1. Delta then ZSTD
Delta stores differences between consecutive values, then ZSTD compresses the small deltas.
CODEC(Delta, ZSTD)Typorithm · medium
Step 1 of 8 · intro card
Scale & Ops
Per-column CODEC choices: Delta/DoubleDelta for sequences, T64/Gorilla for floats, then ZSTD or LZ4 as the final compressor.
Each column can declare its own CODEC, a chain where an encoding transform precedes a general-purpose compressor.
Delta and DoubleDelta shrink monotonic sequences like timestamps and counters by storing differences instead of raw values.
Gorilla and T64 target floating-point series, and the chain ends with a general compressor — ZSTD for ratio, LZ4 for speed.
Delta/DoubleDelta for monotonic sequences.
Gorilla/T64 for floating-point series.
End the chain with ZSTD or LZ4.
CREATE TABLE metrics
(
ts DateTime CODEC(Delta, ZSTD),
seq UInt64 CODEC(DoubleDelta, ZSTD),
latency Float64 CODEC(Gorilla, ZSTD),
payload String CODEC(ZSTD(3))
)
ENGINE = MergeTree
ORDER BY (ts);Connect each part of the code to the concept before you type.
Delta stores differences between consecutive values, then ZSTD compresses the small deltas.
CODEC(Delta, ZSTD)DoubleDelta suits monotonic sequences whose gaps are near-constant, like counters.
CODEC(DoubleDelta, ZSTD)Gorilla (and T64) target floating-point series that drift slowly over time.
CODEC(Gorilla, ZSTD)ZSTD(3) sets a higher compression level for the general-purpose final stage.
CODEC(ZSTD(3))Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.