Skip to content

How writers choose a codec

A writer picks, per stream, the smallest candidate encoding. Some codecs are only tried when the data suggests they will pay:

Codec Tried only when
Integer DICT and Bytes DICT at least 4 values and at most n/2 distinct values (integer DICT also needs at least 2)
RLE at most n/3 runs. In streams that need random access it must also be less than half the size of the best alternative
DELTA not in random-access streams (timestamps, row tags, byte lengths and key lengths)
PATCHED at least 16 values
FRONT at least 4 values and more shared bytes than values
ALP fewer than n/4 exceptions
FSST at least 16 values, at least 2 KiB of data, and the best other encoding larger than half the raw data. When that encoding is at least 4 KiB, FSST must also beat it by at least 5 percent after zstd level 1

All other codecs are plain candidates for the smallest-wins choice. Streams with fewer than 4 values use only PLAIN (bytes) or CONST and FOR (integers). A writer emits FSST only in columnar block revision 3 or later, see columnar revision 3.

The frame codec policy is part of the same writer behaviour: compressed output is kept only if packed + packed/8 < raw, the default is zstd level 1, files at LSM levels 0 and 1 (not cold, not bottom) use LZ4 and the cold layer uses zstd level 9. The details are on zstd and LZ4 framing.