analyze index 时validate structure和compute statistics的区别

analyze index 时validate structure和compute statistics的区别

analyze index index1 validate structure:
analyze index index1 compute statistics:

在分析索引的时候,一般会用到以上二个命令,那么这二个命令是用来干什么呢?
analyze index index1 validate structure:是用来分析索引的数据块是否有坏块以及根据分析得到的数据(存放在index_stats)來判断索引是否需要重新建立

什么样的index需要rebuild?
当一个table经常进行DML操作时,它的索引会存在许多block空间的浪费,这是因为index block中的记录只有在全部表示为不可用时, block 才能被加入到freelist中去被重新利用。所以我们需要寻找那些浪费空间很严重的index。
方法是:
1) analyze index index_name validate structure;
2) select del_lf_blk_len/lf_blk_len from index_stats where name = :index_name;
3) 如果结果大于20%, 那你的Index就可以被rebuild了。

validate structure有二中模式: online, offline, 默认是offline模式。以offline模式分析时, 会對表加一个4级別的锁(表共享),对run系統可能造成一定的影响。而online模式则没有表lock的影响,但当以online模式分析时, 在视图index_stats没有统计信息

analyze index index1 compute statistics:是用来统计index的分析信息,来为CBO服务的。从9i开始,Oracle以建议使用dbms_stats package代替 analyze 了。

请使用浏览器的分享功能分享到微信等