From 76eca9c669d32079b416430fca1f99deb8a0a60d Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Fri, 27 Feb 2026 06:14:46 -0500 Subject: [PATCH] Rule 9: Raise memory grant warning floor to 1GB, Critical to 4GB No memory grant warnings should fire below 1GB on modern hardware. Excessive grant (9a) and large grant (9c) both now require >= 1GB. Critical severity raised from 512MB to 4GB. Co-Authored-By: Claude Opus 4.6 --- Dashboard/Services/PlanAnalyzer.cs | 6 +++--- Lite/Services/PlanAnalyzer.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dashboard/Services/PlanAnalyzer.cs b/Dashboard/Services/PlanAnalyzer.cs index ae156aae..5df73609 100644 --- a/Dashboard/Services/PlanAnalyzer.cs +++ b/Dashboard/Services/PlanAnalyzer.cs @@ -75,7 +75,7 @@ private static void AnalyzeStatement(PlanStatement stmt) if (grant.GrantedMemoryKB > 0 && grant.MaxUsedMemoryKB > 0) { var wasteRatio = (double)grant.GrantedMemoryKB / grant.MaxUsedMemoryKB; - if (wasteRatio >= 10 && grant.GrantedMemoryKB > 1024) + if (wasteRatio >= 10 && grant.GrantedMemoryKB >= 1048576) { stmt.PlanWarnings.Add(new PlanWarning { @@ -98,7 +98,7 @@ private static void AnalyzeStatement(PlanStatement stmt) } // Large memory grant with sort/hash guidance - if (grant.GrantedMemoryKB > 102400 && stmt.RootNode != null) + if (grant.GrantedMemoryKB >= 1048576 && stmt.RootNode != null) { var consumers = new List(); FindMemoryConsumers(stmt.RootNode, consumers); @@ -112,7 +112,7 @@ private static void AnalyzeStatement(PlanStatement stmt) { WarningType = "Large Memory Grant", Message = $"Query granted {grantMB:F0} MB of memory.{guidance}", - Severity = grantMB >= 512 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning + Severity = grantMB >= 4096 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning }); } } diff --git a/Lite/Services/PlanAnalyzer.cs b/Lite/Services/PlanAnalyzer.cs index 0aec572b..803b443b 100644 --- a/Lite/Services/PlanAnalyzer.cs +++ b/Lite/Services/PlanAnalyzer.cs @@ -75,7 +75,7 @@ private static void AnalyzeStatement(PlanStatement stmt) if (grant.GrantedMemoryKB > 0 && grant.MaxUsedMemoryKB > 0) { var wasteRatio = (double)grant.GrantedMemoryKB / grant.MaxUsedMemoryKB; - if (wasteRatio >= 10 && grant.GrantedMemoryKB > 1024) + if (wasteRatio >= 10 && grant.GrantedMemoryKB >= 1048576) { stmt.PlanWarnings.Add(new PlanWarning { @@ -98,7 +98,7 @@ private static void AnalyzeStatement(PlanStatement stmt) } // Large memory grant with sort/hash guidance - if (grant.GrantedMemoryKB > 102400 && stmt.RootNode != null) + if (grant.GrantedMemoryKB >= 1048576 && stmt.RootNode != null) { var consumers = new List(); FindMemoryConsumers(stmt.RootNode, consumers); @@ -112,7 +112,7 @@ private static void AnalyzeStatement(PlanStatement stmt) { WarningType = "Large Memory Grant", Message = $"Query granted {grantMB:F0} MB of memory.{guidance}", - Severity = grantMB >= 512 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning + Severity = grantMB >= 4096 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning }); } }