Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 No Lock

Author  Topic 

ugh3012
Yak Posting Veteran

62 Posts

Posted - 2013-07-17 : 10:12:43
Sometime I see nolock in some of the T-SQLs at work. Is that really necessary in terms of performance?


...
FROM TBl1
INNER JOIN TBL2 (nolock) on TBl1.id = TBl2.id

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-17 : 11:15:33
see

http://visakhm.blogspot.in/2010/02/avoiding-deadlocks-using-new.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

ugh3012
Yak Posting Veteran

62 Posts

Posted - 2013-07-17 : 11:44:46
This will be fine on our day old SQL Server. Everynight, all information is copied to day old server from production server. That serves as our reporting tool.

Once again, thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-07-17 : 11:56:23
Welcome
If data is rather non-volatile then NOLOCK usage is fine as in OLAP systems

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2013-07-17 : 15:53:44
If data is non-volatile then you don't get any benefit to using NOLOCK anyway.
Personally I'd steer clear of it so you don't get into the habit of using it. It's just a bad practice.
Go to Top of Page

mfemenel
Professor Frink

1421 Posts

Posted - 2013-07-17 : 16:10:44
While there are some valid cases, more often then not, when I see nolock I think that the developers got themselves into trouble and started having to resort to query hints to keep from shooting themselves in the foot.

Mike
"oh, that monkey is going to pay"
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2013-07-17 : 18:18:53
I guess for approximate counts and stuff like that, perhaps it's acceptable but generally they can generally wait on the odd lock as well.

You'd have to have a pretty big hole in your foot before you get to the "This is so broken I will accept incorrect data over what I have now" stage!
Go to Top of Page
   

- Advertisement -