Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / December 2007

Tip: Looking for answers? Try searching our database.

Duration of shared locks held

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hassan - 28 Dec 2007 19:09 GMT
Say if i have a join on 2 tables : Table1 with 1 row and Table2 with 1
million rows and if I dont have an efficient index and my query has to scan
every page in Table2 hence acquiring shared locks on that table, the
question I have is , for the duration that it reads through every page on
Table2 in the join, will it also hold a shared lock on Table1 that may
possibly have only one page ?

Thanks
Mohit K. Gupta - 28 Dec 2007 19:25 GMT
Yes, because it has to read information from both tables.   If you are 100%
sure the data can be read without have affect on the dirty reads you can use
(nolock) hint to speed up the processes.  

When you are doing massive selects like that it will lock tables, and any
query that is being blocked will stay on hold until all locks are released
from the resource.
Signature

Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005

> Say if i have a join on 2 tables : Table1 with 1 row and Table2 with 1
> million rows and if I dont have an efficient index and my query has to scan
[quoted text clipped - 4 lines]
>
> Thanks
Dan Guzman - 29 Dec 2007 18:58 GMT
During a scan operation in the READ COMMITTED isolation level, locks are
acquired during the scan (page, key) and are released as soon as no longer
needed.  An intent shared lock is acquired at the table level to indicate
that a lower level shared lock exists.

You can run a Profiler trace of a particular query including lock
acquired/released to see the actual behavior.

Signature

Hope this helps.

Dan Guzman
SQL Server MVP

> Say if i have a join on 2 tables : Table1 with 1 row and Table2 with 1
> million rows and if I dont have an efficient index and my query has to
[quoted text clipped - 4 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.