oracle10g r2_sql tuning_bitmap index位图索引_index性能小测试

conn scott/system

create t_only as select * from dba_objects;

insert /*+ append */ into t_only select * from t_only;

--重复运行多次以上语句,以增大t_only数据量

select owner from t_only where object_type='x';

创始如此索引,就可以非常快速取得查询结果,并不用回表

create index idx_two on t_only(object_type,owner);

然后查看执行计划

set autot trace exp stat

果真如此

但如果对上查询where及select 结果列构建位图索引

查看执行计划却是index range scan,且有回表

 

++++++++++++++++++++++++++++++++++++++++++++

继结测试位图索引与B树索引的存储空间对比

create  bitmap index idx_bit_two on t_only(object_type,owner);

 

select segment_name,bytes/1024/1024 mb from user_segments

  where segment_name in('IDX_TWO','IDX_BIT_TWO');

 

 B树索引大小为

   50m

而位图索引大小却仅仅为

0.8m

 

这就是二者的对比

 

小结:

  bitmap一般用于dw,且用于列值重复值极高的情况

   如用于dml(oltp)下,就会锁住许多行,影响并行的进行

 

 

 

请使用浏览器的分享功能分享到微信等