What is a materialized view?
A materialized view is a database object that stores the pre-computed result of a SQL query. Unlike a regular view, which re-executes the query every time it is accessed, a materialized view persists the result so that queries return instantly without recomputation. In RisingWave, materialized views are incrementally maintained in real time. When new data arrives from sources or tables, RisingWave automatically updates only the affected rows in the materialized view — it does not recompute the entire result from scratch. This makes materialized views in RisingWave fundamentally different from those in traditional databases, which typically use periodic batch refresh.How materialized views work in RisingWave
When you create a materialized view withCREATE MATERIALIZED VIEW, RisingWave:
- Backfills all existing data from the referenced tables or sources to produce an initial consistent snapshot.
- Creates a streaming pipeline that continuously processes new data as it arrives.
- Persists results to Hummock, RisingWave’s LSM-tree storage engine backed by object storage (S3, GCS, Azure Blob).
- Serves queries from dedicated Serving Nodes with low latency and high concurrency.
Cascading materialized views
RisingWave supports cascading materialized views — building materialized views on top of other materialized views. This enables multi-layered streaming pipelines entirely in SQL, without external orchestration.Materialized views vs. regular views
| Feature | Regular view | Materialized view |
|---|---|---|
| Stores data | No — re-executes query on each access | Yes — persists pre-computed results |
| Query latency | Depends on query complexity | Near-instant (reads from stored results) |
| Data freshness | Always current (computed on read) | Always current (incrementally updated on write) |
| Resource usage | CPU cost on every query | CPU cost on data ingestion; minimal on query |
CREATE VIEW) and materialized views are supported. Use regular views for query reuse and abstraction; use materialized views when you need pre-computed, always-fresh results.
Background DDL
For large datasets, the initial backfill of a materialized view can take time. RisingWave supports background DDL to avoid blocking your session:When to use materialized views
- Real-time dashboards: Pre-compute aggregations so dashboards load instantly.
- Streaming ETL: Transform and enrich data as it arrives, then sink results to downstream systems.
- Monitoring and alerting: Continuously compute metrics and trigger alerts on threshold crossings.
- Feature engineering: Maintain up-to-date feature vectors for machine learning models.
- Online serving: Serve pre-joined, pre-aggregated data to applications with low-latency queries.
Related topics
- CREATE MATERIALIZED VIEW — SQL reference
- Data processing in RisingWave — Streaming vs. ad-hoc execution
- Source, Table, MV, and Sink — Core object comparison