GUIDE
Materialized views pre-compute and store query results for fast reads. Learn the difference between regular views, materialized views, and incrementally maintained materialized views — and how RisingWave keeps them always fresh.
Core Concept
A materialized view is a database object that stores the result of a query physically on disk. Unlike a regular view — which re-executes its defining query every time you read from it — a materialized view computes the result once and serves it instantly on subsequent reads, trading storage space for dramatically faster query performance.
| Characteristic | Regular View | Materialized View | Incremental MV (RisingWave) |
|---|---|---|---|
| Storage | None (query alias only) | Stores full result set | Stores full result set |
| Read Speed | Slow (re-executes query) | Fast (pre-computed) | Fast (pre-computed) |
| Freshness | Always current | Stale until refreshed | Always current (auto-updated) |
| Update Method | N/A | REFRESH MATERIALIZED VIEW | Automatic incremental updates |
| Write Cost | None | Full recompute on refresh | Incremental (only changed rows) |
| Best For | Query reuse, abstraction | Read-heavy batch analytics | Real-time dashboards, streaming |
In traditional databases like PostgreSQL, a materialized view must be refreshed manually using REFRESH MATERIALIZED VIEW. This full recomputation can be expensive and creates a window where results are stale. Incremental maintenance — the approach used by RisingWave — eliminates both problems by updating only the rows affected by each incoming change.
How It Works
Full refresh recomputes the entire materialized view from scratch each time it updates — re-reading all source data and re-executing the full query. Incremental maintenance tracks which source rows changed and updates only the affected output rows. For large datasets, incremental maintenance is orders of magnitude faster and enables real-time freshness.
Incremental updates process in milliseconds, keeping materialized views current without manual refresh commands.
Processing only changed rows uses a fraction of the CPU compared to full recomputation on every refresh cycle.
Barrier-based checkpointing ensures that all materialized views reflect the same point-in-time state across the system.
Build views on top of views. Changes flow through the entire DAG automatically — no orchestration logic needed.
Getting Started
Creating a materialized view in RisingWave uses standard PostgreSQL syntax: CREATE MATERIALIZED VIEW view_name AS SELECT ... The view begins ingesting and processing data immediately. You query it with a normal SELECT statement, and results reflect the latest state of the underlying streams — no refresh command needed.
Start building always-fresh materialized views with SQL in minutes.
Try Materialized Views in RisingWave