Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Dashboard/Services/PlanAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
private static void AnalyzeStatement(PlanStatement stmt)
{
// Rule 3: Serial plan with reason
// Skip trivial statements (e.g., variable assignments, constant scans) — not worth warning about
// Skip: trivial cost (< 0.01), TRIVIAL optimization (can't go parallel anyway),
// and 0ms actual elapsed time (not worth flagging).
if (!string.IsNullOrEmpty(stmt.NonParallelPlanReason)
&& stmt.StatementSubTreeCost >= 0.01)
&& stmt.StatementSubTreeCost >= 0.01
&& stmt.StatementOptmLevel != "TRIVIAL"
&& !(stmt.QueryTimeStats != null && stmt.QueryTimeStats.ElapsedTimeMs == 0))
{
var reason = stmt.NonParallelPlanReason switch
{
Expand All @@ -52,11 +55,13 @@
_ => stmt.NonParallelPlanReason
};

var isExplicit = stmt.NonParallelPlanReason is "MaxDOPSetToOne" or "QueryHintNoParallelSet";

stmt.PlanWarnings.Add(new PlanWarning
{
WarningType = "Serial Plan",
Message = $"Query running serially: {reason}.",
Severity = PlanWarningSeverity.Warning
Severity = isExplicit ? PlanWarningSeverity.Warning : PlanWarningSeverity.Info
});
}

Expand Down Expand Up @@ -870,7 +875,7 @@
// Rule 28: Row Count Spool — NOT IN with nullable column
// Pattern: Row Count Spool with high rewinds, child scan has IS NULL predicate,
// and statement text contains NOT IN
if (node.PhysicalOp.Contains("Row Count Spool"))

Check warning on line 878 in Dashboard/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 878 in Dashboard/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 878 in Dashboard/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 878 in Dashboard/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 878 in Dashboard/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
var rewinds = node.HasActualStats ? (double)node.ActualRewinds : node.EstimateRewinds;
if (rewinds > 10000 && HasNotInPattern(node, stmt))
Expand Down
11 changes: 8 additions & 3 deletions Lite/Services/PlanAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
private static void AnalyzeStatement(PlanStatement stmt)
{
// Rule 3: Serial plan with reason
// Skip trivial statements (e.g., variable assignments, constant scans) — not worth warning about
// Skip: trivial cost (< 0.01), TRIVIAL optimization (can't go parallel anyway),
// and 0ms actual elapsed time (not worth flagging).
if (!string.IsNullOrEmpty(stmt.NonParallelPlanReason)
&& stmt.StatementSubTreeCost >= 0.01)
&& stmt.StatementSubTreeCost >= 0.01
&& stmt.StatementOptmLevel != "TRIVIAL"
&& !(stmt.QueryTimeStats != null && stmt.QueryTimeStats.ElapsedTimeMs == 0))
{
var reason = stmt.NonParallelPlanReason switch
{
Expand All @@ -52,11 +55,13 @@
_ => stmt.NonParallelPlanReason
};

var isExplicit = stmt.NonParallelPlanReason is "MaxDOPSetToOne" or "QueryHintNoParallelSet";

stmt.PlanWarnings.Add(new PlanWarning
{
WarningType = "Serial Plan",
Message = $"Query running serially: {reason}.",
Severity = PlanWarningSeverity.Warning
Severity = isExplicit ? PlanWarningSeverity.Warning : PlanWarningSeverity.Info
});
}

Expand Down Expand Up @@ -869,7 +874,7 @@
// Rule 28: Row Count Spool — NOT IN with nullable column
// Pattern: Row Count Spool with high rewinds, child scan has IS NULL predicate,
// and statement text contains NOT IN
if (node.PhysicalOp.Contains("Row Count Spool"))

Check warning on line 877 in Lite/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
var rewinds = node.HasActualStats ? (double)node.ActualRewinds : node.EstimateRewinds;
if (rewinds > 10000 && HasNotInPattern(node, stmt))
Expand Down
Loading