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.

MergeTree

TL;DR

MergeTree stores data in immutable parts with partitions and sorting keys. Background merges optimize reads. Choosing the right partition key (1-300 GB per partition) and sorting key (filtering columns first) is critical for performance.

How MergeTree Works

MergeTree stores data in parts on disk. Each insert creates new parts, and a background process periodically merges smaller parts into bigger parts for more efficient reads.

CREATE TABLE events ( event_date Date, user_id UInt64, event_type String ) ENGINE = MergeTree()

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

MergeTree | ClickHouse for Developers