From 3a8422135880e880f1ca5fbe251352a60220d81c Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Thu, 26 Mar 2026 18:10:36 -0400 Subject: [PATCH] Post-merge cleanup for PR #148 - Fix fire-and-forget: globalWaitTask variable replaced with _ = discard - Remove Debug.WriteLines from wait stats catch blocks, add separate OperationCanceledException handler for clean cancellation - Remove unused System.Diagnostics using - Restore ps. prefix on orderClause (used in ranked CTE where ps is the correct alias for #plan_stats) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Controls/QueryStoreGridControl.axaml.cs | 10 +++++----- .../Services/QueryStoreService.cs | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs index 595acd6..f47df61 100644 --- a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs +++ b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; using System.Threading; @@ -190,9 +189,8 @@ private async System.Threading.Tasks.Task FetchPlansForRangeAsync() _filteredRows.Clear(); // Start global + ribbon wait stats early (they don't depend on plan results) - System.Threading.Tasks.Task? globalWaitTask = null; if (_waitStatsSupported && _waitStatsEnabled && _slicerStartUtc.HasValue && _slicerEndUtc.HasValue) - globalWaitTask = FetchGlobalWaitStatsOnlyAsync(_slicerStartUtc.Value, _slicerEndUtc.Value, ct); + _ = FetchGlobalWaitStatsOnlyAsync(_slicerStartUtc.Value, _slicerEndUtc.Value, ct); try { @@ -417,7 +415,8 @@ private async System.Threading.Tasks.Task FetchGlobalWaitStatsOnlyAsync( if (ct.IsCancellationRequested) { return; } WaitStatsProfile.SetRibbonData(ribbonData); } - catch (Exception ex) { Debug.WriteLine($"[WAITSTATS] FetchGlobalWaitStatsOnlyAsync EXCEPTION: {ex}"); } + catch (OperationCanceledException) { } + catch (Exception) { } finally { WaitStatsProfile.SetLoading(false); @@ -450,7 +449,8 @@ private async System.Threading.Tasks.Task FetchPerPlanWaitStatsAsync( } UpdateWaitBarMode(); } - catch (Exception ex) { Debug.WriteLine($"[WAITSTATS] FetchPerPlanWaitStatsAsync EXCEPTION: {ex}"); } + catch (OperationCanceledException) { } + catch (Exception) { } } /// diff --git a/src/PlanViewer.Core/Services/QueryStoreService.cs b/src/PlanViewer.Core/Services/QueryStoreService.cs index 08b3624..7692981 100644 --- a/src/PlanViewer.Core/Services/QueryStoreService.cs +++ b/src/PlanViewer.Core/Services/QueryStoreService.cs @@ -56,14 +56,14 @@ public static async Task> FetchTopPlansAsync( // avg- variants still rank by total CPU (most impactful plan). var orderClause = key switch { - "cpu" => "total_cpu_us", - "duration" => "total_duration_us", - "reads" => "total_reads", - "writes" => "total_writes", - "physical-reads" => "total_physical_reads", - "memory" => "total_memory_pages", - "executions" => "total_executions", - _ => "total_cpu_us" + "cpu" => "ps.total_cpu_us", + "duration" => "ps.total_duration_us", + "reads" => "ps.total_reads", + "writes" => "ps.total_writes", + "physical-reads" => "ps.total_physical_reads", + "memory" => "ps.total_memory_pages", + "executions" => "ps.total_executions", + _ => "ps.total_cpu_us" }; // Final ORDER BY — either a total or avg column from ranked CTE.