Hi,
Our productions servers cpu was 100% utilized. I tried running few queries on it to see cpu consumption on it. But could not understand few of them esp first query in the list below:
1.DECLARE @ts_now bigint
SELECT @ts_now = cpu_ticks / (cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info
SELECT top 20 record_id, EventTime,
CASE WHEN system_cpu_utilization_post_sp2 IS NOT NULL THEN system_cpu_utilization_post_sp2 ELSE system_cpu_utilization_pre_sp2 END AS system_cpu_utilization,
CASE WHEN sql_cpu_utilization_post_sp2 IS NOT NULL THEN sql_cpu_utilization_post_sp2 ELSE sql_cpu_utilization_pre_sp2 END AS sql_cpu_utilization
FROM
(
SELECT
record.value('(Record/@id)[1]', 'int') AS record_id,
DATEADD (ms, -1 * (@ts_now - [timestamp]), GETDATE()) AS EventTime,
100-record.value('(Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS system_cpu_utilization_post_sp2,
record.value('(Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu_utilization_post_sp2 ,
100-record.value('(Record/SchedluerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS system_cpu_utilization_pre_sp2,
record.value('(Record/SchedluerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu_utilization_pre_sp2
FROM (
SELECT timestamp, CONVERT (xml, record) AS record
FROM sys.dm_os_ring_buffers
WHERE ring_buffer_type = 'RING_BUFFER_SCHEDULER_MONITOR'
AND record LIKE '%<SystemHealth>%') AS t
) AS t
ORDER BY record_id desc
2.SELECT TOP 50 qs.creation_time, qs.execution_count, qs.total_worker_time as total_cpu_time,
qs.max_worker_time as max_cpu_time, qs.total_elapsed_time, qs.max_elapsed_time, qs.total_logical_reads,
qs.max_logical_reads, qs.total_physical_reads, qs.max_physical_reads,t.[text], qp.query_plan, t.dbid, t.objectid,
t.encrypted, qs.plan_handle, qs.plan_generation_num FROM sys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_sql_text(plan_handle)
AS t CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp ORDER BY qs.total_worker_time DESC
3.select * from sysprocesses order by cpu desc
4.select * from sys.dm_os_ring_buffers
5.select COUNT(*) from sys.dm_os_schedulers where status = 'visible online'
Here the count was 8.
6.select cpu_count from sys.dm_os_sys_info
In the first query's output the system_cpu_utili was 100. Does it say cpu is 100% utilized? AM not sure abt the query.
I am able to understand from the above the queries that sql server only caused the issue in windows box but could not find out which query was causing the issue.
Even checked all the queries but they were all fine. The windows box was restarted and cpu came down to 02.
SQL was configured with 8 logical cpus. In the visible online will all the 8 configured be shown or only the utilized one will be shown?
What could be the issue? I suspect it to be some sql query only.
Also we are planning to reduce the cpu from 8 to 4 . How it can be reduced?
Can anyone pls elaborate me on the above mentioned issue and ways to solve it. Also I want to know how 8 cpus can be reduced to 4.
Thanks,
Preetha