Adding to the above, can do one small validation before deciding between MV and a custom Delta/MERGE solution.
Databricks now lets you check whether the MV query is structurally eligible for incremental refresh:
EXPLAIN CREATE MATERIALIZED VIEW mv_orders AS
SELECT ...
That output can tell you whether the query is incrementally refreshable and which part of the query may prevent it. check this.
Also do check the source Delta tables. For the best incremental refresh behaviour, Databricks recommends row tracking, deletion vectors, and change data feed where applicable. For example:
ALTER TABLE orders SET TBLPROPERTIES (
delta.enableDeletionVectors = true,
delta.enableRowTracking = true,
delta.enableChangeDataFeed = true
)
Then create the MV and test a few realistic refreshes:
- small batch of new orders
- updates to recent orders
- a larger batch of changes
Under the default AUTO refresh policy, it does not guarantee every refresh will be incremental. It can still choose a full recompute if its cost model thinks that is cheaper.
For this workload, it gives you a clear plan after validating above:
- MV incremental most of the time โ probably keep the MV.
- MV repeatedly falls back to full refresh and refresh cost matters โ then consider custom incremental Delta/MERGE logic.
For this workload, where the same expensive transformation is reused by multiple downstream queries and freshness of 1-3 times per day is acceptable, MV is a good candidate to start. Measure actual refresh behaviour before going down the path of maintaining your own incremental logic.