I get that the (nolock) optimizer hint allows for “dirty reads”, but under what very specific scenarios is this a bad idea? I’ve never seen such widespread use of (nolock) in an organization, and it makes me nervous. I’d like an explanation in terms of user stories. “Paul does A, Peter does B, X happens instead of Y”.
I get that the (nolock) optimizer hint allows for dirty reads, but under what
Share
Reposting this answer:
NOLOCKmeans placing no locks at all.Your query may returns portions of data as of before
UPDATEand portions as of afterUPDATEin a single query.Like, a debit without a credit and these kinds of stuff.
For instance, I just ran this query on a large table:
All
name‘s have length of1.Then I reran it and in the middle of the query updated the table:
As we can see, this query noticed
577rows as updated (length2), all other rows as not updated (length1).And this query, run right after the previous one finished, sees all updates.