2种方法发现一个索引是否碎片过多,而需要rebuild

有2种方法发现一个索引是否碎片过多,而需要rebuild:
方法1:
下面的视图中关于索引的统计信息:
1. DBA_INDEXES - for non partitioned indexes and aggregate information for all the partitions.
2. DBA_IND_PARTITIONS - identical to above view, but provides information about individual partitions.
从碎片的观点来看,比较重要的列为:
BLEVEL - the btree level - 0 based
LEAF_BLOCKS - Number of leaf blocks in the tree
NUM_ROWS - number of rows in the tree
SAMPLE_SIZE - what sampling did we do - provides level of confidence
不幸的是,在视图中没有提供average row size。我们不得不根据在索引中的列计算average row size以及使用该值来得到索引的利用率。
utilization_factor =
(NUM_ROWS*average_row_size)/(LEAF_BLOCKS*usable_block_size) where usable_block_size = database block size - standard overhead (~ <= 100 bytes).

注意:analyze index index_name validate structure;并不会使dba_indexes中的BLEVEL列有值,而只有compute statistics;  才会。

我们利用DBA_INDEXES进行碎片的估计时,只能根据BLEVEL列来进行大体的判断,认为BLEVEL>4的索引就应该进行考虑其碎片问题,如果真的发现是有碎片问题则需要对索引进行rebuild,否则如果是因为数据过多造成的则建议将索引分区。
下面是用的sql语句:
select index_name, blevel,
        decode(blevel,0,'OK BLEVEL',1,'OK BLEVEL',  
        2,'OK BLEVEL',3,'OK BLEVEL',4,'OK BLEVEL','BLEVEL HIGH') OK  
from dba_indexes  
where owner='SCOTT'
order by blevel;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值