DuckDB's compression knobs — 51 columns, and the engine won every one

**DuckDB 2.0 lets you write CREATE TABLE t (c VARCHAR USING COMPRESSION zstd). We tried to use it on every column we have. The engine's own choice beat us on all 51 of them.** Then we found the knob that does work, and it is not a codec — it is the unit of your timestamps.

What we wanted

Our event table has 56 columns: strings (paths, titles, referrers), UUIDs, timestamps, a handful of doubles, and some maps. We wanted to squeeze it, and DuckDB 2.0 has a per-column syntax that looks like exactly the right tool.

What the engine will actually write

The syntax is there. The list of what the engine accepts is much shorter:

typethe methods the engine will write
VARCHAR / BLOBuncompressed · zstd — only these two
TIMESTAMP / UUID / BIGINT / INTEGERuncompressed · constant · rle · bitpacking
DOUBLE / FLOATuncompressed · constant · rle · alp · alprd

dictionary / fsst / chimp / patas are refused: "deprecated and only has decompress support" — they can be read, not written.

DICT_FSST — the automatic choice you see in the docs — cannot be written by hand. The engine picks it; you cannot ask for it.

51 columns, 51 losses

We wrote every column into its own file, once per method, and measured.

columnthe engine's own choicethe best a knob can givethe gap
browser (VARCHAR)0.85 B/rowzstd 6.828.0×
country (VARCHAR)0.85 B/rowzstd 6.828.0×
url_path (VARCHAR)0.95 B/rowzstd 6.827.2×
session_id (BLOB)4.93 B/rowzstd 9.001.8×
created_at (TIMESTAMP)3.98 B/rowbitpacking 3.98even
session_start (TIMESTAMP)4.74 B/rowbitpacking 4.74even
visit_id (UUID)1.85 B/rowbitpacking 1.85even
event_id (UUID)1.16 B/rowbitpacking 1.16even

The explicit method never won once. (And zstd_min_string_length = 0 changes not one byte — when you force zstd, that threshold is not even looked at.)

The per-column compression knob is not a knob. It can only make things worse, or do nothing. The choice is the engine's, and it is a good one: its automatic pick on a string column is 8× smaller than the only alternative you may write.

The knob that does work: the unit

DuckDB's timestamp columns are bit-packed, and the width of a segment is the range inside it — so the unit is the lever, not the codec, and not the precision of the values.

2,767,665 rows:

columnshapeB/rowthe bits
created_atTIMESTAMP (microseconds)3.9831.8
created_atTIMESTAMP_MS2.6521.2
created_atTIMESTAMP_S1.149.1
created_atTIMESTAMP, values truncated to ms3.9831.8
created_atTIMESTAMP, values truncated to s3.9831.8
session_startTIMESTAMP (microseconds)4.7437.9
session_startTIMESTAMP_MS3.1325.0
session_startTIMESTAMP_S2.3718.9

Truncating the values saves nothing. Not to milliseconds, not to seconds — the width follows the range, not the jitter. only changing the unit saves anything. and it saves ten whole bits (microseconds to milliseconds). because that is a thousand-fold smaller interval.

TIMESTAMP_S is smaller still (9.1 bits) — but it throws the milliseconds away. We keep milliseconds, so TIMESTAMP_MS is the shape that fits that decision.

On the whole instance

The same traffic, the same write path:

on the diskreally useddead blocks
TIMESTAMP (microseconds)119.8 MB93.6 MB26.3 MB
TIMESTAMP_MS (milliseconds)108.8 MB84.9 MB23.9 MB

11.0 MB less on the disk (−9.2%), and the queries did not get slower (summary 67/70 ms against 66/62 ms, pages 7/7 against 7/6, sessions 25/24 against 24/22 — inside this machine's noise).

One correction

We had written down: "DuckDB's timestamp columns are fixed-width 8 bytes, so truncating to seconds does not change the width."

That is not true for DuckDB — they are bit-packed, the width is the range, and the unit is the lever. It is true for PostgreSQL and SQLite, which are fixed-width. The decision to keep milliseconds is unaffected: TIMESTAMP_MS is milliseconds. What changes is how it is stored — and it happens to line up with ClickHouse's DateTime64(3).

What we take away

  1. Do not fight the engine's compression choice. On 51 of 51 columns it was

the best available, and on a string column it was 8× better than the only alternative you are allowed to write.

  1. If your timestamps are big, change the unit, not the values. Truncating

the values buys exactly nothing; TIMESTAMP_MS against TIMESTAMP buys about a third of the column.

  1. **Check what the engine will actually write before you design around the

syntax.** dictionary, fsst, chimp and patas are read-only in 2.0.

Caveats

Our data (2,767,665 rows, 56 columns), DuckDB 2.0.1 on macOS/arm64, one machine. The methods we could write are the ones in the table above; we did not measure the read-only ones, because we cannot write them.

The numbers and the raw output are in the benchmarks folder of the public repository; the tools are private.

Sumimi / 数咪咪 is an independent open-source project. It is an open-source alternative to Umami and implements the Umami v2 HTTP API; no Umami assets are used. Licensed under the Apache-2.0 licence. Third-party names are referenced nominatively.