The unit of a timestamp is the lever, not its precision

Truncating a timestamp to milliseconds saves not one byte. Changing its unit to milliseconds saves a third of the column. The difference is what bit-packing measures.

The principle

DuckDB's timestamps are bit-packed, and the width of a segment is the range inside it — not the jitter, and not the precision of the values.

So truncating the values buys nothing: a value that is already millisecond-precise does not narrow the range. Changing the unit does: microseconds to milliseconds is a thousand-fold smaller interval, and it takes ten whole bits off the width.

The number

the columnthe shapebytes a rowthe bits
created_atTIMESTAMP (microseconds)3.9831.8
created_atTIMESTAMP_MS2.6521.2
created_atTIMESTAMP, values truncated to ms3.9831.8
session_startTIMESTAMP (microseconds)4.7437.9
session_startTIMESTAMP_MS3.1325.0

On the whole instance that is −9.2% on the disk, with the query times unchanged.

And the other half

The per-column compression knobs are not a lever: we tried them on all 51 columns we could measure, and the engine's own choice won every one of them — on a string column it was 8× smaller than the only alternative we were allowed to write.

The experiment report has the whole table, including the methods the engine refuses to write.

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.