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?
Click Here to Expand Forum to Full Width