Data Stores

Materialized View

Also known as: materialised view, precomputed view

Definition

A materialized view stores the result of a query physically rather than recomputing it on each read. It trades storage and refresh cost for read latency, and its central design question is refresh strategy — how stale the result may be and what triggers recomputation.

Last reviewed · Part of the Architecture Glossary

In practice

Refresh strategies, and what each one costs:

StrategyFreshnessCostWhere
Full refresh on scheduleMinutes to hoursRecomputes everythingPostgres REFRESH MATERIALIZED VIEW
Concurrent full refreshSame, no read lockNeeds a unique index, slowerPostgres ... CONCURRENTLY
IncrementalSecondsOnly changed partitionsClickHouse, Snowflake, dbt incremental models
Continuous / streamingSub-secondConstant computeMaterialize, Flink, ksqlDB

A worked case: a dashboard aggregate over 50 million order rows takes 8 seconds live and is loaded 200 times an hour. Materialised and refreshed every 5 minutes, reads drop to 15 ms and the aggregate runs 12 times an hour instead of 200. The product question is whether five-minute-old revenue is acceptable — it usually is, and nobody asks.

When it matters

Dashboards, leaderboards, per-tenant rollups, expensive joins on a read-heavy path, and denormalised read models in CQRS.

Common mistake

A non-concurrent refresh on a view the application reads. REFRESH MATERIALIZED VIEW takes an ACCESS EXCLUSIVE lock — every reader blocks for the duration, so a nightly refresh that grew to 90 seconds becomes a 90-second outage on a page nobody associated with it.

See also

Go deeper