Skip to content

fix: Skip disconnected correlated-only query graphs#701

Merged
adsharma merged 1 commit into
mainfrom
fix/issue-697-optional-match-double-cardinality
Jul 18, 2026
Merged

fix: Skip disconnected correlated-only query graphs#701
adsharma merged 1 commit into
mainfrom
fix/issue-697-optional-match-double-cardinality

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

When a comma-separated pattern in OPTIONAL MATCH references an already-bound variable without adding new constraints (e.g., bare (n3) in OPTIONAL MATCH), the binder creates a disconnected query graph. This graph was planned as a full node-table scan, producing extra rows that doubled the cardinality.

Fix: in planQueryGraphCollection, skip query graphs that have no relationships and whose nodes are all correlated (already bound in the outer plan). Their correlated expressions are already captured via join conditions.

Fixes #697.

@adsharma adsharma changed the title Fix #697: Skip disconnected correlated-only query graphs fix: Skip disconnected correlated-only query graphs Jul 18, 2026
…MATCH

When a comma-separated pattern in OPTIONAL MATCH references an already-bound
variable without adding new constraints (e.g., bare (n3) in OPTIONAL MATCH),
the binder creates a disconnected query graph. This graph was planned as a
full node-table scan, producing extra rows that doubled the cardinality.

Fix: in planQueryGraphCollection, skip query graphs that have no relationships
and whose nodes are all correlated (already bound in the outer plan). Their
correlated expressions are already captured via join conditions.

Fixes #697.
@adsharma
adsharma force-pushed the fix/issue-697-optional-match-double-cardinality branch from ce43bf1 to 4bc1c03 Compare July 18, 2026 18:02
@adsharma
adsharma merged commit e36c93e into main Jul 18, 2026
4 checks passed
@adsharma
adsharma deleted the fix/issue-697-optional-match-double-cardinality branch July 18, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Repeating a bound node in a comma-separated OPTIONAL MATCH doubles the result cardinality

1 participant