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
| Data storage and location | Store their results in a **separate, explicit target table**on insert to a source table, acting as insert triggers. | Projections create optimized data layouts that are physically **stored alongside the main table data** and are invisible to the user. |
19
+
| Data storage and location | Store their results in a **separate, explicit target table**, acting as insert triggers, on insert to a source table.| Projections create optimized data layouts that are physically **stored alongside the main table data** and are invisible to the user. |
22
20
| Update mechanism | Operate **synchronously** on `INSERT` to the source table (for incremental materialized views). Note: they can also be **scheduled** using refreshable materialized views. |**Asynchronous** updates in the background upon `INSERT` to the main table. |
23
21
| Query interaction | Working with Materialized Views requires querying the **target table directly**, meaning that users need to be aware of the existence of materialized views when writing queries. | Projections are **automatically selected** by ClickHouse's query optimizer, and are transparent in the sense that the user does not have to modify their queries to the table with the projection in order to utilise it. From version 25.6 it is also possible to filter by more than one projection. |
24
-
| Handling `UPDATE` / `DELETE`|**Do not automatically react** to `UPDATE` or `DELETE` operations on the source table as materialized views have no knowledge of the source table, acting only as insert triggers _to_ a source table. This can lead to potential data staleness between source and target tables and requires workarounds or periodic full refresh. (via Refreshable materialized view). | By default, are **incompatible with `DELETED` rows** (especially lightweight deletes). `lightweight_mutation_projection_mode` (v24.7+) can enable compatibility. |
22
+
| Handling `UPDATE` / `DELETE`|**Do not automatically react** to `UPDATE` or `DELETE` operations on the source table as materialized views have no knowledge of the source table, acting only as insert triggers _to_ a source table. This can lead to potential data staleness between source and target tables and requires workarounds or periodic full refresh. (via refreshable materialized view). | By default, are **incompatible with `DELETED` rows** (especially lightweight deletes). `lightweight_mutation_projection_mode` (v24.7+) can enable compatibility. |
25
23
|`JOIN` support | Yes. Refreshable materialized views can be used for complex denormalization. Incremental materialized views only trigger on left-most table inserts. | No. `JOIN` operations are not supported within projection definitions for filtering the materialised data. |
26
24
|`WHERE` clause in definition | Yes. `WHERE` clauses can be included to filter data before materialization. | No. `WHERE` clauses are not supported within projection definitions for filtering the materialized data. |
27
25
| Chaining capabilities | Yes, the target table of one materialized view can be the source for another materialized view, enabling multi-stage pipelines. | No. Projections cannot be chained. |
@@ -41,7 +39,6 @@ You should consider using materialized views when:
41
39
- You require **complex denormalization**: You need to pre-join data from several sources (tables, subqueries or dictionaries) into a single, query-optimized table, especially if periodic full refreshes with the use of refreshable materialized views are acceptable.
42
40
- You want **explicit schema control**: You require a separate, distinct target table with its own schema and engine for the pre-computed results, offering greater flexibility for data modelling.
43
41
- You want to **filter at ingestion**: You need to filter data _before_ it's materialized, reducing the volume of data written to the target table.
44
-
- When working with large tables
45
42
46
43
### When to avoid materialized views {#avoid-materialized-views}
47
44
@@ -59,7 +56,7 @@ You should consider using projections when:
59
56
60
57
### When to avoid projections {#avoid-projections}
61
58
62
-
You should consider avoiding use of projections when:
59
+
You should consider avoiding the use of projections when:
63
60
64
61
-**Complex data transformation or multi-stage ETL are required**: Projections do not support `JOIN` operations within their definitions, cannot be changed to build multi-step pipelines and cannot handle some SQL features like window functions or complex `CASE` statements. As such they are not suited for complex data transformation.
65
62
-**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.
0 commit comments