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.

How Matviews Work

TL;DR

Materialized views are insert triggers that process data in blocks. Each block inserted into the source table triggers the materialized view query, which only sees that block (not historical data). Results are written as separate parts that ClickHouse merges in the background. With AggregatingMergeTree, merges aggregate data based on the sorting key.

Example: tracking sales by product.

Source datasource (datasources/sales.datasource):

DESCRIPTION > Sales events datasource SCHEMA > `product_id` String `json:$.product_id`, `quantity` UInt32 `json:$.quantity`, `timestamp` DateTime `json:$.timestamp`

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

How Matviews Work | ClickHouse for Developers