During Extract/Transform/Load (ETL) projects we do a lot of data loading, deleting and reloading. I have come up with this simple solution to better manage and organize the table space and performance during ETL operations. Our table size grew considerably though it has much less data. So any full table scan operation was taking a long time. After we used this method, we reduced the table size, released unused table space and gained lot of time during full table scan operations on the table.
I looked into Oracle documentation on how to reoganize a table and they say to use EXPORT or IMPORT, or it can be done by copying data into a temporary table, using TRUNCATE on the table, and then moving data back to the original table. We were planning to do something like that until I came up with this idea. We use this method to reorganize about 100 tables spanning several GBs of storage space. It was tested using Oralce 22.214.171.124.
We load data into a table by the direct path method:
INSERT /*+ APPEND */In such a direct-path INSERT, data is appended to the end of the table rather than using existing space currently allocated to the table. When we load data into a table and delete some or all of the records by using the DELETE statement, the delete operation does not release the allocated space even if there isn't any data. So until the space is released, they are not going to be used by any direct load operation.
ALTER TABLE <table_name> MOVE;
For More Information
- Feedback: E-mail the editor with your thoughts about this tip.
- More tips: Hundreds of free Oracle tips and scripts.
- Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
- Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
- Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
- Best Web Links: Oracle tips, tutorials, and scripts from around the Web.
This was first published in August 2003