Scale the Parquet read path to 100k–1M rows and many parts #10

Open
opened 2026-10-21 12:53:51 +00:00 by aleksei · 0 comments
Owner

Context

The Parquet Arrow fast path (#9) evaluates raw non-string queries on RecordBatches and only materialises the returned page. At 10k rows this is already faster than ClickHouse, but the current implementation still:

  • reads every visible part sequentially (store::read_batches);
  • keeps all batches of every part in memory;
  • filters every batch and concatenates all survivors into one RecordBatch;
  • sorts the whole survivor set with lexsort_to_indices (top-k only limits the index array, not the concatenated input);
  • reads every projected column, even when the query only needs a few.

At 100k–1M rows and up to 64 parts this becomes slow and memory-heavy: the peak is the full filtered set plus the concatenation, and parts are scanned one at a time.

Scope

1. Projection pushdown

Derive the required columns from the filter, sort, include/exclude and transform keys, and pass a ProjectionMask to ParquetRecordBatchReaderBuilder. Do not read a column that is neither filtered, sorted, grouped nor returned. Preserve the current batch_to_rows output shape (projection still happens at the JSON boundary).

2. Parallel part reads

Read parts concurrently with bounded parallelism (a fixed worker count, e.g. the available parallelism or a configurable constant), preserving deterministic part order for ties. Bound the in-flight memory: do not read all parts at once when the table is large. Use the existing blocking pool (spawn_blocking/rayon) and keep the async runtime responsive.

3. Streaming top-k

Avoid concatenating every filtered row. Keep only the candidates needed for offset + limit across batches/parts (a bounded heap or a merge of per-part top-k results), while still counting the exact total from the filter masks. Return the same stable order: sort fields in order, original row index as the final tie-break, nulls last in both directions.

4. Row-group pruning

Use Parquet column statistics (min/max, null counts) for supported predicates to skip part files and row groups that cannot match:

  • numeric/date Eq, In, Lt, Le, Gt, Ge;
  • conservative fallback when statistics are missing or the predicate is not understood;
  • no false negatives: a row group may only be skipped when the predicate is provably false for every row.

Report skipped parts/row groups through tracing at debug level.

Acceptance criteria

  • Existing query semantics and fallback behaviour are unchanged; all existing eve_e2e/tests/tsdb tests pass.
  • New tsdb benchmark cases at 100k and 1M rows with 1 and 64 parts, including a wide entity (include a subset of columns) and a selective filter; document before/after latency and peak memory.
  • Peak memory does not grow proportionally to the number of parts when limit is small.
  • Parallelism is bounded and configurable; deterministic result order is preserved.
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p eve_tsdb_parquet, cargo test -p eve_e2e --test tsdb --test app pass.
  • adr/parquet.md documents projection pushdown, bounded parallel reads, streaming top-k and pruning.

Non-goals

  • String/regex filters and transforms (they keep the row-evaluator fallback).
  • Changing the on-disk format, manifest or public API.
  • Distributed execution; this is still the local single-process profile.
## Context The Parquet Arrow fast path (#9) evaluates raw non-string queries on `RecordBatch`es and only materialises the returned page. At 10k rows this is already faster than ClickHouse, but the current implementation still: - reads every visible part sequentially (`store::read_batches`); - keeps all batches of every part in memory; - filters every batch and concatenates all survivors into one `RecordBatch`; - sorts the whole survivor set with `lexsort_to_indices` (top-k only limits the index array, not the concatenated input); - reads every projected column, even when the query only needs a few. At 100k–1M rows and up to 64 parts this becomes slow and memory-heavy: the peak is the full filtered set plus the concatenation, and parts are scanned one at a time. ## Scope ### 1. Projection pushdown Derive the required columns from the filter, sort, `include`/`exclude` and transform keys, and pass a `ProjectionMask` to `ParquetRecordBatchReaderBuilder`. Do not read a column that is neither filtered, sorted, grouped nor returned. Preserve the current `batch_to_rows` output shape (projection still happens at the JSON boundary). ### 2. Parallel part reads Read parts concurrently with bounded parallelism (a fixed worker count, e.g. the available parallelism or a configurable constant), preserving deterministic part order for ties. Bound the in-flight memory: do not read all parts at once when the table is large. Use the existing blocking pool (`spawn_blocking`/rayon) and keep the async runtime responsive. ### 3. Streaming top-k Avoid concatenating every filtered row. Keep only the candidates needed for `offset + limit` across batches/parts (a bounded heap or a merge of per-part top-k results), while still counting the exact `total` from the filter masks. Return the same stable order: sort fields in order, original row index as the final tie-break, nulls last in both directions. ### 4. Row-group pruning Use Parquet column statistics (min/max, null counts) for supported predicates to skip part files and row groups that cannot match: - numeric/date `Eq`, `In`, `Lt`, `Le`, `Gt`, `Ge`; - conservative fallback when statistics are missing or the predicate is not understood; - no false negatives: a row group may only be skipped when the predicate is provably false for every row. Report skipped parts/row groups through `tracing` at debug level. ## Acceptance criteria - Existing query semantics and fallback behaviour are unchanged; all existing `eve_e2e/tests/tsdb` tests pass. - New `tsdb` benchmark cases at 100k and 1M rows with 1 and 64 parts, including a wide entity (`include` a subset of columns) and a selective filter; document before/after latency and peak memory. - Peak memory does not grow proportionally to the number of parts when `limit` is small. - Parallelism is bounded and configurable; deterministic result order is preserved. - `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test -p eve_tsdb_parquet`, `cargo test -p eve_e2e --test tsdb --test app` pass. - `adr/parquet.md` documents projection pushdown, bounded parallel reads, streaming top-k and pruning. ## Non-goals - String/regex filters and transforms (they keep the row-evaluator fallback). - Changing the on-disk format, manifest or public API. - Distributed execution; this is still the local single-process profile.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zoo/eve#10
No description provided.