Materialized Views: The Double-Edged Sword
This guide is part of a collection of findings gained from community meetups. For more real world solutions and insights you can browse by specific problem. Too many parts bogging your database down? Check out the Too Many Parts community insights guide. Learn more about Materialized Views.
The 10x Storage Anti-Pattern
Real production problem: "We had a materialized view... the raw log table was around 20 gig but the view from that log table got exploded to 190 gig so almost 10x the size of the raw table... this happened because... we were creating one row per attribute and each log can have 10 attributes"
Rule: If your GROUP BY creates more rows than it eliminates, you're building an expensive index, not a materialized view.
Production MV Health Validation
The Successful MV Patterns
When MVs Become a Problem
Common mistake: Teams create too many materialized views and hurt insert performance.
Simple fix: Replace non-critical MVs with regular tables populated by cron jobs. You get the same query benefits without slowing down inserts.
Which MVs to remove: Start with redundant time windows (like 2-hour aggregations when you already have 1-hour) and low-frequency queries.
Video Sources
- ClickHouse at CommonRoom - Kirill Sapchuk - Source of the "over enthusiastic about materialized views" and "20GB→190GB explosion" case study