Wednesday, October 15, 2003

Ever wondered what is in your SQL Server's cache and how many times a cached item is used?
Check out the master..syscacheobjects table.

If you want to work with the database name just join the table with the sysdatabases.dbid field.

eg.

SELECT master..sysdatabases.name, master..syscacheobjects.objtype,
master..syscacheobjects.cacheobjtype, master..syscacheobjects.usecounts,
master..syscacheobjects.[sql] FROM master..syscacheobjects
INNER JOIN master..sysdatabases ON master..syscacheobjects.dbid = master..sysdatabases.dbid
WHERE sysdatabases.name = 'yourdbname'
GROUP BY master..syscacheobjects.objtype, master..sysdatabases.name, master..syscacheobjects.cacheobjtype, master..syscacheobjects.status, master..syscacheobjects.[sql], master..syscacheobjects.usecounts
ORDER BY master..syscacheobjects.usecounts DESC

No comments: