Skip to content

Query Optimization

Chunk Stats

When a chunk is frozen, the TSDB pre-computes min, max, sum, count. During query execution, aligned buckets can be answered from stats alone — no decompression needed. This can be 100× faster.

When a chunk is sealed, the TSDB pre-computes four statistics: minimum value, maximum value, sum of all values, and count of samples. These four numbers are enough to answer the most common queries — max(), min(), sum(), avg(), and rate() — without decompressing the chunk at all.

Decompressing a chunk takes CPU time and memory. For a query spanning 100 chunks, skipping even 80% of them makes the query ~5× faster.

① Dataset & Chunks

12 chunks of temperature data, 64 samples each. Chunk boundaries are marked with dashed lines.

② Chunk Timeline

Click any chunk to inspect its pre-computed stats.

③ Query Builder

Configure an aggregation query and watch the engine decide which chunks to decode.

12 chunks