I have a scenario wherein I need to copy 500 million rows from a Table1 to Table2. Couple of points,
- Table1 has 2 billion rows.
- Table2 is a new table and identical to Table1.
- Table1 and Table2 both are of List partition type.
- Both tables has to be in same tablespace and tablespace is created with LOGGING mode.
- TABLESPACE Block size is: 8192, FORCE_LOGGING NO, AUTO EXTEND ON. REDO ARCHIVAL ENABLED
So, here is what my approach to do this activity and I ask for recommendations to improve or maybe prevent some sudden unwanted situations.
- Create Table2 with same structure without any indexes or PK.
- Alter Table2 nologging; --Putting the table in NOLOGGING mode to stop redo generation. This is done just to improve performance.
- Do this activity in 50 parallel jobs (Jobs created based on partitioned column). Partitioned Column has 120 distinct values. So total 120 jobs. First 50 will be posted and as soon as 1 finishes, 51th will be posted and so on.
- Using a Cursor, Bulk Fetch with limit of 5000 and FORALL for insert (With APPEND Hint). Commit immediately after 1 iteration so commit freq is 5000.
- After all the jobs are finished, put Table2 back in LOGGING mode. alter table Table2 logging;
- Create all required indexes and PK on Table2 with Parallel mode enabled and then alter index NOPARALLEL.
Any suggestions? Thanks a lot for your time.