Pro Programmer: What is NOLOCK?

Wednesday, August 15, 2012

What is NOLOCK?

The NOLOCK query optimizer hint is generally considered good practice in order to improve concurrency on a busy system. When the NOLOCK hint is included in a Select Statement no locks are taken when data is read. Of course then the result of that would be a dirty read, which means that another process could be updating the data at the exact same time you are reading it. The advantage to performance is that, you reading the data will not block updates from taking place and the updates will not block you from reading the data. Also, select statements take Shared (Read) lock which  means that multiple select statements are allowed simultaneous access, but other processes are blocked from modifying the data.

No comments:

Post a Comment