Rebuilding Indexes
Mercredi 9 juillet 2008The simplest way to rebuild and index is:
Alter indexrebuild tablespace ;
This also has the advantage of not preventing the index from being used whilst it is being rebuilt. The tablespace must be specified otherwise the index will be rebuilt in the current users default tablespace.
Rebuilding the index also allows new storage parameters to be assigned to the index.
If the index is corrupt, it must be dropped and recreated.
- Firstly, identify the original creation parameters:
SELECT COLUMN_NAME FROM USER_IND_COLUMNS WHERE INDEX_NAME = 'index_name';
SELECT TABLE_NAME, UNIQUENESS, TABLESPACE_NAME, INITIAL_EXENT, NEXT_EXTENT, MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, PCT_FREE FROM USER_INDEXES WHERE INDEX_NAME = 'index_name';
The above will give you the columns on which the index is based.
- And then drop the index and recreate it:
Drop index
; Create [UNIQUE] index
On ( [ , ] ) tablespace PCTFREE STORAGE ( NEXT K INITIAL K PCTINCREASE MIN_EXTENTS MAX_EXTENTS );
Today, a battle is raging between the “academics” who do not believe that indexes should be rebuilt without expensive studies and the “pragmatists” who rebuild indexes on a schedule because their end-users report faster response times.
I highly recommend Reading up on the differences between these two different approaches.
-Thanks for reading and come back again.




Index du Blog














