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.

WHERE scheduler_id < 255<br />

AND runnable_tasks_count > 0<br />

-- AND pending_disk_io_count > 0<br />

Listing 7.17: Investigating potential disk I/O or CPU pressure.<br />

Insufficient threads<br />

297<br />

Chapter 7: OS and Hardware Interaction<br />

If the system isn't experiencing CPU pressure, is not I/O bound, and there aren't<br />

too many other types of waits on the system, then you may need to investigate<br />

the possibility that there are simply too few threads available to the server. The<br />

query in Listing 7.18 comes courtesy of Slava Oks (http://blogs.msdn.com/slavao/<br />

archive/2006/09/28/776437.aspx) and investigates the possible need to adjust the server<br />

threads system configuration, by checking the average value of work_queue_count.<br />

In the absence of CPU pressure, values of more than one for the average of the work_<br />

queue_count column can mean that you need to increase the number of threads<br />

allowable to the server.<br />

SELECT AVG(work_queue_count)<br />

FROM sys.dm_os_schedulers<br />

WHERE status = 'VISIBLE ONLINE'<br />

Listing 7.18: Are there sufficient worker threads for the workload?<br />

Context switching<br />

Context switching occurs when a process fails to complete in a reasonable time, and<br />

the process has to give up control of the scheduler (again, representing a CPU) to let<br />

another process complete. <strong>SQL</strong> <strong>Server</strong> generally operates in a non-preemptive mode,<br />

where threads voluntarily give up access to the CPU at the appropriate moment. Some<br />

operations, however, such as calling an extended stored procedure, distributed query,<br />

and so on, cause the scheduler to preempt a context switch. A high number of context

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

Saved successfully!

Ooh no, something went wrong!