Skip to content

[core] Use a single BTree scan for bounded range predicates - #9844

Draft
jerry-024 wants to merge 2 commits into
apache:masterfrom
jerry-024:optimize-btree-bounded-range
Draft

jerry-024 wants to merge 2 commits into
apache:masterfrom
jerry-024:optimize-btree-bounded-range

Conversation

@jerry-024

@jerry-024 jerry-024 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

A filter such as duration >= 30 AND duration < 120 currently evaluates the two BTree predicates separately, scans both half-ranges, and intersects their candidate row IDs. This can make index lookup expensive even when the final range is selective.

Combine lower and upper bounds on the same field under AND into one bounded BTree scan. Forward the combined range through the union and row-ID offset readers, reuse existing index-file pruning, and preserve inclusive/exclusive endpoints. Other index readers retain the default evaluation of supported bounds.

Tests

  • Verify one bounded query on the real BTree reader, with no separate lower/upper queries; reversed ranges are pruned without querying the BTree reader.
  • Cover 12 data types, all endpoint combinations, equal/reversed bounds, both predicate orders, null exclusion, and row-ID offsets through union/offset wrappers.
  • Verify partial-support fallback and that predicates across OR or different fields are not fused; run existing BTree and bitmap table regression tests.

@jerry-024 jerry-024 changed the title [core] Fuse bounded BTree range predicates into one scan [core] Use a single BTree scan for bounded range predicates Sep 15, 2026
@jerry-024
jerry-024 marked this pull request as draft September 15, 2026 09:41
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