I have a database in SQL Server 2008 R2 where all tables seem to be functioning normally except for one table.
In this table, I can't delete a row or insert a row because it goes for over 30 min and times out.
My insert looks like this:
INSERT INTO [dbo].[brokenTable] ([Change], [Date], [ProdId], [IntCol])
VALUES ('test', getdate(), null, '99999')
However, I can select. Selecting top 200,000 takes 33 seconds. There are only ~260,000 rows in the table. There are five columns(one int primary key, one date, another int columns, and 2 varchar columns.)
This table used to work fine and be quick, I have made no structure changes at all.
Does anyone have any ideas why this might have happened, and how to fix it?
To people of the future who may have the same problem.
I thought the query was going very slow, this was not the case. It was being locked by another session. If you follow Martin Smith's comments, he helped me find which one to fix it.
First, I ran
select * from sys.dm_os_waiting_tasks
while running a query that would not finish, and again while not running it, to find a LCK_M_IX. I used the Session Id from that row, and matched it with the row from
select * from sys.dm_exec_sessions
and found the offending session that was blocking my query!
Since I knew this was a safe session to end, i ended it with
Kill [sessionId]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With