What is purpose of using NOLOCK on a SELECT statement?

rstuppi picture rstuppi · Mar 8, 2013 · Viewed 37k times · Source

Can anyone suggest a good reason to issue a NOLOCK on a SELECT statement?

I am re-factoring some stored procedures that are littered with them and it is my understanding that a NOLOCK on a SELECT statement is all but useless.

Answer

Just Aguy picture Just Aguy · Mar 9, 2013

I see some bad info flying around already. WITH(NOLOCK) on a select is not a performance tool to be used wherever you need speed. Read this article it dumps on the answer provided by eSamuel because that IS what most people think, as you can see by the votes. People who don't know but regurgitate what they've heard as how it should be done. Learn to optimize your data and queries first. The NOLOCK hint should only be used in systems where you are consistently dealing with records being deadlocked or another issue that NOLOCK provides a solution for.

I work at a financial institution developing in an OLTP system which processes numerous transactions a minute and provides real-time reporting capabilities to clients and customers. These people perform reads on our fresh data all day long and if we don't do report queries using NOLOCK it's only a matter of time before a deadlock occurs.

Do your due diligence and read from reputable, professional sources before jumping on NOLOCK as the holy graile to SQL query speed because there's much more to it.