View vs Materialized View
A regular view is just a saved query that runs every time you read it. A materialized view instead stores the precomputed result on disk. Reading it returns the cached rows instantly, which is ideal for expensive aggregations run often.
Keeping It Fresh
- The stored result goes stale as base tables change.
- A full refresh recomputes the whole view from scratch.
- An incremental refresh applies only the changed rows, which is cheaper.
- Refresh can run on a schedule or be triggered by writes.
When To Use One
- Dashboards that rerun the same heavy aggregation many times.
- Reports where slightly stale data is acceptable.
- Avoid them when data must be perfectly up to the second.
Key idea
A materialized view stores precomputed query results for fast reads, trading extra storage and a refresh step against the cost of recomputing expensive queries every time.