Sunday, September 8, 2019

Query for SQL Server SP Performance Indicator




SELECT TOP (20) 
  CASE WHEN database_id = 32767 THEN 'Resource' 
    ELSE DB_NAME(database_id)
  END AS DBName
      ,OBJECT_SCHEMA_NAME(object_id,database_id) AS [SCHEMA_NAME] 
      ,OBJECT_NAME(object_id,database_id)AS [OBJECT_NAME]
      ,cached_time
      ,last_execution_time
      ,execution_count
   ,total_worker_time
      ,total_worker_time / execution_count AS AVG_CPU
      ,total_elapsed_time / execution_count AS AVG_ELAPSED
      ,total_logical_reads / execution_count AS AVG_LOGICAL_READS
      ,total_logical_writes / execution_count AS AVG_LOGICAL_WRITES
      ,total_physical_reads  / execution_count AS AVG_PHYSICAL_READS
   FROM sys.dm_exec_procedure_stats 
ORDER BY execution_count DESC

No comments: