Oracle enable row movement tips
Oracle Database Tips by Donald Burleson
The "enable row movement" feature of Oracle is somewhat
confusing to beginners and this notes describes some times when
"enable row movement" is used.
Oracle has several commands to reclaim unused disk space for objects (tables and
indexes). Using the "alter table xxx shrink space compact" command also
has the benefit of making full-table scans run faster, as less block accesses
are required. With standard Oracle tables, you can reclaim space with the
"alter table shrink space" command:
SQL> alter table mytable enable row movement;
SQL> alter table mytable shrink space;
BEWARE: Enable row movement can cause performance
Using the enable row movement clause can reduce the
clustering_factor for a primary access index, causing excessive
I/O. Oracle introduced the sorted gash cluster as a way to keep an
index in-order with the table rows, a technique that greatly reduces I/O for
Before enabling row movement - Rows clustered with primary index
enabling row movement - Extra I/O for index queries
Beware that using "enable row movement" can cause
Oracle to move rows to discontinuous data blocks, causing a performance
problem. Remember, the physical placement of rows on data blocks can
still make a huge difference in query performance.
For complete details of clustering data to speed-up SQL queries, see my book
Tuning: The Definitive Reference"
Finding tables and indexes for shrinking
The Oracle 10g segment advisor will recommend tables that will benefit from
shrinking and indexes that require rebuilding (to reclaim space).
When you add the clause "enable row movement" to a create table
statement, you are giving Oracle permission to change the
ROWID's. This allows Oracle to condense table rows and
make it easier to reorganize tables. The enable row
movement clause in used within these features:
Alter table xxx shrink space compact - When using Automatic Segment
Storage Management (ASSM, a.k.a. bitmap freelists) you can issue the "alter
table xxx shrink" command. to compress the table rows into less data
blocks, and Oracle moves down the high water mark to release the space.
This makes full-table scans run faster.
Flashback table - Using the flashback table features requires "enable
Table reorganization - An Oracle10g database can reclaim space within
data segments online without affecting the ability of end users to access
their data. The only thing that must be ensured before using online segment
reorganization capability is that the tablespaces have the Automatic Segment
Space Management (ASSM) and row movement features enabled. Oracle10g
introduces the ability to reclaim space from a segment by shrinking of the
segment. Shrinking a segment will make unused space available to other
segments in the tablespace and may improve the performance of queries and
The segment shrink is an online operation where the table being
shrunk is open to queries and DML while the segment is being shrunk.
Additionally, segment shrink is performed in-place. This is a key advantage over
performing Online Table Redefinition for compaction and reclaiming space.
Finding opportunities for enable
With the introduction of the
alter table xxx shrink space
compact syntax, the DBA gets a powerful tool for
effective and easy database space management. However, the DBA
needs to know what data segments experience high space waste in
order to reclaim free space to the database and shrink segments.
This page shows scripts that can be run to identify
opportunities for using the "alter table shrink compact" command
and you can use the
script to report percentages of free space for data segments.
Caveat: Using enable row
movement can corrupt any Oracle features that rely on ROWID,
such as nested tables, and they should be used with caution.
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts.