WITH NOLOCK = dirty rotten scoundrels

Posted on Wednesday, August 12, 2009 by Nicki

A comment by a presenter at a SQL Server tuning session at TechEd Africa 2009 sparked my interest, so I decided to investigate.


Do you use WITH (NOLOCK) with each SELECT statement? Do you know what it does?

Let me fill you in. It allows your query to read uncommitted data, i.e. deleted or inserted rows that might still be rolled back. Even worse is that it can double read rows, or even misread rows. Imagine the impact it might have on financial systems...

This might be ok in a data warehouse environment (when the data is not being updated), but certainly is not ok in a transactional database.

If you still need convincing not to to it, look here.

0 Responses to "WITH NOLOCK = dirty rotten scoundrels":