Professional Documents
Culture Documents
Rebuilding Fragmented Indexes: Symptom
Rebuilding Fragmented Indexes: Symptom
Symptom
Indexes are fragmented and require an unnecessarily large amount of space on the database.
Other Terms
Solution
The essential alternatives to defragmenting indexes are:
1. REBUILD
Mechanism
In a REBUILD an index is completely rebuilt as a new segment.
Advantages
Optimal defragmentation is available.
Parallel processing based on parallel DDL (Note 651060) is possible.
If required, storage parameters can be changed.
The index can be moved to another tablespace.
Disadvantages
There is a longer runtime than with COALESCE.
There is an increased storage requirement in the tablespace during the REBUILD (as
the original and new index exist in parallel during this time).
There may be problems as described in Note 682926.
Options
ONLINE: The index is built without keeping a permanent lock. However, critical locks
are still possible (Note 682926). Complete tables must be scanned when the index is
being rebuilt (during the OFFLINE rebuild "only" the source index has to be
scanned).
NOLOGGING: Changes are not logged in the redo logs (Note 547464).
PARALLEL: The index build is distributed to several parallel execution slaves. When
you use this option, NOPARALLEL must be used to undo the parallelism (Note 651060)
after the REBUILD is completed. BRSPACE does this automatically.
COMPUTE STATISTICS: New CBO statistics are created for the index. As of Oracle 10g
and when you use BRSPACE, this is the case by default.
Call
SQLPLUS:
ALTER INDEX "<index_name>" REBUILD [ONLINE] [NOLOGGING]
[PARALLEL <degree>] [COMPUTE STATISTICS]
[REBUILD PARTITION "<partition_name>"];
BRSPACE:
Report RSANAORA
Report RSORAISQN (Note 979054)
2. COALESCE
Mechanism
Data in the leaf blocks under the same branch blocks is defragmented; the index
in relation to the root and branch blocks remains unchanged. However, the number of leaf
blocks may sink dramatically.
Advantages
There is no lock.
No additional space is required in the tablespace.
It is relatively fast.
Disadvantages
There is no defragmentation in the root and branch block area.
The index cann be moved to another tablespace.
Options
PARALLEL: COALESCE is distributed to several parallel execution slaves. When you use
this option, you must use NOPARALLEL to undo the parallelism (Note 651060) after
COALESCE is completed. BRSPACE executes this automatically.
Call
SQLPLUS:
Manual Activities
979054 RSORAISQN
852189
1485841 ALTER INDEX REBUILD does not backup old index statistics
1485841 ALTER INDEX REBUILD does not backup old index statistics
979054 RSORAISQN