Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS SQL Specific Tables Hanging at Queries

I have SQL Server 2008. I run a query in a table on a database. The weirdest thing keeps happening. I run a simple select statement on the table. I know there are 62 rows in the table but it gets stuck at row 48 and goes on "querying...". Waited already for hours and it didn't move on from there. I only know of two programs, and one reporting service connecting to that particular table and one other user. Does anyone have any idea on what could be causing this and how I could trace the source of the lock on that table?

As a side note, I noted that the logs only had a notice that Autogrow failed the day before I checked. Could this have something to do with it?

like image 681
Jonn Avatar asked Jun 01 '10 09:06

Jonn


People also ask

What causes long running queries in SQL Server?

Queries or updates that take longer than expected to execute can be caused by a variety of reasons. Slow-running queries can be caused by performance problems related to your network or the computer where SQL Server is running. Slow-running queries can also be caused by problems with your physical database design.

What is SQL blocking?

As mentioned previously, in SQL Server, blocking occurs when one session holds a lock on a specific resource and a second SPID attempts to acquire a conflicting lock type on the same resource. Typically, the time frame for which the first SPID locks the resource is small.


1 Answers

What if you do a

SELECT * FROM YourTable WITH(NOLOCK)

Does it still hang?

Additionally when it does appear to be blocked you can try running

exec sp_who2

And looking in the BlkBy column to see what process is blocking you.

If that doesn't shed any light this article gives some info on some DMVs that might help get some insight into reasons for waits.

like image 66
Martin Smith Avatar answered Nov 01 '22 10:11

Martin Smith