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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• dbcc shrinkdatabase / shrinkfile<br />

• dbcc indexdefrag / alter index reorganize<br />

• transaction rollbacks.<br />

Chapter 2: Connections, Sessions and Requests<br />

• cpu_time – the total amount of processing time spent on this request<br />

(in milliseconds)<br />

• row_count – the number of rows that were processed for the request<br />

• granted_query_memory – number of pages allocated to the execution of the<br />

request; since this metric is measured in 8 KB pages, you'll need to convert accordingly;<br />

I tend to want to review my metrics in MB, therefore I perform the following<br />

conversion from pages to MB: MB = (Number of 8 KB Pages)/1024 * 8<br />

• reads – total physical disk reads performed for this request<br />

• writes – total physical writes performed for this request<br />

• logical_reads – total number of reads from the data cache for this request.<br />

Overview of sys.dm_exec_sql_text<br />

Having retrieved the sql_handle from the sys.dm_exec_requests DMV (or any<br />

other DMV that exposes it), we can then provide it as a parameter into the sys.dm_<br />

exec_sql_text function, in order to retrieve the <strong>SQL</strong> text for a given batch/procedure.<br />

The sys.dm_exec_sql_text table-valued function returns two columns that are only<br />

interesting if the sql_handle refers to an object, such as a stored procedure, rather than<br />

ad hoc <strong>SQL</strong> statements:<br />

• dbid – the identifier (or surrogate key) for the database, if applicable; (note that this is<br />

usually database_id in other objects)<br />

57

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

Saved successfully!

Ooh no, something went wrong!