Repository navigation
perf(sql): hash safe nullable composite EXISTS witnesses - #31848
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 8f244d4cd399ac4513fe618625ebe1c1f7ad9255
Assessment: approve
No actionable defects found. The Boolean EXISTS path preserves ordinary MARK semantics, copying, transport and resource ownership. The documented additional-memory tradeoff is acceptable.
Model: gpt-6-astra / xhigh
Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2
Validation:
-
Full normal tests passed for both protobuf packages, hashjoin, planner and compiler.
-
Public nullable-EXISTS SQL and two-CN integration tests passed.
-
Four focused dependency/reuse tests passed under race detection, including 100 repetitions each.
-
Seven changed packages passed go vet; formatting and diff checks passed.
-
Decoded protobuf descriptors contain only the intended additions. Discussion coverage and source immutability verified.
-
Commands, exits and retained logs reconciled in validation-ledger.json and validation-audit-v2.log.
Limitations:
-
Performance measurements remain author-reported; benchmarks were not independently repeated.
-
Configured golangci-lint was unavailable; static validation used go vet.
…sion Upstream 4183159 (matrixorigin#31848) added plan.Node.mark_existence_only = 96 and pipeline.HashJoin.existence_only = 19 while this branch had already assigned Node field 96 to its additive ScanReadRole scan_read_role. Resolution (semantic, both sides kept): - upstream's mark_existence_only keeps field number 96 (shipped on main); - this branch's additive scan_read_role moves to field number 97 - the branch was never merged, so no serialized plan ever carried 96 as scan_read_role; - plan.pb.go and pipeline.pb.go are regenerated from the merged protos with the repository protoc/gogofast toolchain plus the plan_string_literal_form and plan_collation_admission postprocess steps; the same toolchain reproduces upstream main's committed bindings byte-for-byte from main's own protos, so the merged bindings are upstream's content plus only this branch's additive fields, in upstream's exact generation style; - all other overlapping files auto-merged with both sides' hunks intact: deepcopy.go still copies both MarkExistenceOnly and ScanReadRole, and upstream's HashJoin wiring in convertToVmOperator lives in distinct functions from this branch's LockOp marking. Full-tree go build ./pkg/... and the focused conflict-resolution test ladder are green (see the PR description for the dated record).
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31829.
What this PR does / why we need it:
Projected correlated EXISTS over duplicate-heavy nullable composite keys can repeatedly scan the complete witness input. The planner already knows when a consumer needs only Boolean existence, but compilation loses that distinction and conservatively uses the three-valued loop MARK path.
Preserve that proof on the plan and lower eligible broadcast MARK joins to the existing hash membership operator. TRUE requires a complete non-NULL matching key; every other existence result is FALSE. Preserve the existing IS TRUE consumer and scalar DISTINCT/LIMIT reconstruction, including NULL on no witness. Ordinary IN/NOT IN/ANY/ALL keep their three-valued semantics and existing shuffle restrictions.
The initial domain is direct cross-input equality on matching integer types, with no residual or computed key and a finite estimated outer cardinality greater than one. Missing/small estimates and unsupported shapes retain the old path. Planner totality checks protect errors and volatile join operands. Reuse HashBuild's existing map, memory accounting, producer-error propagation and cleanup; add no deduplication stage, cache or owner. Copy and transport the Boolean operator mode consistently. Additive proto fields default to false for older persisted plans; no new per-feature protocol gates under the repository's shutdown-upgrade contract.
Design: Boolean existence MARK, revision 1.2. Terra/max designed the solution before implementation and performed the final overall review.
Performance and tradeoffs (local Linux, one CN; timings are observed runs with cache/background-I/O variation):
Both large fixtures return all 288 rows matching independent Python oracles. Operator times are not additive query wall times; these are not an SLA or a controlled production benchmark. DISTINCT controls varied substantially (roughly 4.9–28.7 s). A one-probe timing control was also noisy (23.38 s base / 32.02 s candidate); physical regression coverage confirms it retains LoopJoin, so no speedup is claimed there.
Hash membership exchanges extra O(distinct keys) map memory for avoiding repeated witness scans. Peak build memory still includes existing input copies: O(input rows + distinct keys). The high-distinct fixture adds about 17.33 MB of accounted peak memory. Broadcast builds gain no spill fallback; resource admission can reject a hash plan where a batch-only loop fits. Existing budget failure propagation and zero-account cleanup are tested.
Validation (Go 1.27.1, Linux/amd64, matching native artifacts through the repository CGo wrapper):
go vet, configured golangci-lint (0 issues) and Makefile-pinned molint pass. The final test cleanup delta also passes focused race and incremental SCA. Gofmt and diff checks pass.Remote CI is pending. This does not optimize general nullable composite IN/NOT IN, computed keys, non-integer domains or single-probe estimates.