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 7: OS and Hardware Interaction<br />

DBCC <strong>SQL</strong>PERF ('sys.dm_os_wait_stats', CLEAR);<br />

Listing 7.1: Resetting the wait statistics.<br />

If your <strong>SQL</strong> <strong>Server</strong> instance has been running for quite a while and you make a significant<br />

change, such as adding an important new index, you might consider clearing the old wait<br />

stats in order to prevent the old cumulative wait stats masking the impact of your change<br />

on the wait times.<br />

The following columns are available in the view (times are all in millisecond units):<br />

• wait_type – the type of wait<br />

• waiting_tasks_count – the cumulative total number of waits that have occurred<br />

for the given wait_type<br />

• wait_time_ms – total amount of time that tasks have waited on this given wait type;<br />

this value includes the time in the signal_wait_time_ms column<br />

• max_wait_time_ms – the maximum amount of time that a task has been delayed, for<br />

a wait of this type<br />

• signal_wait_time_ms – the total amount of time tasks took to start executing after<br />

being signaled; this is time spent on the runnable queue, and is pure CPU wait.<br />

There are many reasons why a certain task <strong>with</strong>in <strong>SQL</strong> <strong>Server</strong> may need to wait before<br />

proceeding, which means there are many possible values for the wait_type column.<br />

Some are quite usual, such as the need to wait for a lock to be released before it can<br />

access the required resource (e.g. a data page), and these are indicated by the "normal"<br />

lock modes such as shared, intent, exclusive, and so on (see Chapter 4, Transactions,<br />

for more detail). Other common causes of waits include latches, backups, external<br />

operations like extended stored procedure execution, replication, resource semaphores<br />

(used for memory access synchronization), and many more. There are too many to<br />

cover them all in detail, though most of the wait types are at least listed, if not well<br />

documented, in Books Online.<br />

266

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

Saved successfully!

Ooh no, something went wrong!