I am attempting to delete rows from a set of 5 tables. Their relationships are:
Table 3,4,5 reference Table 2;
Table 2 references Table 1;
Even though I have ON DELETE CASCADE set, it seems to take forever to delete rows in the parent table Table 1. So I am thinking about deleting the corresponding rows in Table 3,4,5 and then Table 2. They all seem to be OK. But when I tried to delete the rows from Table 1, it takes "forever". I suspect even though I've deleted all the Table 2 rows that may reference the rows to be deleted in Table 1, it still checks for Table 2 for any rows that may reference Table 1. In this case, obviously no rows left in Table 2 to be deleted as a result of cascade deletion. Does that mean I have to disable the referential constraint so it won't check Table 2 when I delete rows from Table 1?
Better yet, is there a better way to delete rows in a parent table when ON DELETE CASCADE is on?
Better thing wud be to disable the key nad delete from table1...
delete the records in table2 where referencing key not in table1's refernce key...
so goes for table3,4,5.
"I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."
"Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"
your fk columns are indexed, aren't they?
Click Here to Expand Forum to Full Width