Thursday, August 30, 2012

Avoiding NOLOCK

Here’s an interesting article (http://www.jasonstrate.com/2012/06/the-side-effect-of-nolock/) on the affects of using the NOLOCK hint in your SQL queries and how even data not being directly affected by an update can be messed up in your query.

I’ve always tried to avoid using it but have to admit to being a bit more liberal about it recently to solve some sticky deadlocking issues.  Those places where it’s being used could happily show bad data and not have any real affects, but it’s easy to see where they could, especially where aggregates are being calculated.  I’ve also not yet made the jump to snapshot isolation as that presents it’s own set of issues but will be looking into it more in the future.