Expand description
Hypertable chunk pruning for the SELECT planner.
Phase 0 of PRD #850 — activate the dormant partition-pruning
primitive for hypertables. The machinery already exists
(super::partition_pruning + the per-chunk time bounds tracked by
HypertableRegistry)
but nothing in the SELECT path consulted it, so every query against a
hypertable scanned every chunk.
This module is the bridge: given a hypertable’s spec, its chunk set,
and the SELECT WHERE clause, it returns only the chunks whose
declared [start_ns, end_ns) interval can contain a row the temporal
predicate admits. Chunks proven disjoint from the predicate window are
dropped; everything else is kept.
Soundness contract — the pruner never drops a chunk that could
hold a matching row. A row in chunk C carries a timestamp inside
[C.start_ns, C.end_ns_exclusive); if any timestamp in that interval
satisfies the predicate, C is kept. When the WHERE clause does not
constrain the time column (or uses a shape the lowering can’t reason
about), the pruner is conservative and keeps every chunk — exactly the
Timescale / Postgres contract.
Functions§
- kept_
scan_ bounds - Smallest
[lo, hi)nanosecond window that contains every kept chunk’s declared interval, orNonewhenkeptis empty. - prune_
hypertable_ chunks - Return the subset of
chunksthat may contain a row matchingfilter’s temporal predicate.