Unlock this content

Enter your email to unlock this content for free

By continuing, you agree to our Terms of Service and Privacy Notice, and to receive occasional marketing emails.

AggregatingMergeTree

TL;DR

AggregatingMergeTree stores aggregate function states (not final values) that merge incrementally. Use *State() functions when inserting and *Merge() functions when querying. Usually combined with materialized views.

How It Works

AggregatingMergeTree stores intermediate aggregate states (not final values) that merge incrementally during background merges and at query time. Use AggregateFunction types to define which aggregations to store.

-- Source table: raw session data CREATE TABLE hits ( user_id UInt64, duration UInt64 ) ENGINE = MergeTree() ORDER BY user_id;

Tinybird is not affiliated with, associated with, or sponsored by ClickHouse, Inc. ClickHouse® is a registered trademark of ClickHouse, Inc.

AggregatingMergeTree | ClickHouse for Developers