Skip to Main Content

SQL & PL/SQL

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!

on delete cascade vs manual delete

913578Mar 12 2013 — edited Mar 12 2013
Hi,

I have two tables one is parent and other is child.

ORDER_PRNT (Order_id (pk), Order_desc, create_date);

ORDER_CHILD (Order_id (fk), item)

this is just sample tables and columns as i cannot put actual table names here.

two talbles are containing huge data, i have to delete records older than 10 days daily. so i am doing this operations:

1. delete from child table first:

DELETE FROM ORDER_CHILD where Order_id in (select order_id from ORDER_PRNT where create_Date<sysdate-10);

2. delete from parent table :

DELETE FROM ORDER_PRNT where create_Date<sysdate-10;

The question is regarding better performance. If we can put "on delete cascade" condition for FK then i need not to write 1st delete statement right?
So oracle will automatically deletes the records of child whenever parent record is deleted.

So tell me which one is faster here?

shall i put ondelete cascade to FK ?
or
Manually delete from child table ?


Please suggest.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2013
Added on Mar 12 2013
2 comments
840 views