Voici une petite requête qui permet de retrouver le temps CPU consommé par base de données d’une instance SQL Server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ------------------------------- -- Nicolas Souquet - 2012-02-12 ------------------------------- ;WITH DB_CPU_STAT AS ( SELECT D.database_id , D.name AS database_name , SUM(total_worker_time) / 1000 AS total_CPU_time_ms FROM sys.dm_exec_query_stats AS QS CROSS APPLY ( SELECT CONVERT(int, value) AS database_id FROM sys.dm_exec_plan_attributes(QS.plan_handle) WHERE attribute = N'dbid' ) AS DB INNER JOIN sys.databases AS D ON DB.database_id = D.database_id GROUP BY D.database_id, D.name ) SELECT database_name , total_CPU_time_ms / 1000 AS total_CPU_time_s , CAST(total_CPU_time_ms * 1.0 / SUM(total_CPU_time_ms) OVER() * 100.0 AS decimal(5, 2)) AS [CPU_%] FROM DB_CPU_STAT WHERE database_id > 4 -- system databases AND database_id <> 32767 -- ResourceDB ORDER BY total_CPU_time_ms DESC |
Et bonne surveillance de SQL Server