sys.dm_os_schedulers - useful to find on whether your SQL Server engine is weakening!

Published 17 August 07 06:04 AM | SQL Master 

The system DMV sys.dm_os_schedulers is an useful DMV to find such as running tasks & active workers threads etc. This is required to monitor the system state is heavily loaded or not, in particular this view will help you identify if there is any CPU bottleneck in the SQL Server machine.

SELECT 
scheduler_id,current_tasks_count,runnable_tasks_count 
FROM sys.dm_os_schedulers 
WHERE scheduler_id < 255

By looking at the results of above query, the number of runnable tasks is generally a nonzero value; a nonzero value indicates that tasks have to wait for their time slice to run. If the runnable task counts show high values then there is a symptom of CPU bottleneck. The above query will also lists all the available schedulers in the SQL Server machine and the number of runnable tasks for each scheduler. 

It is universal truth that having more CPUs (OS & SQL edition compatible) is always advantage in gaining performance (not always though, for the sake of theory assume query is normalized). But how to find whether your SQL Server application database is performing and it may need more CPUs or IO disks to keep up the optimum performance over a period of time. As always the SQL Server systemBy using above DMV (sys.dm_os_schedulers) you can obtain such information (as referred in Slava Oka's blog) :

select AVG (runnable_tasks_count) from sys.dm_os_schedulers where status = 'VISIBLE ONLINE'

Using above TSQL if you get the result greater than 0 (numbers >0) then it means your SQL System is waiting for CPU time to finish that particupar process.

select pending_disk_io_count from sys.dm_os_schedulers

Using above TSQL if you get result greater than 0 (numbers >0) then it means the system is bound by IO, you need to get disks to perform better. BOL explains better on this value:

Number of pending I/Os that are waiting to be completed. Each scheduler has a list of pending I/Os that are checked to determine whether they have been completed every time there is a context switch. The count is incremented when the request is inserted. This count is decremented when the request is completed. This number does not indicate the state of the I/Os. Is not nullable.

 

Comments

# SSQA.net - SqlServer-QA.net said on August 17, 2007 7:06 AM:

The system DMV sys.dm_os_schedulers is an useful DMV to find such as running tasks &amp; active workers

# Other SQL Server Blogs around the Web said on August 17, 2007 7:14 AM:

The system DMV sys.dm_os_schedulers is an useful DMV to find such as running tasks &amp; active workers

# SQL Server Security, Performance & Tuning (SSQA.net) said on September 20, 2007 9:07 AM:

Here comes another Frequently Asked Question (FAQ) on the forums and Frequently Posted Blog (FPB) here

Anonymous comments are disabled

About SQL Master

**__________________________________** SQL Server MVP, Sr. DBA & industry expert. - Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.