Unix Technical Forum

Problem with locking in Selects

This is a discussion on Problem with locking in Selects within the SQL Server forums, part of the Microsoft SQL Server category; --> I have a Stored Procedure that performs a simple SELECT. The Select have no locking hints or other hints ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:26 PM
bjornsuneandersen@gmail.com
 
Posts: n/a
Default Problem with locking in Selects

I have a Stored Procedure that performs a simple SELECT. The Select
have no locking hints or other hints and the database is set up in a
standard configuration.

The problem is that the SELECT runs for some time and while it is
running I can see (in the profiler) that other SPs with simple SELECTs
are held waiting until "my" SP has finished. The other SPs may be
other instances of the same SP as the one I'm running. All SPs
contains simple SELECTs and should only hold shared locks.

I have also checked if there are any locks holding the other SPs back
- there isn't any.

So my question is: What resouce can hold out other simple SELECTs in
this situation? Where should I look to identify the resource?


Regards

Bjørn

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:26 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Problem with locking in Selects

(bjornsuneandersen@gmail.com) writes:
> I have a Stored Procedure that performs a simple SELECT. The Select
> have no locking hints or other hints and the database is set up in a
> standard configuration.
>
> The problem is that the SELECT runs for some time and while it is
> running I can see (in the profiler) that other SPs with simple SELECTs
> are held waiting until "my" SP has finished. The other SPs may be
> other instances of the same SP as the one I'm running. All SPs
> contains simple SELECTs and should only hold shared locks.
>
> I have also checked if there are any locks holding the other SPs back
> - there isn't any.
>
> So my question is: What resouce can hold out other simple SELECTs in
> this situation? Where should I look to identify the resource?


I have written a stored procedure aba_lockinfo which is useful for
this sort of things. You find it at
http://www.sommarskog.se/sqlutil/aba_lockinfo.html

What you should look for is the value WAIT in the lstatus column. That is
what the blocked processes are waiting for.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:36 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com