What scenarios/settings will result in a query on SQL Server (2008) return stale data

Posted by s1mm0t on Stack Overflow See other posts from Stack Overflow or by s1mm0t
Published on 2010-05-22T20:28:59Z Indexed on 2010/05/22 20:40 UTC
Read the original article Hit count: 146

Filed under:
|
|

Most applications rarely need to display 100% accurate data. For example if this stack overflow question displays that there have been 0 views, when there have really been 10, it doesn't really matter. This is one way that the (perceived) performance of applications can be improved, by caching results and therefore sometimes not showing 100% accurate results.

There are some cases where the data does need to be 100% accurate though. So if I run the query

select * from Foo

I want to be sure that the results are not stale. Now depending on how my database is set up, other activity on the database, use of transactions and isolation levels etc this query may or may not be a true reflection of the world.

What scenario's and settings can people think of that will result in this query returning stale results or given that another connection is part way through a transaction that has updated this table, how can I guarantee that when the above query returns, the results will be accurate.

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server