ent
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
1 rows processed
no,貌似没有index fast full scan而是走了单块读的index full scan;
SQL> set autotrace trace
SQL> select /*+index_ffs(emp emp_pk)*/ count(empno) from emp;
Execution Plan
----------------------------------------------------------
Plan hash value: 3578136827
------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | INDEX FAST FULL SCAN| EMP_PK | 14 | 2 (0)| 00:00:01 |
------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
23 consistent gets
0 physical reads
0 redo size
530 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
NO.2:部分列不存在索引列中。
SQL> select empno,ename,job from emp where empno=7369;
Execution Plan
----------------------------------------------------------
Plan hash value: 122628344
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 52 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 2 | 52 | 1 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | EMP_PK | 2 | | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO"=7369)
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
7 recursive calls
0 db block gets
26 consistent gets
0 physical reads
0 redo size
735 bytes sent via SQL*Net to client
523 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed
SQL>
可以看到当查询列不存在于索引列的时候,将会通过rowid来对数据表进行访问数据,因为B数索引就是通过rowid和建立索引的列值组合的。注意当该表中存在多条记录的时候consistent gets并不能代表真正的数据块的一直性读,因为重新读取的块被收集在缓存区被钉住计数(buffer is pinned count)。
对于rowid的理解请参考我的另一篇笔记:
http://blog.csdn.net/rhys_oracle/article/details/11715735
NO。3:不适用索引的情况。
SQL> select * from emp;
28 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 3956160932
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 28 | 2436 | 6 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| EMP | 28 | 2436 | 6 (0)| 00:00:01 |
--------------------------------------------------------------------------
Note
-----