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.
Author |
Topic |
jrobin747
Starting Member
48 Posts |
Posted - 2013-08-12 : 12:57:48
|
What is the purpose of using WITH(NOLOCK)?My co worker told me to add it to my FROM |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-08-12 : 13:21:52
|
quote: Originally posted by jrobin747 What is the purpose of using WITH(NOLOCK)?My co worker told me to add it to my FROM
No lock query hint allows you to read dirty data from the database. By default SQL Server uses READ COMMITTED isolation. What that means is that the data that you read will be committed data. You would not read data that has been only partially committed, and hence possibly inconsistent and incorrect.Sometimes people use NOLOCK hints on readonly databases. The rationale being that there is no data modification going on, then there can be no dirty pages.Sometimes people use NOLOCK even on read/write databases under the notion that it cures all performance problems that they may encounter now or in the future. I wouldn't recommend it unless you don't really care about the correctness of your data.You can ask your co worker what his/her rationale for suggesting it is.Google for isolation levels and you will find lot of useful information. Here is one for example: http://www.sqlservercentral.com/blogs/vivekssqlnotes/2012/08/19/isolation-levels-in-sql-server/ |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|