ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle什么情况下需要rebuild index

Oracle什么情况下需要rebuild index

原创 Linux操作系统 作者:lwitpub 时间:2012-08-08 14:52:52 0 删除 编辑
主要还是看index的扁平程度,
Rebuild the index when :
  - deleted entries represent 20% or more of the current entries
  - the index depth is more then 4 levels.
Possible candidate for bitmap index :
  - when distinctiveness is more than 99%

然后可以用如何找出Oracle中需要或值得重建的索引中的脚本,也可以如下:
条件1
在分析(analyze)指定索引之后,查询index_stats的height字段的值,如果这个值>=4 ,则最好重建(rebuild)这个索引。虽然这个规则不是总是正确,但如果这个值一直都是不变的,则这个索引也就不需重建。
条件2
在分析(analyze)指定索引之后,查询index_stats的del_lf_rows和lf_rows的值,如果(del_lf_rows/lf_rows)*100 > = 20,则这个索引也需要重建。
例子:
SQL > analyze index IND_PK validate structure;
 
SQL > select name,height,del_lf_rows,lf_rows,(del_lf_rows/lf_rows) *100 from index_stats;
 
NAME                               HEIGHT DEL_LF_ROWS    LF_ROWS (DEL_LF_ROWS/LF_ROWS)*100
 
------------------------------ ---------- ----------- ---------- -------------------------
 
INDX_PK                                4      277353     990206                28.0096263
SQL> alter index IND_PK rebuild;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/628922/viewspace-740375/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-05-08

  • 博文量
    107
  • 访问量
    418842