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.
④ Query Execution
⑤ Results
⑥ Skip Logic
How the engine decides whether to decode or skip each chunk:
max
If chunk.max ≤ running_max → skip. The chunk can't improve the answer.
min
If chunk.min ≥ running_min → skip. The chunk can't lower the answer.
sum
If bucket aligns with chunk → use chunk.sum directly. No decode needed.
avg
If aligned → compute chunk.sum / chunk.count. Both are pre-computed.