30.06.2013 Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

313<br />

Chapter 7: OS and Hardware Interaction<br />

active your cache is for <strong>SQL</strong> plans, we can filter on type, either CACHESTORE_<strong>SQL</strong>CP or<br />

CACHESTORE_OBJCP, as shown in Listing 7.28.<br />

SELECT name ,<br />

type ,<br />

entries_count ,<br />

entries_in_use_count<br />

FROM sys.dm_os_memory_cache_counters<br />

WHERE type IN ( 'CACHESTORE_<strong>SQL</strong>CP', 'CACHESTORE_OBJCP' )<br />

--ad hoc plans and object plans<br />

ORDER BY name ,<br />

type<br />

Listing 7.28: Investigating the use of the plan cache.<br />

On my test laptop, this returns the following output:<br />

name type entries_count entries_in_use_count<br />

-------------- ------------------ -------------------- --------------------<br />

Object Plans CACHESTORE_OBJCP 22 0<br />

<strong>SQL</strong> Plans CACHESTORE_<strong>SQL</strong>CP 44 2<br />

We can run some ad hoc <strong>SQL</strong>, such as select *from sys.objects, and then rerun<br />

Listing 7.18, in order to see a new entry added to the <strong>SQL</strong> Plans cache:<br />

name type entries_count entries_in_use_count<br />

-------------- -------------------- -------------------- --------------------<br />

Object Plans CACHESTORE_OBJCP 22 0<br />

<strong>SQL</strong> Plans CACHESTORE_<strong>SQL</strong>CP 46 7<br />

Notice that the entries_count for <strong>SQL</strong> Plans has increased by two, one for the<br />

counters query, and one for the ad hoc <strong>SQL</strong> (it might increase more due to other background<br />

processes) but the use count was not incremented. This, of course, is because the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!