WITH (NOLOCK) clause

  • A long time ago, I read that so long as your code/application doesn't mind, you can use the WITH(NOLOCK) hint to speed up your queries, because the query analyser will obviously ignore the locking status of rows and tables, and just return your results.

    However, this all seems a bit subjective - does the forum have any comments on this clause, especially if the behaviour has changed between 7 and 2000?

    Thanks

    Simon

    UK

  • I don't believe it hasn't changed. This code is great if nothing is being updated or inserted in the database. The big problem is this from BOL

    quote:


    Dirty reads are possible.


    Meaning data that has not been committed can be produced in your resultset. So say an account is having a money transaction and you use NOLOCK and you report the amount with the uncommitted data to the customer, say this is their paycheck and for some reason the insert fails and rollsback. If your customer finds a day later they wrote their house payment expecting the money to be there and now it obounced (which a bad check over 500 believe in the US is a felony), they won't stay with your bank long. Just consider does uncommitted records worry you about your results or are not of concern.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply