索引反向使用案例,加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之 反向鍵索引Oracle索引
- 反向索引處理前%索引
- Oracle之Hint使用總結Oracle
- Oracle優化案例-正確的使用索引(二)Oracle優化索引
- SQL優化案例-正確的使用索引(二)SQL優化索引
- SQL最佳化案例-正確的使用索引(二)SQL索引
- MySQL 5.7使用pt-online-schema-change對大表加索引MySql索引
- MySQL索引那些事:什麼是索引?為什麼加索引就查得快了?MySql索引
- mysql為什麼加索引就能快MySql索引
- 怎麼給字串欄位加索引?字串索引
- SQL優化案例-分割槽索引之無字首索引(六)SQL優化索引
- Oracle優化案例-分割槽索引之無字首索引(六)Oracle優化索引
- nginx 反向代理 swoole 使用Nginx
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(五)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(四)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(三)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(二)Oracle
- 【TUNE_ORACLE】Oracle Hint之常用Hint功能概述(一)Oracle
- Redis分散式鎖加鎖案例Redis分散式
- Mysql效能優化:如何給字串加索引?MySql優化字串索引
- nginx反向代理和負載均衡策略實戰案例Nginx負載
- SQL最佳化案例-分割槽索引之無字首索引(六)SQL索引
- 對SQLServer錯誤使用聚集索引的優化案例(千萬級資料量)SQLServer索引優化
- mongodb索引使用MongoDB索引
- Mysql索引使用MySql索引
- 索引的使用索引
- ORACLE的HINT詳解Oracle
- Oracle中的sql hintOracleSQL
- openGauss 支援SQL-hintSQL
- 我就想加個索引,怎麼就這麼難?索引
- GreatSQL 在SQL中使用 HINT 語法修改會話變數SQL會話變數
- oracle不走hint原因1:依據hint會出現錯誤結果Oracle
- SQL優化案例-自定義函式索引(五)SQL優化函式索引
- Oracle優化案例-自定義函式索引(五)Oracle優化函式索引
- MySql索引使用策略MySql索引
- Mysql索引以及使用索引注意事項MySql索引
- Oracle中常見的Hint(一)Oracle
- [20200801]sql hint衝突.txtSQL
- Apache ShardingSphere HINT 實用指南Apache