SQL Server CPU Kullanım raporu sorgusu

SELECT TOP 200
q.text
,DB_NAME(DatabaseID) AS [DatabaseName]
,CONVERT(NUMERIC(10, 2), CONVERT(NUMERIC, (total_worker_time)) / 1000000) AS [CPU_Time_sn]
,qs.execution_count
,CONVERT(NUMERIC(10, 2), (CONVERT(NUMERIC, (total_worker_time)) / qs.execution_count) / 1000000) AS AVG_Time
,CONVERT(NUMERIC(10, 2), CONVERT(NUMERIC, (qs.last_worker_time)) / 1000000) AS last_worker_time
,CONVERT(NUMERIC(10, 2), CONVERT(NUMERIC, (qs.min_worker_time)) / 1000000) AS min_worker_time
,CONVERT(NUMERIC(10, 2), CONVERT(NUMERIC, (qs.max_worker_time)) / 1000000) AS max_worker_time
,CONVERT(NUMERIC(10, 2), CONVERT(NUMERIC, (qs.last_elapsed_time)) / 1000000) AS last_elapsed_time
,CONVERT(NUMERIC(10, 2), CONVERT(NUMERIC, (qs.max_elapsed_time)) / 1000000) AS max_elapsed_time
,qs.last_physical_reads
,qs.last_execution_time
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY (SELECT
CONVERT(INT, value) AS [DatabaseID]
FROM sys.dm_exec_plan_attributes(qs.plan_handle)
WHERE attribute = N'dbid') AS F_DB
CROSS APPLY sys.dm_exec_sql_text(plan_handle) q
WHERE DB_NAME(DatabaseID) = 'VeritabaniAdi'
ORDER BY AVG_Time DESC

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir