Guidelines for rebuilding indexes
Guidelines for rebuilding Index.
Find out indexes that are fragmented
1) select TABLESPACE_NAME , SEGMENT_NAME , COUNT(*)
from DBA_EXTENTS
where SEGMENT_TYPE = 'INDEX'
group by TABLESPACE_NAME , SEGMENT_NAME HAVING COUNT(*) > 5
ORDER BY 3 DESC
this SQL gives you indexs that are fragmented. Change the
group predicate condition if you wish
2) analyze index validate structure
will analyze the index structure
3) select * from index_stats
will display the computed statistics. Some significant fields are
HEIGHT, BLOCK ,
computed value for DEL_LF_ROWS /decode( LF_ROWS,0,1,LF_ROWS ))*100
( According to Oracle for any index, if HEIGHT > 4 or the computed ratio is greater than 25 then the index is a candidate for rebuild.)
4 )select name , value from v$parameter
where name = 'db_block_size' . This will give the value of
db_block_size.
5 ) Rebuild the index
alter index rebuild tablespace
strorage (initial comp_val1 , next comp_val2 , pctincrease 0 )
comp_val1 = BLOCK ( generated in step 3 ) * value of db_block_size
comp_val2 = comp_vale1/2
6 ) If needed create a PL SQL script to autmatically perform all these
steps and run it when the work load on the server is low.