Skip to content

fix(plan): use hash anti join for filtered NOT EXISTS - #26798

Merged
XuPeng-SH merged 2 commits into
mainfrom
fix/issue-26797-not-exists-hash-anti
Aug 9, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
fix/issue-26797-not-exists-hash-anti

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Summary

Validation

  • .agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan ./pkg/sql/compile
  • make build
  • fixed single-node service with 6GB memory cache: full NOT EXISTS returned 199500 in 599ms and used RIGHT ANTI hashOnPK; the old plan was LoopJoin and exceeded 180s
  • complex correctness: 26/26
  • indexed-table DML checks: 0 failures
  • index combinations: 0 failures; predicate-order/index-order/function equivalences preserved
  • concurrent harness: 630 queries, 0 errors/timeouts
  • partition scenarios intentionally excluded

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner August 8, 2026 22:41
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review completed — no blocking findings.

I traced the full path from correlated-subquery flattening through MARK filter pushdown, equality detection, and physical join compilation. The rewrite is semantically sound: once the marker is consumed directly or through NOT and the join is lowered to SEMI/ANTI, only TRUE matches matter, so ISTRUE(equal) and equal define the same match set. Projected MARK joins remain untouched, preserving three-valued semantics. The cross-input guard also correctly retains wrappers for same-side, mixed-side, non-equality, and outer-scope conditions.

Validation at head bdcada5:

  • The exact witness fails on base 08770e1 because ANTI does not expose a hash equality, then passes on this head.
  • Counterexample planner matrix covered EXISTS/NOT EXISTS, commuted and composite nullable equalities, equality plus nullable residual, projected MARK, and mixed/outer/same-side controls.
  • Physical compilation matrix confirmed eligible SEMI/ANTI plans use HashJoin, residual predicates remain residuals, and ineligible mixed-side equality stays on LoopJoin.
  • go build, go vet, and full CGo-controlled tests for ./pkg/sql/plan and ./pkg/sql/compile passed.
  • GitHub CI is green.

Non-blocking follow-up: retain a SQL-level result regression for filtered nullable NOT EXISTS. The committed typed planner/compiler tests prove the transformation and physical selection well; a public result oracle would make the NULL-semantics contract durable too.

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…6798)

## Summary

- unwrap only strict cross-input `ISTRUE(equal)` predicates when a MARK
join is lowered to SEMI/ANTI
- preserve projected MARK join three-valued semantics
- add planner and compiler regression tests
- fixes matrixorigin#26797

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan
./pkg/sql/compile`
- `make build`
- fixed single-node service with 6GB memory cache: full `NOT EXISTS`
returned 199500 in 599ms and used RIGHT ANTI hashOnPK; the old plan was
LoopJoin and exceeded 180s
- complex correctness: 26/26
- indexed-table DML checks: 0 failures
- index combinations: 0 failures; predicate-order/index-order/function
equivalences preserved
- concurrent harness: 630 queries, 0 errors/timeouts
- partition scenarios intentionally excluded
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…6798)

## Summary

- unwrap only strict cross-input `ISTRUE(equal)` predicates when a MARK
join is lowered to SEMI/ANTI
- preserve projected MARK join three-valued semantics
- add planner and compiler regression tests
- fixes matrixorigin#26797

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan
./pkg/sql/compile`
- `make build`
- fixed single-node service with 6GB memory cache: full `NOT EXISTS`
returned 199500 in 599ms and used RIGHT ANTI hashOnPK; the old plan was
LoopJoin and exceeded 180s
- complex correctness: 26/26
- indexed-table DML checks: 0 failures
- index combinations: 0 failures; predicate-order/index-order/function
equivalences preserved
- concurrent harness: 630 queries, 0 errors/timeouts
- partition scenarios intentionally excluded
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…6798)

## Summary

- unwrap only strict cross-input `ISTRUE(equal)` predicates when a MARK
join is lowered to SEMI/ANTI
- preserve projected MARK join three-valued semantics
- add planner and compiler regression tests
- fixes matrixorigin#26797

## Validation

- `.agents/skills/mo-dev/scripts/mo-cgo-test ./pkg/sql/plan
./pkg/sql/compile`
- `make build`
- fixed single-node service with 6GB memory cache: full `NOT EXISTS`
returned 199500 in 599ms and used RIGHT ANTI hashOnPK; the old plan was
LoopJoin and exceeded 180s
- complex correctness: 26/26
- indexed-table DML checks: 0 failures
- index combinations: 0 failures; predicate-order/index-order/function
equivalences preserved
- concurrent harness: 630 queries, 0 errors/timeouts
- partition scenarios intentionally excluded

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance]: NOT EXISTS anti-join falls back to nested-loop execution

2 participants