Oracle Tips by Burleson
Re-sequencing table rows to
reduce disk I/O
Basically, the create table as select (CTAS) statement copies the
selected portion of the table into a new table. If you select the
entire table with an order by clause or an index hint, it will copy
the rows in the same order as the primary index. In addition to
re-sequencing the rows of the new table, the CTAS statement
coalesces free space and chained rows and resets freelists, thereby
providing additional performance benefits. You can also alter table
parameters, such as initial extents and the number of freelists, as
you create the new table. The steps in a CTAS reorganization
1. Define a separate tablespace (maybe with a different blocksize)
to hold the reorganized table.
2. Disable all referential integrity constraints.
3. Copy the table with CTAS (using order by or an index hint)
4. Reenable all referential integrity constraints.
5. Rebuild all indexes on the new table.
The main benefit of CTAS over the other methods is speed. It is far
faster to use CTAS to copy the table into a new tablespace (and then
re-create all RI and indexes) than it is to use the export/import
method. Using CTAS also has the added benefit of allowing the rows
to be resequenced into the same order as the primary index, thereby
greatly reducing I/O. Within CTAS, there are two general
Download your Oracle scripts now:
definitive Oracle Script collection for every Oracle professional DBA