SQL> select * from emp_text where object_id<200;
Execution Plan
----------------------------------------------------------
Plan hash value: 4288487957
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6 | 642 | 153 (0)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| EMP_TEXT | 6 | 642 | 153 (0)| 00:00:02 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID"<200)
Note
-----
- dynamic sampling used for this statement (level=2)
SQL> select * from emp_text where object_id between 20 and 200;
Execution Plan
----------------------------------------------------------
Plan hash value: 4288487957
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 26 | 2782 | 153 (0)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| EMP_TEXT | 26 | 2782 | 153 (0)| 00:00:02 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("OBJECT_ID">
=20 AND "OBJECT_ID"<=200)
Note
-----
- dynamic sampling used for this statement (level=2)
SQL> select * from emp_text where object_id in (10,20,500);
Execution Plan
----------------------------------------------------------
Plan hash value: 1428765950
------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6 | 642 | 31 (0)| 00:00:01 |
| 1 | INLIST ITERATOR | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| EMP_TEXT | 6 | 642 | 31 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | EMP_TEXT_REIDX1 | 42 | | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("OBJECT_ID"=10 OR "OBJECT_ID"=20 OR "OBJECT_ID"=500)
Note
-----
- dynamic sampling used for this statement (level=2)
SQL>
从上面可以看出,对于方向键索引对between xxx and xxx以及不等值的谓词条件oracle是不走方向键索引的,另外之所以走index rance scan,那么说因为序列为递增序列且是order,因此有一部分列如(1-20)都是存在于一个索引叶子节点块中,那么就是走range scan。通常这是不合理的,为了避免出现热块需要序列使用noorder;
另注:
If you use sequence numbers, then always use CACHE with the NOORDER option for optimal performance in sequence number generation. With the CACHEoption, however, you may have gaps in the sequence numbers. If your environment cannot tolerate sequence number gaps