INDEX SKIP SCAN是9i之后提供的新功能,实现了即使WHERE条件中不存在索引的前导列也可以使用索引。但是INDEX SKIP SCAN是需要下面几个条件的:
1,版本9i及以后
2,CBO(表和索引都经过分析)
3,索引的前导列重复值很少(选择性低)
4,WHERE条件中不存在索引前导列
create table test_skipscan (a varchar2(10),b number ,c varchar2(100),d date); insert into test_skipscan select '1',dbms_random.value(1,100),object_name,SYSDATE from dba_objects where rownum<10000; insert into test_skipscan select '2',dbms_random.value(1,100),object_name ,SYSDATE from dba_objects where rownum<10000; insert into test_skipscan select '3',dbms_random.value(1,100),object_name ,SYSDATE from dba_objects where rownum<10000; insert into test_skipscan select '4',dbms_random.value(1,100),object_name ,SYSDATE from dba_objects where rownum<10000; exec DBMS_STATS.GATHER_TABLE_STATS(ownname => 'RTP06TA1',tabname => 'TEST_SKIPSCAN', cascade => TRUE,no_invalidate => FALSE); create index i_test_skipscan_1 on test_skipscan(a,c); select * from test_skipscan where c='/2191e31f'; -- use skip scan create index i_test_skipscan_2 on test_skipscan(a,b,c); select * from test_skipscan where b = '111111' AND c='/2191e31f'; -- use skip scan create index i_test_skipscan_3 on test_skipscan(b,c); select * from test_skipscan where c='/2191e31f'; -- use full table scan create index i_test_skipscan_4 on test_skipscan(c); select * from test_skipscan where c='/2191e31f'; -- use range scan