B樹索引

B樹索引

      結構類似於二叉樹的平衡樹。目標是儘可能減少oracle查找數據的時間

      樹的底層是葉節點(leaf node)或者葉子塊(leaf block),它包含了索引鍵值和鍵值所對應的行的rowid

      葉節點之上所對應的是分支塊(branch block)

     索引特點:

     1、根據索引鍵值和rowid進行排序

      2、葉子節點之間是雙向連接的鏈表(爲索引區間掃描提供便捷——)

       3、因爲是平衡,查找索引鍵值所執行IO次數基本差不多(2~3,根據索引高度來),

4、空置不會維護到索引中去(除了函數索引對空置有特殊處理)

5、基本一個索引鍵值條目對應一行記錄

drop table person;
create table person (id int,name varchar2(100));
create unique index ind_person_id on person(id);
begin
       for i in 1..10 loop
           insert into person(id,name) values(i,'name'||i);
       end loop;
       commit;
end;

select t.blevel from user_indexes t where t.index_name=upper('ind_person_id');
analyze index ind_person_id validate structure ;----組建索引
analyze index ind_person_id compute statistics ;---計算統計信息
select t.* from user_indexes t where t.index_name=upper('ind_person_id');



決定索引的性能,有一個函數決定,這個函數由下面參數決定:

1、通過索引獲取的訪問表中數據的多少(百分比)

2、表中的數據如何佈局。

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