Sync main with release#213
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-generated by the sync branches workflow.