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 2: Connections, Sessions and Requests<br />

expensive queries to the sessions, connections and users that own them. All of this is<br />

accomplished via the following DMOs, which belong to the "Execution-related" category<br />

of objects, and therefore all start <strong>with</strong> sys.dm_exec_.<br />

• sys.dm_exec_connections – provides information about network traffic and<br />

protocols, as well as user attributes from the calling source of the connection.<br />

Additional details are available from Microsoft Books Online: http://msdn.microsoft.com/en-us/library/foo6bd46fe1-417d-452d-a9e6-5375ee8690d8.aspx.<br />

• sys.dm_exec_sessions – returns information about each user and internal system<br />

session on a <strong>SQL</strong> <strong>Server</strong> instance including session settings, security, and cumulative<br />

CPU, memory, and I/O usage. More on this DMV is available from Microsoft Books<br />

Online: http://msdn.microsoft.com/en-us/library/ms176013.aspx.<br />

• sys.dm_exec_requests – provides a range of query execution statistics, such<br />

as elapsed time, wait time, CPU time, and so on. It returns one row for every query<br />

currently executing. More information about this DMV is available in the following<br />

Microsoft KB: http://technet.microsoft.com/en-us/library/ms177648(<strong>SQL</strong>.90).<br />

aspx.<br />

• sys.dm_exec_sql_text – returns the text of the <strong>SQL</strong> batch identified by a<br />

sql_handle; see http://msdn.microsoft.com/en-us/library/ms181929.aspx.<br />

• sys.dm_exec_query_plan – returns, in XML format, the query plan, identified by a<br />

plan_handle, for a <strong>SQL</strong> batch (this DMO is covered in more detail in Chapter 3).<br />

Of course, the journey does not end there. In Chapter 3, we'll delve deeper into query<br />

execution and, in particular, into the execution plans that <strong>SQL</strong> <strong>Server</strong> generates, stores<br />

and, hopefully, reuses, during this process. This allows a broader analysis of your query<br />

workload, from the point of view of what is in the plan cache, rather than just those<br />

queries that are executing right now. In Chapter 4, we'll step down to an even lower<br />

granularity, to look at the transactions that are initiated once a query is assigned a plan<br />

and sent on to the engine for processing. Transactions do (hopefully) complete and<br />

requests are fulfilled, yet the associated user can, and usually does, still maintain<br />

connectivity to the <strong>SQL</strong> <strong>Server</strong> instance.<br />

34

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

Saved successfully!

Ooh no, something went wrong!