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.

ReplacingMergeTree

TL;DR

ReplacingMergeTree deduplicates rows by keeping the latest version based on a version column. Deduplication happens during background merges. Use FINAL at query time to force deduplication, but it has a performance cost.

How It Works

ReplacingMergeTree deduplicates rows based on the sorting key. When multiple rows have the same sorting key values, it keeps the one with the highest version column value.

CREATE TABLE users ( id UInt64, name String, updated_at DateTime ) ENGINE = ReplacingMergeTree(updated_at) ORDER BY id;

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

ReplacingMergeTree | ClickHouse for Developers