[opt](ivm) Reduce snapshot checks for outer join NULL repair #70561
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #70561"
general
weight: 0.35
morrySnow
Background
During incremental refresh, a change to B in
A LEFT JOIN Bcan change a joined row and can also retract or insert the NULL-extended A row. The same repair is needed in the opposite direction for RIGHT and FULL joins. FULL joins additionally preserve unmatched rows from the delta itself.What problem does this PR solve?
Issue Number: None
Related PR: #70630 (sign-aware sequence for repair rows)
PR Type: Performance
Outer join refresh builds separate pre- and post-snapshot existence checks for NULL repair. If a retained A row has at most one matching B row in either snapshot, its repair sign is exactly the negative change in its match count. This PR computes that change from the signed delta and also shares key-based repair events between LEFT, RIGHT and FULL equijoins.
Details
Each row describes one contribution from the changing input B. A is the opposite-side snapshot. The LEFT/RIGHT column covers changes from the null-producing side. When the preserved input changes, that contribution uses the original directional outer join directly. For FULL, apply the column once for each changing input.
| ON condition and B uniqueness | LEFT/RIGHT, B changes | FULL, B changes | B pre/post snapshots for repair |
| --- | --- | --- | --- |
| Pure deterministic ordinary equalities. All B equality keys support value-preserving grouping, and B's direct equality slots cover a unique key of the original relation. |
A INNER JOIN events. Events are B detail plus signed key repairs. |A RIGHT OUTER JOIN B_deltafor detail, including unmatched B rows, plusA INNER JOIN signed_key_repairs. | Neither || Pure deterministic ordinary equalities. All B equality keys support value-preserving grouping, and B's uniqueness is unproven, for example with a partial composite key or an expression key. |
A INNER JOIN events. Events are B detail plus pre/post keyANTI JOINrepairs. |A RIGHT OUTER JOIN B_deltafor detail plusA INNER JOINto the union of the pre/post key repairs. | Both || Deterministic equality plus a residual predicate. B's direct equality slots cover a unique key, A is repeatable, and A's ON inputs support value-preserving grouping. |
A INNER JOIN B_deltafor detail plus signed repair grouped by A's ON inputs. |A RIGHT OUTER JOIN B_deltafor detail plus the same repair grouped by A's ON inputs. | Neither || All remaining cases. Examples include a
FLOATorDOUBLEB equality key, an unproven B key with a residual predicate, and a retained-side producer or input type that cannot be used for tuple repair. |A INNER JOIN B_deltafor detail plus the two pre/postSEMI JOIN/ANTI JOINrepairs. |A RIGHT OUTER JOIN B_deltafor detail plus the same two pre/post repairs. | Both |Both pure-equality event paths group B keys before probing A.
GROUP BYcan merge+0.0and-0.0while a hash join distinguishes them. An update between signed zeros can cancel distinct repair events or make the grouped event probe the wrong rows. Keys that do not support value-preserving grouping use the original per-row SEMI/ANTI snapshot repair and still refresh incrementally.Pure equijoin, LEFT/RIGHT, unique B with eligible equality keys. The key aggregate replaces two repair inputs below the same probe. Ordinary same-key payload updates still flow through detail.
Pure equijoin, FULL, B delta with eligible equality keys. The detail branch emits even a B row with no A match. Only repair events probe A by key.
Additional ON predicate, unique B. For example, given
A.k = B.k AND A.threshold < B.amount, a same-key update can change the match for only some A rows. Evaluate the entire predicate before counting. Retained rows with the same values for every A slot in ON have identical matches. For n such rows, the signed sum is n times the match change, so its sign determines one unit repair per original row. Look up the retained bag with NULL-safe comparisons on the complete tuple. This also works for nullable, colliding or independently generated row IDs. The tuple path accepts booleans, integral and decimal values, character strings, dates/timestamps, IPs and UUIDs. Other input types use snapshot repair. The same fallback applies when a retained subtree produces nondeterministic values, including an otherwise deterministic-looking ON slot backed by a UUID alias.Results and cost. For a unique B that qualifies for signed repair, both repair snapshot reads disappear. In FULL equijoins with eligible equality keys, the opposite-side snapshot occurs twice instead of three times. The residual path evaluates the match join for repair as well as detail and looks up the retained rows for each changed tuple. These are logical plan differences. Runtime will depend on the changed rows, selectivity and snapshot sizes. No elapsed-time benchmark was run.
Testing
FLOATandDOUBLE, and both proven and unproven B uniqueness. Three update batches test both sign changes, insertion, last-match deletion, and changes on both inputs. All 12 result comparisons with fresh queries matched, andEXPLAINverified the expected SEMI/ANTI repair branches. The baseline returned differing rows in both grouped equality paths.IvmJoinDeltaHandlerTest(34),IvmDeltaRewriterTest(23),CreateMTMVCommandTest(99), andDataTypeTest(37). The FE build and Checkstyle passed.LENGTH(A.tag)where the retained project computesUUID() AS tag. The snapshot repair removes the old NULL rows.Release note
Incremental outer join refresh can use fewer snapshot reads when repairing NULL-extended rows.
Check List (For Author)