Large data movement

oracle

I would like to move billions of rows from schema1.table1 to new schema2.table2 where table2 is a refactored one from table1. Hence their table structure is different. both table1 and table2 are partitioned but table2 is empty. Both these schemas are in the same oracle DB. What is performance efficient way to perform this data migration? Would you want to perform commit only at the very end or opt for incremental commit? i.e. let's say data migration fails after completing 99% of the job which took few hours. Do you rollback now?
If you do the incremental commit, how do you handle the failure?

Best Answer

Parallel INSERT APPEND with NOLOGGING would be the way to do this, then as with all NOLOGGING operations, take a backup immediately on completing. Mark indexes unusable first, disable constraints, alter table, perform the operation, then re-enable constraints etc.

Append causes Oracle to always grab free space above the current high water mark, so it's not efficient at reusing space in the segment, but it avoids fiddling with the freelist and the UNDO overhead. If you have to start again for any reason, TRUNCATE, don't DELETE.

As to the incremental commit, it will depend on how your data is segmented, can you easily say move a month's worth at a time (e.g. is the partitioning scheme the same in source and target)? Because remember that if you need to satisfy some predicate, that will obviously slow you down. Test to make sure the operation isn't going to fail logically (e.g. incompatible datatypes in source and target) then allocate sufficient resources and just go for it in one transaction. Good luck!