Problem
Avito built M42, a tool where product managers, marketers and analysts view any metric by dozens of dimensions without SQL. The semantic layer has more than 20,000 metrics and about 250 dimensions, with up to hundreds of thousands of values each. The main clickstream source gains about 45 billion rows a month, and a typical view is a 3-month or 1-year series. Computing on the fly would scan tens to hundreds of billions of rows and take hours, while the UI needs seconds. New dimensions keep appearing.
Example from the article: a slice is one combination such as (region='Moscow', category='Auto', platform='Android'), and users constantly filter reports by Moscow or Android.
Solution in brief
Precompute all metric and dimension combinations daily into one flat ClickHouse table, with one typed column per dimension instead of a JSON slice. Make the "any" value equal to each type's ClickHouse default (0, empty string), so a new dimension joins ORDER BY through a metadata-only ALTER without re-sorting the 9 TB table.
Questions this case answers
- How to serve an interactive metric explorer with arbitrary dimension filters within seconds when the raw event data is too large to aggregate at query time
- How to add a new dimension to a very large precomputed report table that uses a sorting key and deduplication, without rebuilding or copying the table
- How to let business users filter any metric by dozens of dimensions and get an answer in seconds when the raw data is tens of billions of rows a month?
- How to store precomputed metric values for billions of dimension combinations in ClickHouse without a JSON slice table?
Tools and methods
- ClickHouse — stores the report in
ReplicatedReplacingMergeTreefor fast reads and deduplication of recalculated rows - Trino — computes the SQL generated by the semantic layer
- Semantic layer (YAML configs) — defines sources, metrics and dimensions, and which metrics to compute in which dimensions
- Flat report table — one typed column per dimension, no slice table and no joins
Google or a one-time email code. No password.