I've found a Query which supposedely should determine how much CPU is being used by SQL queries, system idle and other processes. This is the Query:
DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks)FROM sys.dm_os_sys_info); SELECT TOP(30) SQLProcessUtilization AS [SQL Server Process CPU Utilization], SystemIdle AS [System Idle Process], 100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization], DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS [Event Time] FROM ( SELECT record.value('(./Record/@id)', 'int') AS record_id, record.value('(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)', 'int') AS [SystemIdle], record.value('(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)', 'int') AS [SQLProcessUtilization], [timestamp] FROM ( SELECT [timestamp], CONVERT(xml, record) AS [record] FROM sys.dm_os_ring_buffers WHERE ring_buffer_type = N'RING_BUFFER_SCHEDULER_MONITOR' AND record LIKE '%<SystemHealth>%') AS x ) AS y where SystemIdle >= 80 ORDER BY record_id DESC;
This shows that the CPU under the column
SQL Server Process CPU Utilization is rather stable at around
When I'm checking the process task at the server, however, I can see that the CPU usage is very high at
90-100% from time to time. When I check what processes are using the most CPU in the task manager, I can conclude that
sqlservr.exe uses much more CPU than the other processes (
In fact, there are more than one sqlservr.exe present.
My question is, really, how can the SQL queries use Little CPU, while sqlservr.exe uses very much?
I have some queries running in the background, by for instance using SQL jobs, but these should be captured in the CPU Query.