Oracle什麼情況下需要rebuild index

lwitpub發表於2012-08-08
主要還是看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%

然後可以用中的指令碼,也可以如下:
條件1
在分析(analyze)指定索引之後,查詢index_statsheight欄位的值,如果這個值>=4 ,則最好重建(rebuild)這個索引。雖然這個規則不是總是正確,但如果這個值一直都是不變的,則這個索引也就不需重建。
條件2
在分析(analyze)指定索引之後,查詢index_statsdel_lf_rowslf_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部落格 ” ,連結:http://blog.itpub.net/628922/viewspace-740375/,如需轉載,請註明出處,否則將追究法律責任。

相關文章