索引反向使用案例,加index_desc hint
drop index idx_t;
create index idx_t on t(owner desc,object_type asc);
select /*+index(a,idx_t)*/ * from t a order by owner desc ,object_type asc;
執行計劃
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74796 | 14M| 3463 (1)| 00:00:42 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 74796 | 14M| 3463 (1)| 00:00:42 |
| 2 | INDEX FULL SCAN | IDX_T | 74796 | | 272 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
12975 consistent gets
0 physical reads
0 redo size
3400784 bytes sent via SQL*Net to client
54052 bytes received via SQL*Net from client
4878 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
73154 rows processed
select /*+index(a,idx_t)*/ * from t a order by owner asc ,object_type desc;
執行計劃
----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74796 | 14M| | 6831 (1)| 00:01:22 |
| 1 | SORT ORDER BY | | 74796 | 14M| 17M| 6831 (1)| 00:01:22 |
| 2 | TABLE ACCESS BY INDEX ROWID| T | 74796 | 14M| | 3463 (1)| 00:00:42 |
| 3 | INDEX FULL SCAN | IDX_T | 74796 | | | 272 (1)| 00:00:04 |
----------------------------------------------------------------------------------------------
統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
3459 consistent gets
0 physical reads
0 redo size
3439096 bytes sent via SQL*Net to client
54052 bytes received via SQL*Net from client
4878 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
73154 rows processed
select /*+index_desc(a,idx_t)*/ * from t a order by owner asc ,object_type desc;
執行計劃
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74796 | 14M| 3463 (1)| 00:00:42 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 74796 | 14M| 3463 (1)| 00:00:42 |
| 2 | INDEX FULL SCAN DESCENDING| IDX_T | 74796 | | 272 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
12968 consistent gets
0 physical reads
0 redo size
3400803 bytes sent via SQL*Net to client
54052 bytes received via SQL*Net from client
4878 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
73154 rows processed
此處引用梁老師例子。
create index idx_t on t(owner desc,object_type asc);
select /*+index(a,idx_t)*/ * from t a order by owner desc ,object_type asc;
執行計劃
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74796 | 14M| 3463 (1)| 00:00:42 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 74796 | 14M| 3463 (1)| 00:00:42 |
| 2 | INDEX FULL SCAN | IDX_T | 74796 | | 272 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
12975 consistent gets
0 physical reads
0 redo size
3400784 bytes sent via SQL*Net to client
54052 bytes received via SQL*Net from client
4878 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
73154 rows processed
select /*+index(a,idx_t)*/ * from t a order by owner asc ,object_type desc;
執行計劃
----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74796 | 14M| | 6831 (1)| 00:01:22 |
| 1 | SORT ORDER BY | | 74796 | 14M| 17M| 6831 (1)| 00:01:22 |
| 2 | TABLE ACCESS BY INDEX ROWID| T | 74796 | 14M| | 3463 (1)| 00:00:42 |
| 3 | INDEX FULL SCAN | IDX_T | 74796 | | | 272 (1)| 00:00:04 |
----------------------------------------------------------------------------------------------
統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
3459 consistent gets
0 physical reads
0 redo size
3439096 bytes sent via SQL*Net to client
54052 bytes received via SQL*Net from client
4878 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
73154 rows processed
select /*+index_desc(a,idx_t)*/ * from t a order by owner asc ,object_type desc;
執行計劃
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 74796 | 14M| 3463 (1)| 00:00:42 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 74796 | 14M| 3463 (1)| 00:00:42 |
| 2 | INDEX FULL SCAN DESCENDING| IDX_T | 74796 | | 272 (1)| 00:00:04 |
-------------------------------------------------------------------------------------
統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
12968 consistent gets
0 physical reads
0 redo size
3400803 bytes sent via SQL*Net to client
54052 bytes received via SQL*Net from client
4878 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
73154 rows processed
此處引用梁老師例子。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2085121/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle索引HINT的使用Oracle索引
- 【HINT】使用“NO_INDEX ”Hint提示避免SQL使用特定索引IndexSQL索引
- oracle hint /*+ BYPASS_UJVC*/ 使用案例Oracle
- 【索引】反向索引引起排序索引排序
- 【Oracle】-【索引-HINT,執行計劃】-帶HINT的索引執行計劃Oracle索引
- oracle hint之full,index,index_asc,index_desc,index_combile示例OracleIndex
- 【優化】使用反向索引(Reverse Key Indexes)減少索引熱點塊優化索引Index
- 反向索引處理前%索引
- oracle之 反向鍵索引Oracle索引
- 【索引】反向索引--條件 範圍查詢索引
- 反向索引與模糊查詢索引
- 【索引】反向索引--條件 範圍查詢(二)索引
- Use index_descIndex
- sql調優一例---索引排序hintSQL索引排序
- ORACLE 通過SPM為SQL語句加HINTOracleSQL
- oracle 通過sql profile為sql語句加hintOracleSQL
- SQL優化案例-正確的使用索引(二)SQL優化索引
- Oracle優化案例-正確的使用索引(二)Oracle優化索引
- ORACLE使用HINT的方法Oracle
- LOCAL INDEX和HINT的使用【DO BE USED LOCAL INDEX IN HINT】薦Index
- sql優化案例一:使用了表示式不會使用索引SQL優化索引
- SQL最佳化案例-正確的使用索引(二)SQL索引
- 【sql調優之執行計劃】使用hint(五)Hint for parallelSQLParallel
- Oracle之Hint使用總結Oracle
- Oracle 反向索引 where index_column like '%xxx'Oracle索引Index
- 檢視SQL PROFILE使用的HINTSQL
- Oracle中“HINT”的使用方法Oracle
- oracle經常使用到的hintOracle
- Redis分散式鎖加鎖案例Redis分散式
- SQL優化案例一則--複合索引沒有被使用SQL優化索引
- 加hint改變執行計劃訪問順序優化sql優化SQL
- nginx 反向代理 swoole 使用Nginx
- 【微信公眾號● DBAplus】Oracle原廠老兵:從負面案例看Hint的最佳使用方式Oracle
- nginx反向代理和負載均衡策略實戰案例Nginx負載
- sql優化一例(index_desc)SQL優化Index
- oracle索引分類rebuild案例集Oracle索引Rebuild
- 分割槽表索引實踐案例索引
- 使用hint改變執行計劃