← Back to Pull requests

[opt](ivm) Explore a smaller hash build for NULL repair anti joins #71071

Closed
unknown closed this pull request without merging on Nov 30, 2026 23:23 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 17:06 UTC
Author

Background

During incremental materialized view refresh, a change on the null-producing side of an equi-join can add or remove a NULL-extended row. When the matching key is non-unique, the refresh groups the changed keys and uses an anti join against the pre-refresh or post-refresh snapshot to detect that transition.

What problem does this PR solve?

Issue Number: None
Related PR: #70922 (the INNER and CROSS JOIN optimization)
PR Type: Performance

Problem Summary: A NULL repair anti join can build its hash table over a large snapshot even when the refresh affects a few keys. If invalid statistics automatically disable join reordering, the optimizer can still consider building this particular anti join on the affected keys.

Details

  • Why it was slow: The existing LEFT ANTI orientation uses the snapshot as its hash build input. In a directional A/B test, the hash build consumed 8 million rows to evaluate 32 affected keys.

  • Optimization: Identify the anti join generated for non-unique equality keys. After a statistics check automatically disables reordering, offer one RIGHT ANTI alternative in the same Memo group when the rewritten join still supports hashing and the snapshot exceeds the configured broadcast row limit. The optimizer compares the existing orientation and the new one.

  • Results: With an 8-million-row snapshot and 32 keys, test queries on the same single-BE ASAN runtime on a Xeon Platinum 8457C host returned the same 16 unmatched keys. Both plans used bucket shuffle. Across five interleaved warm runs per direction, median client wall time was 1.49 s for LEFT ANTI and 0.28 s for RIGHT ANTI. The hash build operator reported a peak of 109.78 MB and 30.52 MB, respectively. With a 16-row snapshot, LEFT ANTI chose broadcast and ran in 0.07 s median, compared with 0.13 s for RIGHT ANTI. These measurements cover the isolated anti join.

  • Applicability and cost: Local exploration adds at most one orientation per eligible join. Snapshot scans can still be large, and the cost model accounts for shuffle. Small snapshots keep their automatic broadcast option. Explicit reordering and distribution decisions take precedence.
  • Testing

  • FE package and Checkstyle passed.

  • Passed 551 IVM and MTMV FE unit tests. The focused optimizer and statistics run also passed all 75 tests.

  • All 132 IVM regression suites passed across the directory run and a targeted rerun of three suites. Two existing fixtures required the default database name. The updated NULL-repair suite passed with regenerated expected results.

  • The new suite checks automatic broadcast for a small snapshot, RIGHT ANTI for a large snapshot after invalid stats disable reorder, and LEFT ANTI when reorder is disabled explicitly. It covers first-match insertion, last-match deletion, and deletion with a duplicate match remaining.
  • Release note

    Incremental refresh can reduce the hash build footprint of eligible NULL repair anti joins against large snapshots.

    Check List (For Author)

  • Behavior changed: No

  • Does this need documentation: No

  • Pre-submission status: Partially verified: the isolated anti-join comparison used an ASAN build. RELEASE and refresh-wide performance were not measured.
  • Diff: 405 lines (+303 / -102) across 5 files Reviewer: morrySnow Review duration: 6137m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 405 lines diff across 5 files
    0.45
    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.359
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #71071"
    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: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    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: 17.7% · Safe to merge
    17.7%
    Repository