(1)INDEX UNIQUE SCAN
唯一索引扫描,唯一索引即做单一匹配。在唯一索引中,每个非空键值只有唯一的一条,主键也是唯一索引。
示例:
SQL> execsql_explain('select * from emp where empno=8888');
Plan hash value:2949544139
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 39 | 1 (0)|00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID|EMP | 1 | 39 | 1 (0)|00:00:01 |
|* 2 | INDEXUNIQUE SCAN | PK_EMP | 1 | | 0 (0)|00:00:01 |
--------------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
2 -access("EMPNO"=8888)
PL/SQL 过程已成功完成。
(2)INDEX RANGE SCAN
非唯一索引扫描,对应唯一索引扫描,索引进行范围匹配,(例如>、<、like等)或进行单一匹配(例如=)
示例:
SQL> create tablet_xyc as select * from emp;
表已创建。
SQL> insert intot_xyc select * from emp;
已创建15行。
SQL> commit;
提交完成。
SQL> create indexxyc_index on t_xyc(empno);
索引已创建。
---用等号(=)进行单一匹配
SQL> execsql_explain('select * from t_xyc where empno=8888');
Plan hash value:767710755
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 78 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID|T_XYC | 2 | 78 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | XYC_INDEX | 2| | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
2 -access("EMPNO"=8888)
PL/SQL 过程已成功完成。
----用大于(>)进行范围匹配
SQL> execsql_explain('select * from t_xyc where empno>8888');
Plan hash value:767710755
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 78 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID|T_XYC | 2 | 78 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | XYC_INDEX | 2 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
2 -access("EMPNO">8888)
PL/SQL 过程已成功完成。
(3)INDEX RANGE SCAN(MIN/MAX)
对索引进行范围扫描来获得索引字段的最大或最小值。
示例:
SQL> execsql_explain('select min(empno) from t_xyc where empno>8888');
Plan hash value:2706514164
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 4 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 4 | | |
| 2 | FIRST ROW | | 1 | 4 | 1 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN (MIN/MAX)|XYC_INDEX | 1 | 4 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
3 -access("EMPNO">8888)
PL/SQL 过程已成功完成。
(4)INDEX FAST FULLSCAN
快速完全索引扫描,不按照索引逻辑顺序读取索引数据块,而是以物理顺序读取索引数据库(可以每次读取多个块,多块读取)。
示例:
SQL> begin
2 fori in 1..10000 loop
3 insert into fast_xyc values(i,'向银春');
4 endloop;
5 commit;
6 end;
7 /
PL/SQL 过程已成功完成。
SQL> create indexfast_idx on fast_xyc(id);
索引已创建。
SQL> execsql_explain('select id from fast_xyc where id>5');
Plan hash value:1029382659
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 9995 | 126K| 9 (0)| 00:00:01 |
|* 1 | INDEX FAST FULL SCAN| FAST_IDX| 9995 | 126K| 9 (0)| 00:00:01 |
---------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
1 - filter("ID">5)
Note
-----
- dynamic samplingused for this statement (level=2)
PL/SQL 过程已成功完成。
(5)INDEX FULL SCAN
全索引扫描,即对索引进行完全扫描,它与索引快速全扫描区别在于:
①它是按照索引数据的逻辑顺序去读,而快速全扫描是按照物理存储顺序读取。
②它每次只能读取一个数据块,而快速全扫描可以读取多个数据块。
示例:
SQL> set pagesize0
SQL> set lines400
SQL> setserveroutput on
SQL> execsql_explain('select empno from emp');
Plan hash value:179099197
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 15 | 60 | 1 (0)| 00:00:01 |
| 1 | INDEX FULL SCAN | PK_EMP| 15 | 60 | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------
PL/SQL 过程已成功完成。
(6)INDEX SAMPLE FASTFULL SCAN
索引快速完全采样扫描,以多数据块和物理存储数据读取方式扫描部分数据块。示例:
----sample(10)表示采样10%;
SQL> exec sql_explain('selectid from fast_xyc sample(10) where id>5');
Plan hash value:3595809218
----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1000 | 14000 | 7 (0)| 00:00:01 |
|* 1 | INDEX SAMPLE FAST FULL SCAN|FAST_IDX | 1000 | 14000 | 7 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
1 -filter("ID">5)
(7)INDEX FULL SCAN (MIN/MAX)
对索引字段全扫描,以获取索引字段最大,最小值。
示例:
SQL> execsql_explain('select max(empno) from emp');
Plan hash value:1707959928
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 4 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 4 | | |
| 2 | INDEX FULL SCAN (MIN/MAX)|PK_EMP | 1 | 4 | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------
PL/SQL 过程已成功完成。
(8)INDEX FULL SCANDESCENDING
以索引逻辑顺序相反的顺序进行完全扫描
示例:
SQL> execsql_explain('select * from emp order by empno desc');
Plan hash value:3088625055
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 15 | 585 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID|EMP | 15 | 585 | 2 (0)| 00:00:01 |
| 2 | INDEX FULL SCAN DESCENDING|PK_EMP | 15 | | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
PL/SQL 过程已成功完成。
(9)INDEX SKIP SCAN
索引跳跃扫描,在复合索引中,如果后续索引比第一索引唯一性强,而且用后续索引作为过滤条件时,会发生索引跳跃扫描。
示例:
----创建name为第一索引,但是id字段唯一性要强
SQL> create indexfh_index1 on fast_xyc(name,id);
索引已创建。
SQL> execsql_explain('select * from fast_xyc where id=:A');
Plan hash value:3991949787
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 15 | 4 (0)| 00:00:01 |
|* 1 | INDEX SKIP SCAN |FH_INDEX1 | 1 | 15 | 4 (0)| 00:00:01 |
------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
1 -access("ID"=TO_NUMBER(:A))
filter("ID"=TO_NUMBER(:A))
PL/SQL 过程已成功完成。
(10)索引连接扫描:Index Join Scan
alter table emp modify (SAL not null, ENAME not null);
create index I_ENAMEon EMP(ename);
create index I_SAL onEMP(sal);
select /*+ INDEX_JOIN(e) */ ename, sal from emp e;
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 140 |
| 1 | VIEW | index$_join$_001 | 14 | 140 |
| 2 | HASH JOIN | | | |
| 3 | INDEX FAST FULL SCAN| IX_SS | 14 | 140 |
| 4 | INDEX FAST FULL SCAN| I_ENAME | 14 | 140 |
--------------------------------------------------------------------
Predicate Information(identified by operation id):
---------------------------------------------------
2 - access(ROWID=ROWID)
(11)DOMAIN INDEX
访问域索引(例如全文索引)
示例:
SQL> execsql_explain('select * from qw_xyc where contains(name,:A)>0');
Plan hash value:2774494995
----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 460 | 19780 | 91 (0)| 00:00:02 |
| 1 | TABLE ACCESS BY INDEX ROWID|QW_XYC | 460 | 19780 | 91 (0)| 00:00:02 |
|* 2 | DOMAIN INDEX | QW_INDEX | | | 4 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
PredicateInformation (identified by operation id):
---------------------------------------------------
2 -access("CTXSYS"."CONTAINS"("NAME",:A)>0)
Note
-----
- dynamic samplingused for this statement (level=2)
PL/SQL 过程已成功完成。
(12)BITMAP INDEX SINGLEVALUE
位图索引单值,即对一个键值访问(可以参考上边的B树索引,不举例)。
(13)BITMAP INDEX RANGESCAN
位图范围扫描(可以参考上边的B树索引,不举例)。
(14)BITMAP INDEX FAST FULLSCAN
位图索引全扫描(可以参考上边的B树索引,不举例)。
(15)BITMAP INDEX FASTFULL SCAN
位图索引快速全扫描(可以参考上边的B树索引,不举例)。
位图索引访问例子:
SELECT * FROMPERF_TEAM WHERE country='FR';
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 45 |
| 1 | TABLE ACCESS BY INDEX ROWID | PERF_TEAM | 1 | 45 |
| 2 | BITMAP CONVERSION TO ROWIDS| | | |
| 3 | BITMAP INDEX SINGLE VALUE | IX_B2 | | |
---------------------------------------------------------------------
Predicate: 3 - access("COUNTRY"='FR')
SELECT * FROMPERF_TEAM WHERE country>'FR';
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 45 |
| 1 | TABLE ACCESS BY INDEX ROWID |PERF_TEAM | 1 | 45 |
| 2 | BITMAP CONVERSION TO ROWIDS| | | |
| 3 | BITMAP INDEX RANGE SCAN | IX_B2 | | |
---------------------------------------------------------------------
Predicate:3 - access("COUNTRY">'FR')
filter("COUNTRY">'FR')