Skip to main content

CREATE MATERIALIZED VIEW

Turso Extension: Materialized views are a Turso-specific feature not available in SQLite. This feature is experimental and must be enabled before use.
A materialized view stores precomputed query results on disk and automatically keeps them up to date using Incremental View Maintenance (IVM). Unlike standard views, reading from a materialized view does not re-execute the underlying SELECT.

Syntax

Parameters

How Incremental View Maintenance Works

When you modify data in a table that underlies a materialized view, Turso incrementally updates the materialized view within the same transaction. There is no manual REFRESH step. The materialized view is always consistent with the base tables.
  • Changes to the materialized view are committed or rolled back together with the changes to the base tables.
  • Aggregations like COUNT, SUM, and AVG are maintained efficiently — Turso does not recompute the entire result set on each change.

Current Limitations

  • Not all SQL functions are supported in materialized view definitions.
  • A materialized view cannot reference another view or materialized view.
  • The TEMPORARY modifier is not supported for materialized views.

Examples

Precomputed Aggregations

Automatic Updates

Filtered Summary

See Also

  • CREATE VIEW for standard (non-materialized) views
  • DROP VIEW for removing materialized views
  • SELECT for the query syntax used in view definitions