<p><strong>Edit</strong>: Solved, there was a trigger with a loop on the table (read my own answer further below).</p>

<hr>

<p>We have a simple delete statement that looks like this:</p>

<pre><code>DELETE FROM tablename WHERE pk = 12345
</code></pre>

<p>This just hangs, no timeout, no nothing.</p>

<p>We've looked at the execution plan, and it consists of many lookups on related tables to ensure no foreign keys would trip up the delete, but we've verified that none of those other tables have any rows referring to that particular row.</p>

<p>There is no other user connected to the database at this time.</p>

<p>We've run DBCC CHECKDB against it, and it reports 0 errors.</p>

<p>Looking at the results of <em><code>sp_who</code></em> and <em><code>sp_lock</code></em> while the query is hanging, I notice that my spid has plenty of PAG and KEY locks, as well as the occasional TAB lock.</p>

<p>The table has 1.777.621 rows, and yes, pk is the primary key, so it's a single row delete based on index. There is no table scan in the execution plan, though I notice that it contains something that says <em>Table Spool (Eager Spool)</em>, but says Estimated number of rows 1. Can this actually be a table-scan in disguise? It only says it looks at the primary key column.</p>

<p>Tried DBCC DBREINDEX and UPDATE STATISTICS on the table. Both completed within reasonable time.</p>

<p>There is unfortunately a high number of indexes on this particular table. It is the core table in our system, with plenty of columns, and references, both outgoing and incoming. The exact number is 48 indexes + the primary key clustered index.</p>

<p>What else should we look at?</p>

<p>Note also that this table did not have this problem before, this problem occured suddently today. We also have many databases with the same table setup (copies of customer databases), and they behave as expected, it's just this one that is problematic.</p>

[{'answer_id': 56128, 'author': 'Ed Guiness', 'author_id': 4200, 'author_profile': 'https://Stackoverflow.com/users/4200', 'pm_score': 2, 'selected': False, 'text': '<p>Try recreating the index on that table, and try regenerating the statistics.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/aa258828(SQL.80).aspx" rel="nofollow noreferrer">DBCC REINDEX</a><br/></p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/aa260645(SQL.80).aspx" rel="nofollow noreferrer">UPDATE STATISTICS</a></p>\n'}, {'answer_id': 56163, 'author': 'Josef', 'author_id': 5581, 'author_profile': 'https://Stackoverflow.com/users/5581', 'pm_score': 4, 'selected': True, 'text': "<p>One piece of information missing is the number of indices on the table you are deleting the data from. As SQL Server uses the Primary Key as a pointer in every index, any change to the primary index requires updating every index. Though, unless we are talking a high number, this shouldn't be an issue.</p>\n\n<p>I am guessing, from your description, that this is a primary table in the database, referenced by many other tables in FK relationships.  This would account for the large number of locks as it checks the rest of the tables for references. And, if you have cascading deletes turned on, this could lead to a delete in table a requiring checks several tables deep.</p>\n"}, {'answer_id': 56437, 'author': 'Lasse V. Karlsen', 'author_id': 267, 'author_profile': 'https://Stackoverflow.com/users/267', 'pm_score': 1, 'selected': False, 'text': "<p>Ok, this is embarrasing.</p>\n\n<p>A collegue had added a trigger to that table a while ago, and the trigger had a bug. Although he had fixed the bug, the trigger had never been recreated for that table.</p>\n\n<p>So the server was actually doing nothing, it just did it a huge number of times.</p>\n\n<p>Oh well...</p>\n\n<p>Thanks for the eyeballs to everyone who read this and pondered the problem.</p>\n\n<p>I'm going to accept Josef's answer, as his was the closest, and indirectly thouched upon the issue with the cascading deletes.</p>\n"}]
['https://Stackoverflow.com/questions/56070', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/267/']