I have statements like this that are timing out:
DELETE FROM [table] WHERE [COL] IN ( \'1\', \'2\', \'6\', \'12\', \'24\', \'7\', \'3\', \'5\')
Preventive Action
Check with the help of SQL Profiler
for the root cause of this issue. There may be Triggers
causing the delay in Execution. It can be anything. Don't forget to Select the Database Name
and Object Name
while Starting the Trace
to exclude scanning unnecessary queries...
Database Name Filtering
Table/Stored Procedure/Trigger Name Filtering
Corrective Action
As you said your table contains 260,000 records...and IN Predicate
contains six values. Now, each record is being search 260,000 times for each value in IN Predicate
. Instead it should be the Inner Join like below...
Delete K From YourTable1 K
Inner Join YourTable2 T on T.id = K.id
Insert the IN Predicate
values into a Temporary Table
or Local Variable