Skip to main content

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 with CREATE MATERIALIZED VIEW, RisingWave:
  1. Backfills all existing data from the referenced tables or sources to produce an initial consistent snapshot.
  2. Creates a streaming pipeline that continuously processes new data as it arrives.
  3. Persists results to Hummock, RisingWave’s LSM-tree storage engine backed by object storage (S3, GCS, Azure Blob).
  4. 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.
Each layer updates incrementally when upstream data changes. Cascading materialized views are strongly consistent — downstream views always reflect the latest state of upstream views.

Materialized views vs. regular views

In RisingWave, both regular views (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.