← Back to Pull requests

add index key columns and order them #25484

Closed
unknown closed this pull request without merging on Oct 05, 2026 15:21 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 18:47 UTC
Author

What does this PR do?

Report SQL Server index key columns and included columns as separate fields on each index in the schema payload. key_columns is the key, in key order, with DESC on descending keys. included_columns is only the INCLUDE list. column_names is unchanged.

Motivation

column_names is one comma-separated string, so a reader cannot tell a key column from an INCLUDE column or from a partition column SQL Server appends. A clustered key can also come back in table order instead of key order. That makes an index look like it covers a query when it does not, and it makes index recommendations get dropped because a column looks like it is already indexed.

Local test

Ran this against SQL Server 2022 in dbm/local-dev (sqlserver-primary), database index_key_repro. Six rows came back.

dbo.wide is columns a, b, c, e:

CONSTRAINT pk_wide PRIMARY KEY CLUSTERED (b, a)
CREATE INDEX ix_include ON dbo.wide (c) INCLUDE (a, e);
CREATE INDEX ix_prefix ON dbo.wide (c, a) INCLUDE (e);
CREATE INDEX ix_desc ON dbo.wide (c DESC, a);

| defined as | key_columns | included_columns | column_names |
|---|---|---|---|
| PRIMARY KEY CLUSTERED (b, a) | b,a | | a,b |
| (c) INCLUDE (a, e) | c | a,e | c,a,e |
| (c, a) INCLUDE (e) | c,a | e | c,a,e |
| (c DESC, a) | c DESC,a | | c,a |
| (population) on a table partitioned by id | population | | population,id |
| PRIMARY KEY CLUSTERED (id) | id | | id |

column_names still follows table order on pk_wide (a,b for a key of (b, a)), and it is the same string c,a,e for both INCLUDE indexes. The new fields keep the declared key, the INCLUDE list, and DESC.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)

  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.

  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged
  • Diff: 273 lines (+204 / -69) across 3 files Reviewer: steveny91 Review duration: 5554m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 273 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.336
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #25484"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.5% (MEDIUM) · Higher = larger blast radius
    39.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.6% · Safe to merge
    15.6%