compress index试验

create index idx_a02 on A02 (owner, object_type, object_name);
analyze table a02 compute statistics;
select t.leaf_blocks from user_indexes t where t.index_name='IDX_A02';
29

drop index idx_a02;
create index idx_a02 on A02 (owner, object_type, object_name) compress 1;
analyze table a02 compute statistics;
select t.leaf_blocks from user_indexes t where t.index_name='IDX_A02';
25

drop index idx_a02;
create index idx_a02 on A02 (owner, object_type, object_name) compress 2;
analyze table a02 compute statistics;
select t.leaf_blocks from user_indexes t where t.index_name='IDX_A02';
20

drop index idx_a02;
create index idx_a02 on A02 (owner, object_type, object_name) compress 3;
analyze table a02 compute statistics;
select t.leaf_blocks from user_indexes t where t.index_name='IDX_A02';
33

可以看出当compress为0,1,2时叶块一次减少,但当compress为3时比没有compress时占用的叶块更多。
这是因为owner,object_type都有比较多的重复值,而object_name时唯一的。oracle在做compress时会为每个唯一的值增加4bytes的开销,
比如组合索引(x,y),x占用1byte,y占用60bytes,共100条,x都是同样的值而y是唯一的。没有compress时,占用空间为61x100=6100。
当做compress 2时占用的空间为1+4+(60+4)x100=6405。所以会比no compress占用更多空间。
使用compress index会增加cpu使用,但每个叶块存放更多的索引条目,增加buffer hit ratio,减少physical read,但是也会增加block contention的出现机率。

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值