BitMap索引的效率要优于B(2)


Statistics
----------------------------------------------------------
    32  recursive calls
      0  db block gets
    72  consistent gets
    266  physical reads
      0  redo size
    424  bytes sent via SQL*Net to client
    419  bytes received via SQL*Net from client
      2  SQL*Net roundtrips to/from client
      0  sorts (memory)
      0  sorts (disk)
      1  rows processed

SQL> select count(*) from t_bmap where status='VALID';


Execution Plan
----------------------------------------------------------
Plan hash value: 516980546

---------------------------------------------------------------------------------------------
| Id  | Operation              | Name        | Rows  | Bytes | Cost (%CPU)| Time    |
---------------------------------------------------------------------------------------------
|  0 | SELECT STATEMENT          |        |      1 |      5 |      3  (0)| 00:00:01 |
|  1 |  SORT AGGREGATE          |        |      1 |      5 |        |        |
|  2 |  BITMAP CONVERSION COUNT    |        | 62928 |    307K|      3  (0)| 00:00:01 |
|*  3 |    BITMAP INDEX FAST FULL SCAN| STATUS_BMAP |        |        |        |        |
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

3 - filter("STATUS"='VALID')

Note
-----
  - dynamic sampling used for this statement (level=2)


Statistics
----------------------------------------------------------
      0  recursive calls
      0  db block gets
      6  consistent gets
      0  physical reads
      0  redo size
    424  bytes sent via SQL*Net to client
    419  bytes received via SQL*Net from client
      2  SQL*Net roundtrips to/from client
      0  sorts (memory)
      0  sorts (disk)
      1  rows processed

从上面的查询中,我们可以得到,分别给两张内容一样的表做查询的时候,在执行第二次的时候是属于软解析:

从一致性读上比较,B-Tree索引的consistent gets是180,BitMap的是6;

从Cost的消耗上看,B-Tree索引的COST是49,而BitMap的是3。

在索引键是高重复率键值(status)的时候情况下BitMap索引的效率要优于B-Tree索引。

Oracle B树索引简介(B-Tree Index) 

浅析Oracle B-Tree index搜索原理

Oracle索引之B-Tree和Bitmap索引对比

从平衡树到oracle B-Tree索引的原理探索

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/723cf1d07a455bdac0790d084e04cb83.html