0

When deleting a row by its PrimaryKey from a table, I get about 44472 logical reads. Now the table has 5-6 child tables that link their ForeignKeys to the PK of the table I want to delete from.

I'm not sure what to do to improve the performance of the delete.

Any suggestions ?

Edit : I added the queryplan for the delete

http://img384.imageshack.us/img384/6255/deleteexecutionplan.png

Edit : I found a solution (not sure if it's the ideal solution)- it's in the response bellow.

sirrocco
  • 7,975
  • 4
  • 59
  • 81
  • That execution plan shows a table scan on OrderDetails, and on two other small tables. Do you have a self-referencing FK on that table, and is the FK in that case on a non-indexed column? If you share the schema for the table and the related tables along with the actual execution plan (in .xml format) it will be easier to say exactly what is the cause... – KristoferA Oct 15 '09 at 10:49

3 Answers3

0

Look at the query plan for the single row delete.

I think you will find that a table scan is being done on one or more of the "child" tables. If so consider putting an index on the ForeignKey in on that child table(s).

(Otherwise please add the query plan to your question)

Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
0

Do you have FK constraints?

The options I can think of are

  • Add indexes to the FK columns in the child tables.
  • Remove the constraint (which would risk having orphaned rows).
  • Try reducing the number of child tables.
Jeremy French
  • 11,707
  • 6
  • 46
  • 71
0

This answer solved the problem, now deletes work like a charm. I'm not sure if there are any downsides I should be aware of.

Community
  • 1
  • 1
sirrocco
  • 7,975
  • 4
  • 59
  • 81