Skip to content
Advertisement

Oracle cascade delete

Is cascade delete on a table more efficient than individual delete statements (executed in a single plsql block) ?

Advertisement

Answer

What cascade delete does is issue individual delete statements.

Examine the following test case:

In the trace file, you will find a line like this:

That is Oracle issuing a delete statement against CHILD for each record it’s deleting in PARENT.

A different question would be which of the two are more efficient:

vs

both with on delete cascade enabled. Suprisingly enough, in the first case above, Oracle will probe the foreign key index on the child table to see if any rows exist which would require a cascade. If no rows exist, Oracle does not execute the cascaded delete.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement