Skip to content

Commit 77ec4a4

Browse files
committed
add TotalMemoryMB metric for query history
1 parent 6d525e7 commit 77ec4a4

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/PlanViewer.App/Dialogs/QueryStoreHistoryWindow.axaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<ComboBoxItem Content="Total Reads" Tag="TotalLogicalReads"/>
6060
<ComboBoxItem Content="Total Writes" Tag="TotalLogicalWrites"/>
6161
<ComboBoxItem Content="Total Physical Reads" Tag="TotalPhysicalReads"/>
62+
<ComboBoxItem Content="Total Memory (MB)" Tag="TotalMemoryMb"/>
6263
<ComboBoxItem Content="Executions" Tag="CountExecutions"/>
6364
</ComboBox>
6465
<StackPanel Orientation="Horizontal" Spacing="4" VerticalAlignment="Center">
@@ -142,6 +143,7 @@
142143
<DataGridTextColumn Header="Total Reads" Binding="{ReflectionBinding TotalLogicalReadsDisplay}" Width="100"/>
143144
<DataGridTextColumn Header="Total Writes" Binding="{ReflectionBinding TotalLogicalWritesDisplay}" Width="100"/>
144145
<DataGridTextColumn Header="Total Phys Reads" Binding="{ReflectionBinding TotalPhysicalReadsDisplay}" Width="120"/>
146+
<DataGridTextColumn Header="Total Memory (MB)" Binding="{ReflectionBinding TotalMemoryMbDisplay}" Width="120"/>
145147
<DataGridTextColumn Header="Min DOP" Binding="{ReflectionBinding MinDop}" Width="70"/>
146148
<DataGridTextColumn Header="Max DOP" Binding="{ReflectionBinding MaxDop}" Width="70"/>
147149
<DataGridTextColumn Header="Last Execution" Binding="{ReflectionBinding LastExecutionLocal}" Width="140"/>

src/PlanViewer.App/Dialogs/QueryStoreHistoryWindow.axaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public partial class QueryStoreHistoryWindow : Window
8484
["avg-writes"] = "AvgLogicalWrites",
8585
["physical-reads"] = "TotalPhysicalReads",
8686
["avg-physical-reads"] = "AvgPhysicalReads",
87-
["memory"] = "TotalCpuMs",
87+
["memory"] = "TotalMemoryMb",
8888
["avg-memory"] = "AvgMemoryMb",
8989
["executions"] = "CountExecutions",
9090
};
@@ -877,7 +877,8 @@ private void OnChartPointerMoved(object? sender, PointerEventArgs e)
877877
"TotalLogicalReads" => row.TotalLogicalReads,
878878
"TotalLogicalWrites" => row.TotalLogicalWrites,
879879
"TotalPhysicalReads" => row.TotalPhysicalReads,
880-
"CountExecutions" => row.CountExecutions,
880+
"TotalMemoryMb" => row.TotalMemoryMb,
881+
"CountExecutions" => row.CountExecutions,
881882
_ => row.AvgCpuMs,
882883
};
883884

src/PlanViewer.Core/Models/QueryStoreHistoryRow.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public class QueryStoreHistoryRow
2323
public double TotalLogicalReads { get; set; }
2424
public double TotalLogicalWrites { get; set; }
2525
public double TotalPhysicalReads { get; set; }
26-
27-
public int MinDop { get; set; }
26+
public double TotalMemoryMb { get; set; }
27+
public int MinDop { get; set; }
2828
public int MaxDop { get; set; }
2929
public DateTime? LastExecutionUtc { get; set; }
3030

@@ -41,7 +41,8 @@ public class QueryStoreHistoryRow
4141
public string TotalLogicalReadsDisplay => TotalLogicalReads.ToString("N2");
4242
public string TotalLogicalWritesDisplay => TotalLogicalWrites.ToString("N2");
4343
public string TotalPhysicalReadsDisplay => TotalPhysicalReads.ToString("N2");
44+
public string TotalMemoryMbDisplay => TotalMemoryMb.ToString("N2");
4445

45-
public string IntervalStartLocal => TimeDisplayHelper.FormatForDisplay(IntervalStartUtc);
46+
public string IntervalStartLocal => TimeDisplayHelper.FormatForDisplay(IntervalStartUtc);
4647
public string LastExecutionLocal => LastExecutionUtc.HasValue ? TimeDisplayHelper.FormatForDisplay(LastExecutionUtc.Value) : "";
4748
}

src/PlanViewer.Core/Services/QueryStoreService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ THEN SUM(rs.avg_rowcount * rs.count_executions) / SUM(rs.count_executions)
608608
SUM(rs.avg_physical_io_reads * rs.count_executions),
609609
MIN(rs.min_dop),
610610
MAX(rs.max_dop),
611-
MAX(rs.last_execution_time)
611+
MAX(rs.last_execution_time),
612+
SUM(rs.avg_query_max_used_memory * rs.count_executions)
612613
FROM sys.query_store_runtime_stats rs
613614
JOIN sys.query_store_runtime_stats_interval rsi
614615
ON rs.runtime_stats_interval_id = rsi.runtime_stats_interval_id
@@ -652,7 +653,8 @@ JOIN sys.query_store_query q
652653
MinDop = (int)reader.GetInt64(15),
653654
MaxDop = (int)reader.GetInt64(16),
654655
LastExecutionUtc = reader.IsDBNull(17) ? null : ((DateTimeOffset)reader.GetValue(17)).UtcDateTime,
655-
});
656+
TotalMemoryMb = reader.GetDouble(18),
657+
});
656658
}
657659

658660
return rows;

0 commit comments

Comments
 (0)