
Unlock this content
Enter your email to unlock this content for free
SummingMergeTree
TL;DR
SummingMergeTree automatically sums numeric columns during merges, pre-aggregating counters and metrics. Put all dimension columns in the sorting key. Use GROUP BY in queries for reliable aggregation.
How It Works
SummingMergeTree automatically sums numeric columns during merges, using the sorting key as the group key. All numeric columns are summed for each unique combination of sorting key values.
CREATE TABLE page_views (
date Date,
user_id UInt64,
views UInt64
) ENGINE = SummingMergeTree()
ORDER BY (date, user_id);