Description: i wear this chaos well
9 minute read Published: 2024-12-15 ClickHouse is a fairly impressive columnar database. It's super efficient and highly performant and has some really impressive features. The use of MATERIALIZED VIEWS , which traditional RDBMS folks would call INSERT TRIGGERS allow you to chain inserts and aggregate data into other tables. This is incredibly handy. There are a lot of tutorials talking about using AggregatingMergeTree tables as the destination for rollup style views of your raw data.
A common use case for this pattern is to transform an event stream into a pre-rendered timeseries table. When using AggregatingMergeTree tables, you can aggregate statistics into buckets and store the state of the aggregations. Aggregation states can be simple, like for min() or max() , or complex, like in the case of uniq() . In testing, uniqState() storage often crept up to ~50% of the storage space required to store the raw documents from the source table. Worse, performance using uniqMerge() against the
In this article, we'll explore a few different ways to work-around this issue and do something cool!