BItMap位圖索引

位圖索引是爲了數據倉庫和查詢系統,不適合OLTP系統或者多個併發頻繁地更新。

它是一種結構,使用一個索引鍵條目存儲指向多行的指針。針對索引鍵空置,oracle會單獨列出一個索引條目。

針對Bitmap索引,支持索引鍵值or(IN)查詢和等值查詢

什麼情況下新建Bitmap索引

1、位圖索引相


drop table dept;
drop table emp;
create table dept as select   ''||level name ,level  no  from dual connect  by level<11 ;
 
create table emp(name,deptno) as select t.object_name,mod(rownum,11)+1 from all_objects t;
create bitmap index emp_deptno on emp(deptno);


創建位圖聯接索引

注意聯接條件必須是主鍵

alter table  dept add  constraint dept_pk primary key (no);
create bitmap index emp_link_dept on emp( dept.name)
from emp  ,dept   where dept.no=emp.deptno;
 begin
  dbms_stats.set_table_stats(ownname => user,tabname => 'DEPT',numrows => 100000000,numblks => 1000);
   dbms_stats.set_table_stats(ownname => user,tabname => 'EMP',numrows => 100000000,numblks => 1000);
 end;


通過使用表關聯,從而使得在兩個關聯表中進行一些查詢時,使用關聯bitmap索引














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