㈠ INDEX UNIQUE SCAN
如 果表上有唯一索引, 搜索索引列时会用上INDEX UNIQUE SCAN
原来Index Unique Scan和Index Range Scan在B Tree上的搜索路径是一样的
只是Index Unique Scan在找到应该含有要找的Index Key的block后便停止了搜索,因为该键是唯一的
而Index Range Scan还要循着指针继续找下去直到条件不满足时
Oracle9i Database Performance Tuning Guide and Reference提到:
This access path is used when all columns of a unique (B-tree) index are specified with equality conditions
如 果表上有唯一索引, 搜索索引列时会用上INDEX UNIQUE SCAN
原来Index Unique Scan和Index Range Scan在B Tree上的搜索路径是一样的
只是Index Unique Scan在找到应该含有要找的Index Key的block后便停止了搜索,因为该键是唯一的
而Index Range Scan还要循着指针继续找下去直到条件不满足时
Oracle9i Database Performance Tuning Guide and Reference提到:
This access path is used when all columns of a unique (B-tree) index are specified with equality conditions
下面测试一下这句话的真实性:
hr@ORCL> create table t (id number,name varchar2(10));
hr@ORCL> create unique index ind_t on t (id);
hr@ORCL> insert into t values(1,'a');
hr@ORCL> insert into t values(2,'b');
hr@ORCL> commit;
hr@ORCL> set autot trace exp
hr@ORCL> select * from t where id=1;
Execution Plan
----------------------------------------------------------
Plan hash value: 1366100657
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 20