HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How do I clear a table from SQL Server's cache?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
howsqlcacheclearserverfromtable

Problem

I have a few tables in my database that should not be cached.

How do I tell SQL Server not to cache a table's pages or how do I flush a single table from the cache?

Flushing all the cache is not an option.

I'm using SQL Server 2008 and SQL Server 2008 R2.

Solution

There is no way of doing this.

DBCC DROPCLEANBUFFERS doesn't accept any parameters for a specific database or object. Internally SQL Server can do this at a database level however as when a database is AUTO_CLOSEd all corresponding pages are removed from the buffer cache.

Also internally SQL Server can mark certain pages such that they will be the first ones kicked out by the lazy writer. This is used by DMVs such as sys.dm_db_index_physical_stats to avoid flushing the buffer pool as alluded to in this article but this functionality is not exposed in any way to us (even though it might be useful to be able to specify the same if doing a one off scan of a large table for example).

Context

StackExchange Database Administrators Q#6417, answer score: 12

Revisions (0)

No revisions yet.