SQL Server with Mr. Denny

Jan 23 2013   9:00AM GMT

NOLOCK is not a turbo button

Denny Cherry Denny Cherry Profile: Denny Cherry

All to often when talking to developers they put the WITH (NOLOCK) table hint in place to speed up queries without understanding what the table hint does.  I’ve even run across companies that have policies in place that every select statement must have the WITH (NOLOCK) table hint.

The WITH (NOLOCK) table hint isn’t a go faster button for SQL Server.  It has actual implications to the data which is being returned by the query.  The biggest of these implications is that the data might not be correct.  You see the WITH (NOLOCK) table hint uses dirty reads to return the data, so it basically ignores the locks which other queries have taken.  This is why the query appears to run faster, because the query isn’t being blocked any more.  The proper approach would be to find the query which is causing the extended blocking and figure out why it is taking so long to run, and fix the performance problems of that query.

The only go faster button that is available in SQL Server is the CREATE INDEX statement.  Anything else isn’t truly a go faster button, and has other side effects which must be understood before being implemented.


1  Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.
  • CodyK
    Great post! I'm making it company policy to have indexes on every column now, thanks.

    (Just kidding)
    10 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: