Skip to content

perf: LIKE/GLOB prefix range, BETWEEN single-range, and IN-list index optimizations #606

Description

@iheitlager

Summary

Carried forward from #527 (epic #421, closed without full completion).
Verified via codebase search: LIKE/GLOB prefix-to-index-range rewriting has
zero matches anywhere in src/. BETWEEN handling exists in expression
codegen (src/codegen/select/aggregate.rs, src/codegen/select/join_order.rs)
but it's unconfirmed whether it collapses to a single index range seek
versus two separate constraints. IN-list-to-multiple-index-seeks is also
unverified.

Techniques

Technique Description Priority
LIKE/GLOB prefix LIKE 'foo%' → index range >= 'foo' AND < 'fop' High
BETWEEN → range x BETWEEN 5 AND 10x >= 5 AND x <= 10 with single index seek Medium
IN list optimization x IN (1,2,3) → multiple index seeks Medium

Acceptance criteria

  • EXPLAIN QUERY PLAN shows index usage for LIKE 'prefix%'
  • BETWEEN uses a single index range seek, not two separate constraints
  • x IN (...) against an indexed column uses one seek per value, not a
    full scan
  • Benchmark shows improvement for pattern-matching and range queries

Complexity

Estimate: medium
Reasoning: LIKE prefix extraction needs a literal-prefix analysis of the
pattern (bail out on leading wildcard/escape edge cases) plus wiring into
the planner's range-constraint machinery — new code path. BETWEEN/IN need
verification first (may already partially work) and then closing gaps in
src/planner.rs / index-seek codegen if they don't collapse as expected.

Refs: #527

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance workv8V8 — Integrity & Triggers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions