Hi,
I have a table (ParentVal) with four child tables (ParentValA, ParentValB, ParentValC, ParentValD) each with foreign key constraints.
ParentVal has 15000 records
ParentValA has 1000000 records
ParentValB has 2000000 records
ParentValC has 15000000 records
ParentValD has 30000000 records
If I attempt to delete a record from ParentVal, which has no associated records in the child table, it takes 45 seconds, which is unacceptable. Exec plan shows clustered index scans on the child tables and clustered index seek on the ParentVal table.
If I disable the fk constraints on the child tables to the parent, the same delete takes less than a second but I don't want to disable foreign keys!
Can anyone offer a suggestion as to how I should proceed?
Thanks in advance!
-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook
I have a table (ParentVal) with four child tables (ParentValA, ParentValB, ParentValC, ParentValD) each with foreign key constraints.
ParentVal has 15000 records
ParentValA has 1000000 records
ParentValB has 2000000 records
ParentValC has 15000000 records
ParentValD has 30000000 records
If I attempt to delete a record from ParentVal, which has no associated records in the child table, it takes 45 seconds, which is unacceptable. Exec plan shows clustered index scans on the child tables and clustered index seek on the ParentVal table.
If I disable the fk constraints on the child tables to the parent, the same delete takes less than a second but I don't want to disable foreign keys!
Can anyone offer a suggestion as to how I should proceed?
Thanks in advance!
-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook