Repository navigation
Intersect index ranges and union disjunctions in the planner - #26
Merged
Merged
Conversation
The planner used a single access path per MATCH. It now also costs intersections over the cheapest exact paths for AND, and a union when every operand of an OR has its own path. Candidates carry the conjuncts they consume, so only the rest are verified row by row.
venkat1701
force-pushed
the
feat/planner-index-intersection
branch
from
October 4, 2026 08:25
859c6d0 to
04bf764
Compare
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.
Closes #12
The planner picked one access path per MATCH and checked everything else row by row. It now has two composite paths:
CONTAINS,IN, an atom equality) are sorted by estimated rows, and every prefix of two to four becomes a candidate. Each part is scanned into a sorted id array and merge-intersected. Rows are estimated asrows1 * product(rows_i / population). Cost is the sum of the part scans plus verifying whatever wasn't consumed.ORis consumed and not verified again.Candidates now carry the list of conjuncts they consume, rather than a single optional source, so the residual filter is just the conjuncts nobody consumed.
The cost model is unchanged, which means intersection only wins when it actually should. Scanning a second index costs about as much per row as verifying a row, plus a fixed per-scan overhead, so on small data a single selective index still wins. That's why the test builds 4,000 items: two colours and two shapes split evenly, so each predicate matches 2,000 rows and the pair matches 1,000.
broadPredicatesAreIntersectedAndDisjunctionsUnionedinQueryLanguageTestchecks:Intersect[...]for the AND, andUnion[...]with no Verify step for the OR.Full
./mvnw installpasses locally and every commit compiles on its own.