Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Purge Large Dataset

user12840908Apr 7 2017 — edited Apr 11 2017

Hi,

We have a table with millions of records (approx 120-125 M) and we have to purge few old records which will be close to 35 M (Table is not date partitioned)

It's a live production system. Ofcource we can't simply issue single delete statement and delete all 35 M records in one go.

We plan to create a pl/sql unit to delete records in Batch (lets says of size 100k)

Now the question is, out of two below available methods which will be best from performance point of view.

Background:

Tables:

PURGE_TABLE (table to be purged, primary key REF_NO)

DELETE_ID  - Column1: REF_NO (list of REF_NO to be deleted), Column2: BATCH_NO

Option 1:

For I IN 1.. TOTAL_BATCH

LOOP

DELETE FROM PURGE_TABLE WHERE  REF_NO IN (SELECT REF_NO FROM DELETE_ID WHERE BATCH_NO= I)

COMMIT;

END LOOP;

Option 2:

For I IN 1.. TOTAL_BATCH

SELECT REF_NO INTO TYPE_VAR FROM DELETE_ID WHERE BATCH_NO= I;

FORALL J IN TYPE_VAR.FIRST..TYPE_VAR.LAST

DELETE FROM PURGE_TABLE WHERE  REF_NO = TYPE_VAR(J);

END LOOP;

What will be the best approach?

Regards!

This post has been answered by jgarry on Apr 7 2017
Jump to Answer

Comments

I would definitely go with option #3. It is the easiest and the one with the least down time. I would suggest that you use AutoUpgrade to do the upgrade instead of the manual upgrade. It is easier and it does support having source Oracle Home and target Oracle Home on two different servers. Take a look at the Database Upgrade Quick Start Guide which shows how to get started with the tool. In your case you would execute "analyze" and "fixups" mode on the source system and wait for the changes to be applied on the standby. Then you break the connection and you can eventually do the upgrade using the "upgrade" mode. In your configuration file instead of specifying a "target_home" you should specify "target_version" instead.

Regards,

Daniel 

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 9 2017
Added on Apr 7 2017
12 comments
439 views