diff --git a/src/Opserver.Core/Data/SQL/SQLInstance.TopOperations.cs b/src/Opserver.Core/Data/SQL/SQLInstance.TopOperations.cs index cc599ef5..d7bf5955 100644 --- a/src/Opserver.Core/Data/SQL/SQLInstance.TopOperations.cs +++ b/src/Opserver.Core/Data/SQL/SQLInstance.TopOperations.cs @@ -52,6 +52,9 @@ public class TopOperation : ISQLVersioned public long AvgReads { get; internal set; } public long TotalReads { get; internal set; } public decimal PercentReads { get; internal set; } + public long AvgWrites { get; internal set; } + public long TotalWrites { get; internal set; } + public decimal PercentWrites { get; internal set; } public long ExecutionCount { get; internal set; } public decimal PercentExecutions { get; internal set; } public decimal ExecutionsPerMinute { get; internal set; } @@ -82,9 +85,9 @@ public ShowPlanXML GetShowPlanXML() } internal const string FetchSQL = @" -SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute, - TotalCPU, TotalDuration, TotalReads, - PercentCPU, PercentDuration, PercentReads, PercentExecutions, +SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute, AvgWrites, + TotalCPU, TotalDuration, TotalReads, TotalWrites, + PercentCPU, PercentDuration, PercentReads, PercentExecutions, PercentWrites, ExecutionCount, ExecutionsPerMinute, PlanCreationTime, LastExecutionTime, @@ -109,6 +112,7 @@ ELSE StatementEndOffset total_worker_time / execution_count AS AvgCPU, total_elapsed_time / execution_count AS AvgDuration, total_logical_reads / execution_count AS AvgReads, + total_logical_writes / execution_count AS AvgWrites, Cast(total_worker_time / age_minutes As BigInt) AS AvgCPUPerMinute, execution_count / age_minutes AS ExecutionsPerMinute, Cast(total_worker_time / age_minutes_lifetime As BigInt) AS AvgCPUPerMinuteLifetime, @@ -116,10 +120,12 @@ ELSE StatementEndOffset total_worker_time AS TotalCPU, total_elapsed_time AS TotalDuration, total_logical_reads AS TotalReads, + total_logical_writes AS TotalWrites, execution_count ExecutionCount, CAST(ROUND(100.00 * total_worker_time / t.TotalWorker, 2) AS MONEY) AS PercentCPU, CAST(ROUND(100.00 * total_elapsed_time / t.TotalElapsed, 2) AS MONEY) AS PercentDuration, CAST(ROUND(100.00 * total_logical_reads / t.TotalReads, 2) AS MONEY) AS PercentReads, + CAST(ROUND(100.00 * total_logical_writes / t.TotalWrites, 2) AS MONEY) AS PercentWrites, CAST(ROUND(100.00 * execution_count / t.TotalExecs, 2) AS MONEY) AS PercentExecutions, qs.creation_time AS PlanCreationTime, qs.last_execution_time AS LastExecutionTime, @@ -144,7 +150,8 @@ THEN DATEDIFF(second, creation_time, last_execution_time) / 60.0 CROSS JOIN(SELECT SUM(execution_count) TotalExecs, SUM(total_elapsed_time) TotalElapsed, SUM(total_worker_time) TotalWorker, - SUM(Cast(total_logical_reads as DECIMAL(38,0))) TotalReads + SUM(Cast(total_logical_reads as DECIMAL(38,0))) TotalReads, + SUM(Cast(total_logical_writes as DECIMAL(38,0))) TotalWrites FROM sys.dm_exec_query_stats) AS t CROSS APPLY sys.dm_exec_plan_attributes(qs.plan_handle) AS pa WHERE pa.attribute = 'dbid' @@ -185,7 +192,10 @@ public enum TopSorts [Description("Percent of Total Executions")] PercentExecutions = 13, [Description("Executions per minute")] ExecutionsPerMinute = 14, [Description("Plan Creation Time")] PlanCreationTime = 15, - [Description("Last Execution Time")] LastExecutionTime = 16 + [Description("Last Execution Time")] LastExecutionTime = 16, + [Description("Average Writes")] AvgWrites = 17, + [Description("Total Writes")] TotalWrites = 18, + [Description("Percent of Total Writes")] PercentWrites = 19 } public class TopSearchOptions diff --git a/src/Opserver.Web/Views/SQL/Operations.Top.Detail.cshtml b/src/Opserver.Web/Views/SQL/Operations.Top.Detail.cshtml index 4089e67b..16597184 100644 --- a/src/Opserver.Web/Views/SQL/Operations.Top.Detail.cshtml +++ b/src/Opserver.Web/Views/SQL/Operations.Top.Detail.cshtml @@ -26,7 +26,7 @@ { var plan = op.GetShowPlanXML();
-
+
CPU
@@ -45,7 +45,7 @@
-
+
Reads
@@ -64,7 +64,26 @@
-
+
+
+
Writes
+
+
+ @op.TotalWrites.ToComma() + +
+
+ @op.AvgWrites.ToComma() + +
+
+ @op.PercentWrites.ToString("0.00") + +
+
+
+
+
Executions
diff --git a/src/Opserver.Web/Views/SQL/Operations.Top.cshtml b/src/Opserver.Web/Views/SQL/Operations.Top.cshtml index 7b2a4a96..cce021dc 100644 --- a/src/Opserver.Web/Views/SQL/Operations.Top.cshtml +++ b/src/Opserver.Web/Views/SQL/Operations.Top.cshtml @@ -59,6 +59,7 @@ else CPU Time Reads + Writes Execs Time Query Info @@ -74,6 +75,9 @@ else @SortLink(SQLInstance.TopSorts.AvgReads, "Avg") @SortLink(SQLInstance.TopSorts.TotalReads, "Total") + @SortLink(SQLInstance.TopSorts.AvgWrites, "Avg") + @SortLink(SQLInstance.TopSorts.TotalWrites, "Total") + @SortLink(SQLInstance.TopSorts.ExecutionCount, "Execs") @SortLink(SQLInstance.TopSorts.ExecutionsPerMinute, "Execs/min") @SortLink(SQLInstance.TopSorts.LastExecutionTime, "Last Exec") @@ -92,6 +96,8 @@ else @ReadableTime(o.TotalDuration) @o.AvgReads.ToComma() @o.TotalReads.ToComma() + @o.AvgWrites.ToComma() + @o.TotalWrites.ToComma() @o.ExecutionCount.ToComma() @o.ExecutionsPerMinute.ToString("0.00") @o.LastExecutionTime.ToRelativeTimeSpan()