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.

Chapter 3: Query Plan Metadata<br />

However, other attributes are important, too, the values for which are stored in the sys.<br />

dm_exec_plan_attributes function, described by Books Online as follows:<br />

Returns one row per plan attribute for the plan specified by the plan handle. You can use this table-valued<br />

function to get details about a particular plan, such as the cache key values or the number of current<br />

simultaneous executions of the plan.<br />

Like sys.dm_exec_query_plan, sys.dm_exec_plan_attributes takes a<br />

plan_handle as a parameter and returns the following columns:<br />

• attribute – name of the attribute<br />

• value – the current value assigned to the attribute<br />

• is_cache_key – indicates if the attribute is part of how <strong>SQL</strong> <strong>Server</strong> resolves the plan;<br />

A value of 1 indicates that it is, and 0 that it is not.<br />

This DMV returns one row per plan attribute, and available attributes include:<br />

• set_options – the options values (the ones that can be found using @@options,<br />

such as SET NOCOUNT) that were in use when the plan was built<br />

• date_format – the date format of the connection that created the plan<br />

• inuse_exec_context – the number of currently executing batches that are<br />

using the plan.<br />

If the value of is_cache_key is 1 for a given attribute, that attribute forms part of the<br />

"key" that is used when <strong>SQL</strong> <strong>Server</strong> searches the cache for a suitable plan. During the<br />

process of checking the cache for a match, the text of a submitted query is compared to<br />

the text of other queries that have been executed and for which a plan is stored. Even if<br />

the text of the queries matches exactly, the submitted query's attributes would also need<br />

to match exactly those for the cached plan, for every attribute <strong>with</strong> a value of 1 for the<br />

is_cache_key column in sys.dm_exec_plan_attributes.<br />

98

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

Saved successfully!

Ooh no, something went wrong!