Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The use of NOLOCK
Message
From
17/02/2009 02:56:59
Walter Meester
HoogkarspelNetherlands
 
 
To
16/02/2009 19:10:04
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01382232
Message ID:
01382285
Views:
79
This message has been marked as a message which has helped to the initial question of the thread.
>On a specific SQL command, if I use NOLOCK, does this mean I can get innaccurate data up to several minutes ago, or worst? Or, is it just within some fractions of a second?

Michel,

In all likelyhood you're using automatic transactions currently, with no or little chance that an update, delete or insert is rejected.
In this situation the chance of NOLOCK returning records of transactions that are not completed is about zero.

The NOLOCK hint is one that is frequently overlooked. For statistical purposes there is seldom a reason not to use it. Unless you're trying to run a long lasting query in an mission critical OLTP environment it does not hurt to set it off. For most applications (such a disconnected web applications) it is not mission critical that a query ones in a few thousand queries might contain a record that was updated, deleted or inserted during the query execution. If the query is on a flat table (not querying on primarykeys - forreign keys relationship) it does not pose a problem either.

Only in certain situations where for example in a transaction the parent was deleted, but the child not yet or the parent was inserted but not all the childs yet, the query would return inaccurate results if executed when those transactions are executing in parrallel.

HTH,

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform