
Unlock this content
Enter your email to unlock this content for free
Tinybird is not affiliated with, associated with, or sponsored by ClickHouse, Inc. ClickHouse® is a registered trademark of ClickHouse, Inc.
Optimizing a Project with Materialized Views
To optimize a project with materialized views, identify slow aggregation queries and create materialized views using AggregatingMergeTree. Use *State() functions in the materialized view and *Merge() functions at query time. The performance improvement can be dramatic: reading thousands of pre-aggregated rows instead of billions of rows from the source table.
Example: calculate the count of events per action type from the analytics events table.
The Problem: Slow Aggregation Queries
Original query:
SELECT count()
FROM analytics_events
GROUP BY action