Using T-SQL Query to fetch data for the SQL Server worker threads

--We can use the sys.dm_os_schedulers dynamic management view to check the current value for the maximum worker threads. 

DECLARE @max INT;

SELECT @max = max_workers_count

FROM sys.dm_os_sys_info;

SELECT GETDATE() AS 'CurrentDate', 

       @max AS 'TotalThreads', 

       SUM(active_Workers_count) AS 'CurrentThreads', 

       @max - SUM(active_Workers_count) AS 'AvailableThreads', 

       SUM(runnable_tasks_count) AS 'WorkersWaitingForCpu', 

       SUM(work_queue_count) AS 'RequestWaitingForThreads', 

       SUM(current_workers_count) AS 'AssociatedWorkers'

FROM sys.dm_os_Schedulers

WHERE STATUS = 'VISIBLE ONLINE';

No comments:

Post a Comment