Repository navigation
Plan analysis: mark which warnings are SQL Server's and key duplicate index suggestions on the database (#4520, #4523) - #4543
Merged
Conversation
erikdarlingdata
marked this pull request as ready for review
September 28, 2026 02:25
This was referenced Sep 28, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4520
Fixes #4523
Part of #4511
Why
Two small syncs from PerformanceStudio's plan analyzer.
PlanWarningcarried nothing but type, severity and message, so a reader could not tell a warning SQL Server itself wrote into the plan (a spill, an implicit conversion, no statistics — a record of what the engine did) apart from one the analyzer inferred from plan shape (which can be wrong about a particular plan in a way the engine's own record cannot be).Rule 30's duplicate-index-suggestion check grouped missing index suggestions by schema and table only. A plan touching a same-named table (e.g.
dbo.t) in two different databases had its suggestions merged and reported as duplicates of each other, even though they target unrelated tables.What changes
PlanWarning.Source(new enumPlanWarningSource:Analyzerdefault,SqlServer).ShowPlanParser.ParseWarningsFromElementstamps every warning it returns asSqlServerin one place — the only place parser warnings are built — so a new engine warning is attributed correctly without anyone needing to remember it at each construction site.sourcefield on every warning (additive; existing fields unchanged).[SQL Server]next to the warning type, in both the statement-level and node-level warnings panels. Only the engine's are tagged, since they are the minority and a badge on every line would carry no information.MissingIndex.Database, which already existed on the model), not just schema and table.Test plan
New
Darling.Testsclasses with synthetic plan XML (dbo.t,[db1]/[db2]):PlanSync4520Tests: an enginePlanAffectingConvertwarning is stampedSqlServer; an analyzer non-SARGable-predicate warning keeps the defaultAnalyzer; the MCP formatter's JSON carries both source values on the product's own formatting call path (McpPlanAnalysisFormatter.BuildAnalysisResult).PlanSync4523Tests: two missing-index suggestions for the same table name in two different databases are NOT reported as duplicates; two suggestions for the same table in the same database still are.Findings do not say whether SQL Server or the analyzer produced them (PlanWarning.Source) #4520:
PlanWarning.SourceandPlanWarningSourceare new, soPlanSync4520Testsis a compile-only RED on dev. Mutation: removing the parser'sSource = SqlServerstamping failsEngineWarning_IsStampedSqlServer(Expected: SqlServer, Actual: Analyzer) andMcpFormatter_CarriesSourceOnEachWarning("source":"SqlServer"not found).Duplicate index suggestions (rule 30) treat same-named tables in different databases as one table #4523:
SameTableName_DifferentDatabases_AreNotReportedAsDuplicatesis a runtime RED on dev (Assert.DoesNotContain() Failure: Filter matched in collection). Mutation: dropping the database from both rule-30 keys fails it again.Run: the new classes plus the plan-analysis classes (
ShowPlanParserCondAndMultiplePlanTests, theActualPlan*classes,QueryModificationDetectorTests,ReproScriptBuilderHardeningTests,DarlingAnalysisPipelineTests,DarlingMcpPlanToolsSurfaceAndSqlTests,McpPlanAnalysisEnvelopeTests,SerialLoopStoreSizeSourceTests,TsqlConventionGuardTests,DocCommentHygieneTests):Total: 234, Failed: 0.McpPlanAnalysisEnvelopeTestsneeded no change: thesourcefield is additive. The live-Postgres plan-tool class runs in CI.Lite.Testsbuilds; its plan classes run on Windows only.Consumers checked:
PlanAdvisoryAggregatorreads severity and counts only;McpPlanAnalysisFormattergainssource; the plan viewer tags the engine's own warnings[SQL Server]in both warning panels, as PerformanceStudio does. PerformanceStudio's CLI text formatter has no PM counterpart.CHANGELOG
SECTION: Added
ENTRY: - Plan analysis now marks which findings are SQL Server's own warnings and which are inferences, and duplicate missing-index suggestions are no longer merged across different databases ([#4543]) -
PlanWarning.Sourcesays whether a plan warning came from the engine's own<Warnings>element or from the analyzer; the plan viewer tags the engine's with[SQL Server]and the MCP plan tools carry it as asourcefield. Rule 30's duplicate-index-suggestion check now keys on database as well as schema and table, so same-named tables in different databases are no longer reported as duplicates of each other.REF: [#4543]: #4543