DRAG DROP
You have a SQL Server 2014 database.
You plan to create a stored procedure that will retrieve the following information:
The XML content of the query plans that is stored in memory
The number of times each query plan is used
You need to identify which dynamic management objects must be used to retrieve the
required information for the stored procedure.
Which dynamic management objects should you identify?
To answer, drag the appropriate dynamic management object to the correct requirement in
the answer area.
Explanation:
Note:
* sys.dm_exec_query_plan
Returns the Showplan in XML format for the batch specified by the plan handle. The plan
specified by the plan handle can either be cached or currently executing.
* sys.dm_exec_cached_plans
Returns a row for each query plan that is cached by SQL Server for faster query execution.
You can use this dynamic management view to find cached query plans, cached query text,
the amount of memory taken by cached plans, and the reuse count of the cached plans.
For the number of times each query plan is used
I would choose sys.dm_exec_query_stats
column execution_count (bigint) returns
number of times that the plan has been executed since it was last compiled.
sys.dm_exec_cached_plans
usecounts (int) returns
number of times the cache object has been looked up
Agreed. Number of times plan is used: sys.dm_exec_query_stats
Hmmm, there’s no sys.dm_exec_query_stats in the options!! So, I’d go with sys.dm_exec_cached_plans.