Monday, May 5, 2008

Monitoring the SQL Plan Cache.

Something that isn't often monitored by DBA's but should be is the contents of the Procedure Cache. In SQL 2005, this can be done through the DMV's, and a lot of data is available for a DBA to analyze by querying a single DMV:

For each row returned, there is a plan_handle that will allow you to view the specific query that the plan exists for by using a CROSS APPLY of the following system function:


We can see some important information about the queries that are or are not being properly cached in the Procedure Cache by the database engine.  Microsoft has provided some scripts on the Scripts site that allow you to look at how efficiently your queries are functioning.

A problem which will be addressed in a later posting is cache bloat caused by the execution of adhoc, non-parameterized queries.

No comments:

Post a Comment