SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Can we list cached data by key?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

denis_the_thief
Aged Yak Warrior

Canada
591 Posts

Posted - 10/31/2013 :  11:27:46  Show Profile  Reply with Quote
I was wondered if there is a query that we can see which values are in the cache (i.e. buffer pool) by key value?

I know that we can run this:
DBCC IND(DatabaseName, TableName, -1)
GO

Then we can pick a PagePID, and run this:

DBCC TRACEON(3604)
DBCC PAGE(DatabaseName, 1, PagePID, 3) WITH TABLERESULTS
GO

But I was hoping this could be run in one query to list, to list all values of the Primary Key that are in the cache, showing:

Table, PageID, PKColumn, Value

Is there a query that can do this?

robvolk
Most Valuable Yak

USA
15665 Posts

Posted - 10/31/2013 :  20:08:10  Show Profile  Visit robvolk's Homepage  Reply with Quote
Interesting problem, but I'm not sure I see what you could do with that information.

It will probably be simpler to query sys.dm_os_buffer_descriptors, that will show you which pages are actually cached. You can then join that to sys.allocation_units and then to sys.partitions to link up to an object_id. Linking those to actual keys is another step I don't know how to do, except to use this:

http://www.sqlskills.com/blogs/paul/sql-server-2008-new-undocumented-physical-row-locator-function/

The main problem is that querying this info will affect the data that's in cache and probably moot whatever you're trying to determine. DBCC PAGE may do the same (according to my tests anyway), as it would buffer its results.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000