Skip to Main Content
  • Questions
  • Deletion from a atble having millions of records

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Anupama.

Asked: November 03, 2016 - 3:43 pm UTC

Last updated: November 04, 2016 - 4:45 am UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi Tom,

I have a table having 115 columns and 25 foreign key constraints having millions of records. I am running a deletion script from the table based on one field in that table. An index is created for the same field and also the table is non-partitioned. For deleting 3372960 records from the same table, the process is completing with 5 hours 15 minutes. But for the other tables having nearly the same count of records is deleting within seconds. But those tables have only less number of columns and constraints. Please advice how can I proceed with the deletion.

Regards,
Anupama

and Connor said...

If the deletion takes places whilst applications are using it (and hence you need to keep the indexes/constraints activated), then your options are limited. You could look at dbms_parallel_execute to run the task in parallel chunks.

If the deletion can be done with the application offline, then you would consider disabling the constraints, setting the indexes unusable, and then doing the delete (or using a CTAS).

But often the solution here is more about design - for example, perhaps a view that simply "hides" the rows from display is sufficient for the appearance of "deletion"

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

DBMS_PARALLEL_EXECUTE

More on PL/SQL routine DBMS_PARALLEL_EXECUTE here