Skip to content

Show related operator costs alongside missing index suggestions #69

@erikdarlingdata

Description

@erikdarlingdata

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

  1. PlanAnalyzer: When building MissingIndexResult, find operators where Object contains the missing index table name AND the operator is a scan (Clustered Index Scan, Index Scan, Table Scan). Store their stats.
  2. MissingIndexResult: Add fields for related operator summaries (name, node ID, CPU, elapsed, reads). Could be a list if multiple scans hit the same table.
  3. TextFormatter: Output the "Related:" line between the impact line and CREATE statement.
  4. AdviceContentBuilder: Style the related operator line.

Notes

  • Table name matching needs substring logic: Object is dbo.Comments.PK_Comments_Id, missing index table is dbo.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions