Report Offensive Message

NoLock reads dirty
so you get all the data but it's state could be undefined.

READPAST skips locked records so any uncommitted records will not be in the result set.

Risk of what is is the question that needs to be answered.


If you were say returning all the orders created today, at the time there was an uncommitted transaction on one of them.
READPAST would skip it, NOLOCK, you might get one that was going to be deleted, one that was have its date_created chnage to yesterday, one that was about to be rolled back.
No of you were just using that list to give a say dashboard value, number of orders and total value today, once every five minutes, big deal..
If you were going to do and end of period report, or use the order key in somethng that couldn't cope with it not existing, but you still didn't want it to block, then READPAST is a better choice.

Risk is down to how you use the data, not inherrent to the hint.
Posted by Tony Hopkinson
Updated - 27th Dec 2010