What a materialized view is
A materialized view stores the result of a query physically, so reads hit precomputed data instead of scanning base tables. The catch is that base data changes, so the view must be refreshed to stay correct.
Refresh strategies
- A full refresh recomputes the whole view. Simple and always correct, but expensive on large inputs.
- An incremental refresh applies only the changes since the last run, using the delta of inserts, updates, and deletes. Much cheaper but harder to implement for complex aggregates.
- A scheduled refresh runs periodically, while an on demand refresh runs when staleness matters.
The freshness trade off
A view refreshed less often is cheaper but more stale. Systems expose this directly, letting queries either read the possibly stale view or fall back to the base tables for exact answers.
Choosing incremental over full refresh, and the right cadence, is how teams keep precomputed aggregates fresh without paying full recompute cost every time.
Key idea
A materialized view stores query results and must be refreshed, with incremental refresh applying only deltas to balance freshness against cost.