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
12 changes: 9 additions & 3 deletions src/PlanViewer.Core/Services/PlanAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@
private static void AnalyzeStatement(PlanStatement stmt, AnalyzerConfig cfg)
{
// 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 (!cfg.IsRuleDisabled(3) && !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 @@ -138,11 +141,14 @@
_ => stmt.NonParallelPlanReason
};

// Only warn (not info) when the user explicitly forced serial execution
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 @@ -978,7 +984,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 (!cfg.IsRuleDisabled(28) && node.PhysicalOp.Contains("Row Count Spool"))

Check warning on line 987 in src/PlanViewer.Core/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Dereference of a possibly null reference.

Check warning on line 987 in src/PlanViewer.Core/Services/PlanAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Dereference of a possibly null reference.
{
var rewinds = node.HasActualStats ? (double)node.ActualRewinds : node.EstimateRewinds;
if (rewinds > 10000 && HasNotInPattern(node, stmt))
Expand Down
4 changes: 2 additions & 2 deletions src/PlanViewer.Web/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ else
{
<span class="stmt-tab-cost">@s.EstimatedCost.ToString("N2")</span>
}
@if (s.Warnings.Count > 0)
@if (GetAllWarnings(s).Count > 0)
{
<span class="stmt-tab-warns">@s.Warnings.Count</span>
<span class="stmt-tab-warns">@GetAllWarnings(s).Count</span>
}
</button>
}
Expand Down
3 changes: 2 additions & 1 deletion src/PlanViewer.Web/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ textarea::placeholder {
margin-bottom: 0.75rem;
}

/* Wait stats card gets extra width when present */
/* Give params and waits cards extra width when populated */
.insight-card.params.has-items,
.insight-card.waits.has-items {
grid-column: span 2;
}
Expand Down
Loading