Link to home
Create AccountLog in
Avatar of bibi92
bibi92Flag for France

asked on

cpu overload

Hello,

I try to understand what happen on SQL Instance 2014, CPU is very high and reads too.

Thank you

Regards 
Avatar of lcohan
lcohan
Flag of Canada image

Did you tried to look at that SQL 2014 - Performance Dashboard Report as that could tell right away what/where the problem is? You could use the 2012 version of them as described at link below as there were added by default to SQL 2016 and up if I'm not mistaken.

https://www.sqlshack.com/performance-dashboard-reports-sql-server-2014/

In addition to that the scripts below should help identify which DB(s) are using most of the CPU and IO

WITH CPU_Per_Db
AS
(SELECT 
 dmpa.DatabaseID
 , DB_Name(dmpa.DatabaseID) AS [Database]
 , SUM(dmqs.total_worker_time) AS CPUTimeAsMS
 FROM sys.dm_exec_query_stats dmqs 
 CROSS APPLY 
 (SELECT 
 CONVERT(INT, value) AS [DatabaseID] 
 FROM sys.dm_exec_plan_attributes(dmqs.plan_handle)
 WHERE attribute = N'dbid') dmpa
 GROUP BY dmpa.DatabaseID)
 
 SELECT 
 [Database] 
 ,[CPUTimeAsMS] 
 ,CAST([CPUTimeAsMS] * 1.0 / SUM([CPUTimeAsMS]) OVER() * 100.0 AS DECIMAL(5, 2)) AS [CPUTimeAs{96f5cbaad583fb885ff5d18ecce5734bf1e8596949521e20c290401929518f75}]
 FROM CPU_Per_Db
 ORDER BY [CPUTimeAsMS] DESC;

--chck IO per DB
WITH IO_Per_DB
AS
(SELECT 
  DB_NAME(database_id) AS Db
  , CONVERT(DECIMAL(12,2), SUM(num_of_bytes_read + num_of_bytes_written) / 1024 / 1024) AS TotalMb
 FROM sys.dm_io_virtual_file_stats(NULL, NULL) dmivfs
 GROUP BY database_id)

 SELECT 
    Db
    ,TotalMb
    ,CAST(TotalMb / SUM(TotalMb) OVER() * 100 AS DECIMAL(5,2)) AS [I/O]
FROM IO_Per_DB
ORDER BY [I/O] DESC;



Open in new window

Avatar of bibi92

ASKER

Thank you for the script CPU Time 99% and IO 50%
How to resolve please ?

Best regards 
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer