INDEX SKIP SCAN適用場景
--請記住這個INDEX SKIP SCAN掃描方式
drop table t purge;
create table t as select * from dba_objects;
update t set object_type='TABLE' ;
commit;
update t set object_type='VIEW' where rownum<=30000;
commit;
create index idx_type_id on t(object_type,object_id);
exec dbms_stats.gather_table_stats(ownname => 'LJB',tabname => 'T',estimate_percent => 10,method_opt=> 'for all indexed columns',cascade=>TRUE) ;
set autotrace traceonly
set linesize 1000
select * from t where object_id=8;
執行計劃
-------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 94 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 94 | 4 (0)| 00:00:01 |
|* 2 | INDEX SKIP SCAN | IDX_TYPE_ID | 1 | | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=8)
filter("OBJECT_ID"=8)
統計資訊
----------------------------------------------------------
1 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
1401 bytes sent via SQL*Net to client
415 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
總結:
複合索引當謂詞條件不為索引的第一個欄位時,一般不會走索引,但是當複合索引的第一個欄位重複率較高時,會用到INDEX SKIP SCAN(記得收集統計資訊讓oracle知道列的分佈情況)。
drop table t purge;
create table t as select * from dba_objects;
update t set object_type='TABLE' ;
commit;
update t set object_type='VIEW' where rownum<=30000;
commit;
create index idx_type_id on t(object_type,object_id);
exec dbms_stats.gather_table_stats(ownname => 'LJB',tabname => 'T',estimate_percent => 10,method_opt=> 'for all indexed columns',cascade=>TRUE) ;
set autotrace traceonly
set linesize 1000
select * from t where object_id=8;
執行計劃
-------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 94 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 94 | 4 (0)| 00:00:01 |
|* 2 | INDEX SKIP SCAN | IDX_TYPE_ID | 1 | | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID"=8)
filter("OBJECT_ID"=8)
統計資訊
----------------------------------------------------------
1 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
1401 bytes sent via SQL*Net to client
415 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
總結:
複合索引當謂詞條件不為索引的第一個欄位時,一般不會走索引,但是當複合索引的第一個欄位重複率較高時,會用到INDEX SKIP SCAN(記得收集統計資訊讓oracle知道列的分佈情況)。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2085124/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- INDEX SKIP SCANIndex
- 理解index skip scanIndex
- [轉貼]Skip Scan IndexIndex
- 關於INDEX SKIP SCANIndex
- index range scan,index fast full scan,index skip scan發生的條件IndexAST
- 索引優化index skip scan索引優化Index
- oracle hint_skip scan_index_ssOracleIndex
- 高效的SQL(index skip scan使用條件)SQLIndex
- index skip scan的一些實驗。Index
- 跳躍式索引(Skip Scan Index)的淺析索引Index
- 跳躍式索引(Skip Scan Index)淺析 - 轉索引Index
- 【每日一摩斯】-Index Skip Scan Feature (212391.1)Index
- 跳躍式索引掃描(index skip scan) [final]索引Index
- Spark適用於哪些場景?不適用於哪些場景?Spark
- INDEX UNIQUE SCAN,INDEX FULL SCAN和INDEX FAST FULL SCANIndexAST
- 【TUNE_ORACLE】列出走了INDEX SKIP SCAN的SQL參考OracleIndexSQL
- [20180725]index skip-scan operation.txtIndex
- 【INDEX_SS】使用HINT使SQL用索引跳躍掃描(Index Skip Scan)方式快速獲取資料IndexSQL索引
- CDN適用哪些場景?
- rowid,index,INDEX FULL SCAN,INDEX FAST FULL SCAN|IndexAST
- Index Full Scan vs Index Fast Full ScanIndexAST
- Index Full Scan 與 Index Fast Full ScanIndexAST
- Index的掃描方式:index full scan/index fast full scanIndexAST
- INDEX FULL SCAN和INDEX FAST FULL SCAN區別IndexAST
- index full scan 和 index FAST full scan 區別IndexAST
- Index Full Scan 與 Index Fast Full Scan (Final)IndexAST
- Streaming特性和適用場景
- 設計模式適用場景整理設計模式
- SPM適用的場景和示例
- INDEX FULL SCAN和INDEX FAST FULL SCAN的區別IndexAST
- Clustered Index Scan and Clustered Index SeekIndex
- [20181201]奇怪的INDEX SKIP SCAN執行計劃.txtIndex
- MongoDB的優勢和適用場景MongoDB
- index full scan 和 index fast full scan (IFS,FFS)的不同IndexAST
- skip_unusable_index parameterIndex
- Index Unique Scan (213)Index
- 企業雲盤適用哪些應用場景
- 區塊鏈不適用的若干場景區塊鏈