Skip to content

Commit 9928aa5

Browse files
Merge pull request #343 from erikdarlingdata/fix/rule9-memory-grant-thresholds
Rule 9: Raise memory grant warning floor to 1GB
2 parents 608c1fd + 76eca9c commit 9928aa5

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Dashboard/Services/PlanAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private static void AnalyzeStatement(PlanStatement stmt)
7575
if (grant.GrantedMemoryKB > 0 && grant.MaxUsedMemoryKB > 0)
7676
{
7777
var wasteRatio = (double)grant.GrantedMemoryKB / grant.MaxUsedMemoryKB;
78-
if (wasteRatio >= 10 && grant.GrantedMemoryKB > 1024)
78+
if (wasteRatio >= 10 && grant.GrantedMemoryKB >= 1048576)
7979
{
8080
stmt.PlanWarnings.Add(new PlanWarning
8181
{
@@ -98,7 +98,7 @@ private static void AnalyzeStatement(PlanStatement stmt)
9898
}
9999

100100
// Large memory grant with sort/hash guidance
101-
if (grant.GrantedMemoryKB > 102400 && stmt.RootNode != null)
101+
if (grant.GrantedMemoryKB >= 1048576 && stmt.RootNode != null)
102102
{
103103
var consumers = new List<string>();
104104
FindMemoryConsumers(stmt.RootNode, consumers);
@@ -112,7 +112,7 @@ private static void AnalyzeStatement(PlanStatement stmt)
112112
{
113113
WarningType = "Large Memory Grant",
114114
Message = $"Query granted {grantMB:F0} MB of memory.{guidance}",
115-
Severity = grantMB >= 512 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning
115+
Severity = grantMB >= 4096 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning
116116
});
117117
}
118118
}

Lite/Services/PlanAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private static void AnalyzeStatement(PlanStatement stmt)
7575
if (grant.GrantedMemoryKB > 0 && grant.MaxUsedMemoryKB > 0)
7676
{
7777
var wasteRatio = (double)grant.GrantedMemoryKB / grant.MaxUsedMemoryKB;
78-
if (wasteRatio >= 10 && grant.GrantedMemoryKB > 1024)
78+
if (wasteRatio >= 10 && grant.GrantedMemoryKB >= 1048576)
7979
{
8080
stmt.PlanWarnings.Add(new PlanWarning
8181
{
@@ -98,7 +98,7 @@ private static void AnalyzeStatement(PlanStatement stmt)
9898
}
9999

100100
// Large memory grant with sort/hash guidance
101-
if (grant.GrantedMemoryKB > 102400 && stmt.RootNode != null)
101+
if (grant.GrantedMemoryKB >= 1048576 && stmt.RootNode != null)
102102
{
103103
var consumers = new List<string>();
104104
FindMemoryConsumers(stmt.RootNode, consumers);
@@ -112,7 +112,7 @@ private static void AnalyzeStatement(PlanStatement stmt)
112112
{
113113
WarningType = "Large Memory Grant",
114114
Message = $"Query granted {grantMB:F0} MB of memory.{guidance}",
115-
Severity = grantMB >= 512 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning
115+
Severity = grantMB >= 4096 ? PlanWarningSeverity.Critical : PlanWarningSeverity.Warning
116116
});
117117
}
118118
}

0 commit comments

Comments
 (0)