Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1105646
  • 博文数量: 148
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 3555
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-30 13:00
个人简介

About me:Oracle ACE,optimistic,passionate and harmonious. Focus on oracle programming,peformance tuning,db design, j2ee,Linux/AIX,web2.0 tech,etc

文章分类

全部博文(148)

文章存档

2024年(3)

2023年(28)

2022年(43)

2020年(62)

2014年(3)

2013年(9)

分类: Oracle

2020-08-31 15:39:15


接PART1:http://blog.chinaunix.net/uid-7655508-id-5836298.html

1.Bitmap index使用

 

DROP TABLE t;
CREATE TABLE t AS SELECT * from dba_objects;
dingjun123@ORADB> SELECT COUNT(*),
COUNT(DISTINCT owner) FROM t;
  COUNT(*) COUNT(DISTINCTOWNER)
---------- --------------------
     76422                   35
 

分别对owner创建bitmap index和普通index测试




1)在OLAP环境下,使用BITMAP索引比普通B*Tree有很大优势
2)BITMAP索引做COUNT、OR、AND、MINUS等运算,可以充分发挥其性能
3)从例子中可以看出BITMAP索引存储NULL值。

2.Bitmap index的缺点
  下面来做个测试,数据准备如下:

CREATE TABLE bitmap_test(ID NUMBER,status NUMBER);
CREATE BITMAP INDEX idx_bitmap_test ON bitmap_test(status);       
INSERT INTO bitmap_test VALUES(1,0);
INSERT INTO bitmap_test VALUES(2,0);
INSERT INTO bitmap_test VALUES(3,0);
INSERT INTO bitmap_test VALUES(1,1);
INSERT INTO bitmap_test VALUES(2,1);
INSERT INTO bitmap_test VALUES(3,1);
COMMIT;



按照红色数字标识执行顺序:
SESSION1:

SESSION2:
出现enq: TX - row lock contention等待。

1)Bitmap index上如果DML操作,按照位图索引块级别加锁,锁定的行多,容易造成阻塞或死锁。
2)因此,虽然Bitmap index在一些统计运算、提升低选择性列运算性能上有优势,Bitmap index在OLTP中则是坚决杜绝使用的。只有在OLAP环境下,数据加载完毕后,基本处于只读状态,主要进行统计分析,才比较适合。
这个例子,在B*tree中则不会出现阻塞或死锁情况。
阅读(9734) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~