You are on page 1of 2

When to Rebuild an Index?

It is important to periodically examine your indexes to determine if they have become


skewed and might need to be rebuilt.
When an index is skewed, parts of an index are accessed more frequently than others.
As a result, disk contention may occur,creating a bottleneck in performance. Here is a
sample procedure on how to identify the such indexes
!. "ather statistics on your indexes. #or large indexes $over one hundred thousand
records in the underlying table%, use &'(I)A(& instead of *+),-(& '(A(I'(I*'.
#or example
'./0 analy1e index emp2empno2pk compute statistics3
Index analy1ed.
4. 5un the query below to find out how skewed each index is. (his query checks on
all indexes that are on emp table.
'./0select index2name, blevel,
decode$blevel,6,7+8 9/&:&/7,!,7+8 9/&:&/7,4,
7+8 9/&:&/7,;,7+8 9/&:&/7,<,7+8 9/&:&/7,79/&:&/ HI"H7% +8
from user2indexes where table2name=7&),73
INDEX_NAME BLEVEL OK
&),2&),>+2,8 6 +8 9/&:&/
;. (he 9/&:&/ $or branch level% is part of the 9?tree index format and relates to the
number of times +racle has to narrow its search on the index while searching for a
particular record. In some cases, a separate disk hit is requested for each 9/&:&/. If
the 9/&:&/ were to be more than <, it is recommended to rebuild the index.
Note: If you do not analy1e the index, the index2check.sql script will show @9/&:&/
HI"H@ for such an index.
<. "ather more index statistics using the :A/IAA(& '(5-*(-5& option of the
A>A/BC& command to populate the I>A&D2'(A(' virtual table.
'./0 analy1e index emp2empno2pk validate structure3
Index analy1ed.
E. 5un the following query to find out ,*(2A&/&(&A ratio.
'./0 select A&/2/#25+W'F!66Gdecode$/#25+W', 6, !, /#25+W'%
,*(2A&/&(&A,
4 $/#25+W'?AI'(I>*(28&B'%F!66G decode$/#25+W',6,!,/#25+W'%
AI'(I>*(I:&>&''
; from index2stats
< where >A)&=7&),2&),>+2,873
P!_DELE!ED DI"!IN!IVENE""
6 6
(he ,*(2A&/&(&A column shows the percent of leaf entries $i.e. index entries% that
have been deleted and remain unfilled. (he more deleted entries exist on an index, the
more unbalanced the index becomes. If the ,*(2A&/&(&A is 46H or higher, the
index is candidate for rebuilding. If you can afford to rebuild indexes more frequently,
then do so if the value is higher than !6H. /eaving indexes with high
,*(2A&/&(&A without rebuild might cause excessive redo allocation on some
systems.
(he AI'(I>*(I:&>&'' column shows how often a value for the column$s% of the
index is repeated on average. #or example, if a table has !6666 records and I666
distinct ''> values, the formula would result in $!6666?I666% x !66 G !6666 = !6.
(his shows a good distribution of values. If, however, the table has !6666 records and
only 4 distinct ''> values, the formula would result in $!6666?4% x !66 G!6666 =
II.IJ. (his shows that there are very few distinct values as a percentage of total
records in the column. 'uch columns are not candidates for a rebuild but good
candidates for bitmapped indexes.

You might also like