SQLUndercover / UndercoverToolbox

A collection of cool and useful tools, procedures and scripts for the discerning DBA
https://sqlundercover.com
MIT License
84 stars 40 forks source link

Inspector - Add a new view to check on execution times for Inspector procs #286

Closed Adedba closed 3 years ago

Adedba commented 3 years ago

Create a new view called ExecutionInfo with execution count, average/max execution time and total execution time for all executions of inspector stored procs logged to the Executionlog table.

CREATE VIEW [Inspector].[ExecutionInfo] AS SELECT Procname, COUNT(Procname) AS ExecutionCount, SUM(Duration) AS TotalDuration_Seconds, AVG(Duration) AS AverageDuration_Seconds, MAX(Duration) AS MaxDuration_Seconds FROM Inspector.ExecutionLog WHERE Procname != N'InspectorDataCollection' GROUP BY Procname;