Oracle Index 的三个问题

http://tech.ddvip.com   2007年05月08日    社区交流

本文详细介绍Oracle Index 的三个问题

  1 0 TABLE ACCESS (FULL) OF 'MYTABLES' (Cost=3132 Card=318474 Byt es=141402456)

  Statistics

  7 recursive calls

  89 db block gets

  41473 consistent gets

  19828 physical reads

  0 redo size

  131489563 bytes sent via SQL*Net to client

  1760245 bytes received via SQL*Net from client

  21729 SQL*Net roundtrips to/from client

  1 sorts (memory)

  0 sorts (disk)

  325917 rows processed

  第二句:

  Execution Plan

  0 SELECT STATEMENT Optimizer=CHOOSE (Cost=346 Card=663 Bytes=2 94372)

  1 0 TABLE ACCESS (BY INDEX ROWID) OF 'MYTABLES' (Cost=346 Card=663

  Bytes=294372)

  2 1 INDEX (RANGE SCAN) OF 'PK_MYTABLES' (UNIQUE) (Cost=5 Card=663)

  Statistics

  1278 recursive calls

  0 db block gets

  6647 consistent gets

  292 physical reads

  0 redo size

  3544898 bytes sent via SQL*Net to client

  42640 bytes received via SQL*Net from client

  524 SQL*Net roundtrips to/from client

  1 sorts (memory)

  0 sorts (disk)

  7838 rows processed

  显而易见,第1句没有使用索引,第2句使用了主键索引 pk_mytables. FF 的巨大影响由此可见一斑。由此想到,我们在写sql 语句时,如果预先估计一下FF, 你就几乎可以预见到Oracle 会否使用索引。

  第二讲、索引也有好坏

  索引有 B tree 索引, Bitmap 索引, Reverse b tree 索引, 等。最常用的是 B tree 索引。 B 的全称是 Balanced , 其意义是,从 tree 的 root 到任何一个 leaf ,要经过同样多的 level. 索引可以只有一个字段( Single column ) , 也可以有多个字段( Composite ) , 最多 32 个字段, 8I 还支持 Function-based index. 许多 developer 都倾向于使用单列 B 树索引。

责编:豆豆技术应用

正在加载评论...