反向鍵索引

反向鍵索引爲了減少葉節點競爭,這些列主要是序列產生或者時間戳。

沒插入一條記錄,索引都會按照索引列值的大小進行排序,如果使用序列,導致插入集合的索引聚集在少量葉節點上,當大量用戶修改或者讀取它是,訪問比較集中的幾個塊,導致塊競爭。使用反向鍵索引,將插入集合的索引均勻分佈在葉節點上。

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) );


全表掃描


索引範圍掃描


反向鍵索引有助於緩解緩衝區忙等待問題,提高吞吐量


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章