Remember
Purpose
Materialize the results of a streaming-compatible QUERY under a durable alias so future readers can replay the stored snapshot without re-scanning the cluster.
Form
REMEMBER QUERY <query-expr> AS <name>
<query-expr>must be a plainQUERYcommand that already works at the shell prompt.<name>becomes the filename-friendly alias used undermaterializations/<name>/.
Constraints
- Aliases may contain ASCII letters, digits,
_, and-only. - Only selection queries without aggregates, grouping, or event sequences can be remembered (the same restriction as streaming queries).
- The first run performs a full scan; ensure the backend has enough disk for the snapshot.
Behavior
- The query plan is compiled and executed once through the streaming pipeline.
- Batches are persisted to
materializations/<name>/frames/NNNNNN.matusing the same column ordering and types as the live query. - A catalog entry (
materializations/catalog.bin) records:- Canonical query hash and serialized query spec.
- Stored schema snapshot.
- Current row and byte totals.
- High-water mark (timestamp + event_id) used for future incremental refreshes.
- Last append deltas (rows/bytes) and timestamps.
- Optional retention policy placeholder (future feature).
- A short summary (rows stored, bytes, watermark age) is returned to the caller.
Retention
Each remembered query can optionally track a retention policy (max rows or max age). Policies are recorded in the catalog for future use; the current implementation records the fields and prunes frames when they are set programmatically.
Diagnostics & Telemetry
- Successful runs log a
sneldb::rememberevent with alias, total rows, rows appended, and watermark details. - You can inspect
materializations/catalog.bin(bincode + JSON-encoded spec) to review metadata, or issueSHOW <name>to fetch both the stored snapshot and the latest delta.
Errors
- Alias already exists.
- Query is not streaming-compatible.
- Engine is unable to write the materialization directory (disk full / permission).
- Catalog persistence failure (corrupted header or serialization error).