-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Summary
When an actual plan has missing index suggestions, correlate them with the scan operators that touch the same table and show their CPU, duration, and read costs. This gives DBAs concrete numbers alongside the optimizer's impact percentage.
Example
Currently:
Missing indexes:
StackOverflow2013.dbo.Comments (impact: 79%)
CREATE NONCLUSTERED INDEX [Comments_Score]
ON [dbo].[Comments] ([Score])
INCLUDE ([UserId]);
Proposed:
Missing indexes:
StackOverflow2013.dbo.Comments (impact: 79%)
Related: Clustered Index Scan (Node 8) — 5,031ms CPU, 4,372ms elapsed, 303,887 reads
CREATE NONCLUSTERED INDEX [Comments_Score]
ON [dbo].[Comments] ([Score])
INCLUDE ([UserId]);
Implementation
- PlanAnalyzer: When building
MissingIndexResult, find operators whereObjectcontains the missing index table name AND the operator is a scan (Clustered Index Scan, Index Scan, Table Scan). Store their stats. - MissingIndexResult: Add fields for related operator summaries (name, node ID, CPU, elapsed, reads). Could be a list if multiple scans hit the same table.
- TextFormatter: Output the "Related:" line between the impact line and CREATE statement.
- AdviceContentBuilder: Style the related operator line.
Notes
- Table name matching needs substring logic:
Objectisdbo.Comments.PK_Comments_Id, missing index table isdbo.Comments - Only available in actual plans (estimated plans have no runtime stats) — skip gracefully
- All three PlanAnalyzer copies (PerformanceStudio, Dashboard, Lite) need the update
- We can show operator costs but cannot precisely predict seek savings (depends on selectivity)
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels