Sqlserver-dba.com

SQL Server query plans in cache

 If you want to view the objects within the cache  use the query below. This  will give you an  insight into how optimizer and storage engine reached the plan.

 

SELECT [qpc].[refcounts]

, [qpc].[usecounts]

, [qpc].[objtype]

, [st].[dbid]

, [stx].[objectid]

, [stx].[text]

, [qpl].[query_plan]

FROM sys.dm_exec_cached_plans qpc

CROSS APPLY sys.dm_exec_sql_text ( cp.plan_handle ) stx

CROSS APPLY sys.dm_exec_query_plan ( cp.plan_handle ) qpl ;

Key Column meanings:

[qpc].[refcounts] = Number of cached objects referencing the object

[qpc].[usecounts] = Times used since started

[qpl].[query_plan] = compile-time Showplan

Author: Jack Vamvas (http://www.sqlserver-dba.com)

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact