You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data-modeling/projections/2_materialized-views-versus-projections.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,18 +47,15 @@ You should consider using materialized views when:
47
47
48
48
You should consider avoiding use of materialized views when:
49
49
50
-
-**High ingestion throughput is critical**: Especially for high-velocity streaming data with small, frequent batches, as synchronous materialized view updates can significantly degrade insert performance. This is because successive blocks of inserted data will have to wait until each materialized view is finished transforming the current blocks data for insertion into the materialized view's target table.
51
-
-**Source data is frequently updated or deleted**: Without additional strategies for handling consistency between the source and target tables, incremental materialized views will become stale and inconsistent.
50
+
-**Source data is frequently updated or deleted**: Without additional strategies for handling consistency between the source and target tables, incremental materialized views could become stale and inconsistent.
52
51
-**Simplicity and automatic optimization are preferred**: If you want to avoid managing separate target tables.
53
52
54
53
### When to choose projections {#choosing-projections}
55
54
56
55
You should consider using projections when:
57
56
58
-
-**Optimizing queries for a single table**: Your primary goal is to accelerate queries on a single base table by providing alternative sorting orders, optimizing filters on columns which are not part of the primary-key, or pre-computing aggregations for a single table.
59
-
- You want **query transparency**: You want queries to target the original table without modification, relying on ClickHouse to pick the best data layout for a given query.
60
-
-**High ingestion throughput is a priority**: Projections' asynchronous updates generally have less direct impact on write performance compared to materialized views.
61
-
-**Data is predominantly append-only or immutably managed**: or if your `DELETE` strategy can effectively leverage the `lightweight_mutation_projection_mode` (v24.7+)
57
+
-**Optimizing queries for a single table**: Your primary goal is to speed up queries on a single base table by providing alternative sorting orders, optimizing filters on columns which are not part of the primary-key, or pre-computing aggregations for a single table.
58
+
- You want **query transparency**: you want queries to target the original table without modification, relying on ClickHouse to pick the best data layout for a given query.
62
59
63
60
### When to avoid projections {#avoid-projections}
64
61
@@ -68,19 +65,20 @@ You should consider avoiding use of projections when:
68
65
-**Explicit filtering of materialized data is needed**: Projections do not support `WHERE` clauses in their definition to filter the data that gets materialized into the projection itself.
69
66
-**Non-MergeTree table engines are used**: Projections are exclusively available for tables using the `MergeTree` family of engines.
70
67
-`FINAL` queries are essential: Projections do not work with `FINAL` queries, which are sometimes used for deduplication.
68
+
- Working with large tables that grow quickly:
71
69
72
70
## Summary {#summary}
73
71
74
72
Materialized views and projections are both powerful tools in your toolkit for
75
73
optimizing queries and transforming data, and in general, we recommend not to view
76
-
using them as an either/or choice. Instead, they can be used together to get the
77
-
most out of your queries. As such, the choice between materialized views and
78
-
projections in ClickHouse really depends on your specific use case and access
79
-
patterns.
74
+
using them as an either/or choice. Instead, they can be used in a complementary
75
+
manner to get the most out of your queries. As such, the choice between materialized
76
+
views and projections in ClickHouse really depends on your specific use case and
77
+
access patterns.
80
78
81
79
As a general rule of thumb, you should consider using materialized views when
82
80
you need to aggregate data from one or more source tables into a target table or
83
-
perform complex transformations. Materialized views are excellent for shifting
81
+
perform complex transformations at scale. Materialized views are excellent for shifting
84
82
the work of expensive aggregations from query time to insert time. They are a
85
83
great choice for daily or monthly rollups, real-time dashboards or data summaries.
0 commit comments