Skip to content

Show nonclustered index count on modification operators #167

@erikdarlingdata

Description

@erikdarlingdata

Feature Request

When a modification operator (INSERT, UPDATE, DELETE) touches multiple indexes, display the count of nonclustered indexes maintained by that operator as a badge on the plan node.

Why

A single INSERT/UPDATE/DELETE on a table with many nonclustered indexes has hidden I/O cost — every row modification must maintain each nonclustered index. The clustered index (or heap) is implicit since it is the table, but the nonclustered maintenance overhead is not obvious from the operator name alone.

How it works in the plan XML

Modification operators contain multiple <Object> elements inside <Update> or <SimpleUpdate>, one per index touched:

<Update DMLRequestSort="false">
    <Object ... Index="[PK_Users_Id]" IndexKind="Clustered" Storage="RowStore" />
    <Object ... Index="[a0]" IndexKind="NonClustered" Storage="RowStore" />
    <Object ... Index="[a1]" IndexKind="NonClustered" Storage="RowStore" />
    <Object ... Index="[a2]" IndexKind="NonClustered" Storage="RowStore" />
</Update>

What to display

Count only IndexKind="NonClustered" objects. The primary object (clustered index or heap) is not counted since it's inherent to the operation.

This applies to both clustered tables and heaps — a Table Insert on a heap with 5 nonclustered indexes should show the same badge as a Clustered Index Insert with 5 nonclustered indexes.

Implementation

  1. ShowPlanParser: Count <Object> elements with IndexKind="NonClustered" inside <Update> / <SimpleUpdate> elements
  2. PlanNode model: Add NonClusteredIndexCount field
  3. PlanViewerControl: Display as a badge on the operator node when count > 0 (similar to existing warning/parallel badges)

Test plans

Three example plans in .internal/examples/:

  • multi_index_update.sqlplan — UPDATE touching 6 indexes (1 CL + 5 NC)
  • multi_index_insert.sqlplan — INSERT touching 6 indexes (1 CL + 5 NC)
  • multi_index_delete.sqlplan — DELETE touching 6 indexes (1 CL + 5 NC)

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