I have a table with more than 20 million rows, and when i do:
DELETE [Table] WHERE ID = ?
It takes over 40 seconds. The ID column is clustered.
Is this what you could expect? or is it possible to optimize this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In addition to the fine points JNK included in their answer, one particular killer I’ve seen is when you’re deleting rows from the referenced table for one or more foreign key constraints, and the referencing column(s) in the referencing table(s) aren’t indexed – you’re forcing a table scan on each of those tables to occur before the delete can be accepted.