Tables that forget: retention by age, size or row count over immutable Parquet files
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.5.5 | 1.5.6 | 2.0.0 | 2.0.1 |
|---|---|---|---|---|
| Linux AMD64 | ||||
| Linux ARM64 | ||||
| macOS AMD64 | ||||
| macOS ARM64 | ||||
| Windows AMD64 | ||||
| Windows ARM64 | ||||
| WebAssembly |
Installing and Loading
INSTALL capped FROM community;
LOAD capped;
Example
INSTALL capped FROM community;
LOAD capped;
ATTACH 'telemetry-store' AS t (TYPE capped);
CREATE TABLE t.main.events(ts TIMESTAMPTZ, severity VARCHAR, body VARCHAR) WITH (time_col = 'ts', ttl = '7 days', max_bytes = '1GB');
INSERT INTO t.main.events VALUES (now(), 'info', 'hello capped');
SELECT severity, body FROM t.main.events;
About capped
capped gives DuckDB tables that forget. You set a limit on each table when
you create it: how old rows may get (ttl), how big the table may grow
(max_bytes), or how many rows it may hold (max_rows). New rows keep
coming in, and the oldest data is removed whenever a limit is passed.
It is built for telemetry such as logs, traces, metrics and events, where nobody needs last month's data and nobody wants to schedule cleanup jobs.
Each table is stored as a series of immutable Parquet files. Removing old data means deleting whole files, so nothing is rewritten, no space is left behind, and size limits are exact. Queries go through DuckDB's own Parquet reader, so filters and pushdown work as usual.
Retention runs when a store is attached, on every write, and on a
background thread. Tables can also opt in to full-text and vector search
(capped_fts, capped_vector_search), and the indexes are removed along
with the data they cover.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| capped_add_segment | table | NULL | NULL | |
| capped_enforce | table | NULL | NULL | |
| capped_fts | table | NULL | NULL | |
| capped_index | table | NULL | NULL | |
| capped_seal | table | NULL | NULL | |
| capped_status | table | NULL | NULL | |
| capped_tables | table | NULL | NULL | |
| capped_vector_search | table | NULL | NULL | |
| capped_version | scalar | NULL | NULL |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases | typed_value |
|---|---|---|---|---|---|
| capped_pending_delete_grace | capped: grace for orphan-GC candidates and newly queued pending deletes (duration, default 5 min) | VARCHAR | GLOBAL | [] | 5 min |
| temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |