You are on page 1of 4

SAP Note

332677 - Rebuilding fragmented indexes


Component: BC-DB-ORA (Oracle), Version: 18, Released On: 07.02.2012

Symptom
Indexes are fragmented and require an unnecessarily large amount of space on the database.

Other Terms

Reason and Prerequisites


If, on the basis of an index fragmentation analysis (for example, according to Note 771929)
you decide to defragment indexes, there are different approaches available. The following
section deals with these approaches and their advantages and disadvantages.

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:

brspace -f idrebuild -i <index_name> [-NBR] [-e <degree>]


[-a rebpart -ip <partition_name>]
The "-NBR" option ensures that NOLOGGING is used during the REBUILD. The
"-e"- option provides parallel processing. You can use "-a rebpart -ip" as of BRSPACE 7.10
(24) to restructure individual index partitions (Note 1360603).
By default, indexes are rebuilt online. Under the patch prerequiste of
Note 1080376 indexes can also be rebuilt offline using "-m offline".
SAP:

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:

ALTER INDEX "<index_name>" COALESCE;


BRSPACE:

brspace -f idalter -i <index_name> -a coalesce [-d <degree>]


You can use the "-d" option to define the degree of parallelism of the
operation COALESCE.
SAP:

Report RSORAISQN (Note 979054)


3. DROP / CREATE
Mechanism
DROP is used first to completely delete the index and then CREATE rebuilds it.
Advantages
There are none.
Disadvantages
There is a longer runtime than with COALESCE.
There is a danger of duplicate key records if primary indexes are dropped during
live operation.
There may be problems as described in Note 682926.
Conclusion
Due to the significant disadvantages you should generally not use DROP and CREATE.

Manual Activities

This document refers to


SAP Note/KBA Title

979054 RSORAISQN

852189

821687 FAQ: Space utilization and fragmentation in Oracle

771929 FAQ: Index fragmentation

706478 Preventing Basis tables from increasing considerably

682926 Composite SAP note: Problems with "create/rebuild index"

651060 FAQ: Oracle Parallel Execution

618868 FAQ: Oracle performance

541538 FAQ: Reorganization

459199 Measures during the Euro currency conversion

435125 Poor performance of tables used by CRM (Oracle only)

369123 ORA-600 [6050] or ORA-600 [25012]

1597364 FAQ: BW-BCT: Extraction performance in source system

1485841 ALTER INDEX REBUILD does not backup old index statistics

147139 Build.summarization levels CO-PA is slow/terminates

1360603 Reorganization and rebuild of individual partitions

1080376 Enhancements for reorganization and rebuild

This document is referenced by


SAP Note/KBA Title

2931495 Program RSANAORA failed with DBIF_DSQL2_OBJ_UNKNOWN runtime error

618868 FAQ: Oracle performance

821687 FAQ: Space utilization and fragmentation in Oracle

706478 Preventing Basis tables from increasing considerably

541538 FAQ: Reorganization

1597364 FAQ: BW-BCT: Extraction performance in source system

682926 Composite SAP note: Problems with "create/rebuild index"

771929 FAQ: Index fragmentation

1485841 ALTER INDEX REBUILD does not backup old index statistics

1360603 Reorganization and rebuild of individual partitions


1080376 Enhancements for reorganization and rebuild

651060 FAQ: Oracle Parallel Execution

979054 RSORAISQN

834118 RBDCPIDXRE in building online indexes

435125 Poor performance of tables used by CRM (Oracle only)

147139 Build.summarization levels CO-PA is slow/terminates

459199 Measures during the Euro currency conversion

369123 ORA-600 [6050] or ORA-600 [25012]

You might also like