反向键索引为了减少叶节点竞争,这些列主要是序列产生或者时间戳。
没插入一条记录,索引都会按照索引列值的大小进行排序,如果使用序列,导致插入集合的索引聚集在少量叶节点上,当大量用户修改或者读取它是,访问比较集中的几个块,导致块竞争。使用反向键索引,将插入集合的索引均匀分布在叶节点上。
select 123123,dump(123123),reverse('123123') from dual;
应用场景:
1、很少使用区间查询:where between and ,和范围查询
2、求索引列的max min值
3、有大量插入或者更新操作时。
创建反向键索引
create table t_reverse as select rownum id,t.* from all_objects t ;
alter table t_reverse add constraint const_reverse_pk primary key(id)
using index (create unique index const_reverse_idx on t_reverse(id) reverse );
创建不同索引
create table t_unreverse as select rownum id,t.* from all_objects t ;
alter table t_unreverse add constraint const_unreverse_pk primary key(id)
using index (create unique index const_unreverse_idx on t_unreverse(id) );
全表扫描
索引范围扫描
反向键索引有助于缓解缓冲区忙等待问题,提高吞吐量