Skip to content

Sync main with release#213

Merged
conradbzura merged 6 commits into
mainfrom
release
Jul 9, 2026
Merged

Sync main with release#213
conradbzura merged 6 commits into
mainfrom
release

Conversation

@conradbzura

Copy link
Copy Markdown
Collaborator

Auto-generated by the sync branches workflow.

conradbzura and others added 6 commits July 8, 2026 18:33
The idiomatic per-interval overlap count -- SELECT a.cols, COUNT(b.col)
FROM a LEFT JOIN b ON a.interval INTERSECTS b.interval GROUP BY a.cols --
declined to the naive plan like every outer join, becoming a HASH_JOIN on
the low-cardinality chromosome key with the position inequalities as a
residual filter (quadratic; ~180x slower than achievable at scale).

Detect this shape and reuse the INNER IEJoin path (which already plans
COUNT + GROUP BY through IE_JOIN), then wrap its counts in a zero-fill
LEFT join back onto the distinct left keys so left intervals with no
overlap report 0. Supports a single COUNT(<right column>) /
COUNT(DISTINCT <right column>) with a GROUP BY on the projected left
columns; COUNT(*), non-COUNT aggregates, ORDER BY / LIMIT / HAVING, and
other outer-join shapes still take the naive-predicate plan.

Claude-Session: https://claude.ai/code/session_01TERWBHov76DQM3nQeT8yyy
Add shape, decline (COUNT(*), non-COUNT aggregate, no GROUP BY, ORDER BY,
self-join), a Hypothesis property test against a Python count_overlaps
reference (zero-overlap rows, one-sided chromosomes, empty right table,
duplicate left rows), and an EXPLAIN plan guard asserting the generated
inner SQL is not planned as a BLOCKWISE_NL_JOIN.

Claude-Session: https://claude.ai/code/session_01TERWBHov76DQM3nQeT8yyy
Describe the LEFT-join COUNT over INTERSECTS routing through the INNER
IE_JOIN count plus a zero-fill LEFT join, and the shapes that remain on
the naive-predicate plan.

Claude-Session: https://claude.ai/code/session_01TERWBHov76DQM3nQeT8yyy
Tighten the count_overlaps detection gate for two shapes a review found
producing wrong results on matched queries: a GROUP BY carrying keys
beyond the projected columns (the extra key inflates the count cardinality
and drops zero-count rows the zero-fill base cannot reproduce), and a
projected key whose output name collides with the COUNT alias (the
zero-fill USING / COALESCE binds to the wrong duplicately-named column).
Require the group keys to equal the projected keys exactly and all output
names to be distinct, declining to the naive plan otherwise.

Claude-Session: https://claude.ai/code/session_01TERWBHov76DQM3nQeT8yyy
Add decline tests for a GROUP BY exceeding the projection, an output-name
collision between a key and the COUNT alias, and a top-level WHERE, plus a
COUNT(DISTINCT b.col) execution test asserting equivalence with the naive
plan.

Claude-Session: https://claude.ai/code/session_01TERWBHov76DQM3nQeT8yyy
@conradbzura conradbzura merged commit dbc3ea2 into main Jul 9, 2026
1 of 3 checks passed
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.

1 participant