操作系统:rhel 5.4 x86,数据库:oracle 11g r2,实验说明:该实验是为了说明b-tree索引性能优于bitmap索引的情况。 从一致性读
一、实验说明:
操作系统:rhel 5.4 x86
数据库:oracle 11g r2
实验说明:该实验是为了说明b-tree索引性能优于bitmap索引的情况。
oracle b树索引简介(b-tree index)
浅析oracle b-tree index搜索原理
oracle索引之b-tree和bitmap索引对比
从平衡树到oracle b-tree索引的原理探索
二、实验操作:
首先创建一张t_btree表,并建立b-tree索引,索引键是object_id:
sql> create table t_btree as select * from dba_objects;
table created.
sql> create index ind_tree on t_btree(object_id);
index created.
执行两次下面的查询语句,并显示执行计划:
sql> set autotrace traceonly;
sql> select * from t_btree where object_id=9899;
execution plan
----------------------------------------------------------
plan hash value: 447474086
----------------------------------------------------------------------------------------
| id | operation | name | rows | bytes | cost (%cpu)| time |
----------------------------------------------------------------------------------------
| 0 | select statement | | 1 | 207 | 2 (0)| 00:00:01 |
| 1 | table access by index rowid| t_btree | 1 | 207 | 2 (0)| 00:00:01 |
|* 2 | index range scan | ind_tree | 1 | | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
predicate information (identified by operation id):
---------------------------------------------------
2 - access(object_id=9899)
note
-----
- dynamic sampling used for this statement (level=2)
statistics
----------------------------------------------------------
312 recursive calls
0 db block gets
108 consistent gets
289 physical reads
0 redo size
1404 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 * from t_btree where object_id=9899;
execution plan
----------------------------------------------------------
plan hash value: 447474086
----------------------------------------------------------------------------------------
| id | operation | name | rows | bytes | cost (%cpu)| time |
----------------------------------------------------------------------------------------
| 0 | select statement | | 1 | 207 | 2 (0)| 00:00:01 |
| 1 | table access by index rowid| t_btree | 1 | 207 | 2 (0)| 00:00:01 |
|* 2 | index range scan | ind_tree | 1 | | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
predicate information (identified by operation id):
---------------------------------------------------
2 - access(object_id=9899)
note
-----
- dynamic sampling used for this statement (level=2)
statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
1404 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 * from t_bmap where object_id=9899;
execution plan
----------------------------------------------------------
plan hash value: 3763176822
----------------------------------------------------------------------------------------
| id | operation | name | rows | bytes | cost (%cpu)| time |
----------------------------------------------------------------------------------------
| 0 | select statement | | 1 | 207 | 110 (0)| 00:00:02 |
| 1 | table access by index rowid | t_bmap | 1 | 207 | 110 (0)| 00:00:02 |
| 2 | bitmap conversion to rowids| | | | | |
|* 3 | bitmap index single value | ind_map | | | | |
----------------------------------------------------------------------------------------
predicate information (identified by operation id):
---------------------------------------------------
3 - access(object_id=9899)
note
-----
- dynamic sampling used for this statement (level=2)