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.

When to Use Matviews

TL;DR

Materialized views solve three main use cases: data transformation (ELT pattern), aggregation for faster queries, and handling historical data. The main use case is aggregation. Use AggregatingMergeTree with AggregateFunction types for complex aggregations (averages, unique counts) or SummingMergeTree with SimpleAggregateFunction for simple sums. Materialized views only process new data; historical data requires backfilling.

Materialized views are insert triggers that transform and aggregate data as it arrives. They solve three main use cases: data transformation, aggregation, and historical data handling.


Use Case 1: Data Transformation (ELT)

Materialized views help transform data following the Extract, Load, Transform (ELT) pattern. Common tasks include parsing logs, processing JSON strings, filtering data, and routing data to different tables.

Example: Filter and Extract from JSON

-- Source datasource: analytics_events.datasource

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

When to Use Matviews | ClickHouse for Developers