设为首页 加入收藏

TOP

B树索引学习总结。(二)
2014-11-24 01:08:16 来源: 作者: 【 】 浏览:38
Tags:索引 学习 总结
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
-----
首页 上一页 1 2 3 4 5 6 下一页 尾页 2/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇ACCESS 外链文件 下一篇Oracle系统包

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: