Skip to content
ParticleDB
Release candidateParticleDB 1.1.19-rc.17 is not yet GA or ready for production data.Release status →

Materialized views

Store a query result and refresh it when the source changes.

CREATE TABLE docs_sales (id BIGINT PRIMARY KEY, amount BIGINT);
INSERT INTO docs_sales VALUES (1, 10), (2, 20);
CREATE MATERIALIZED VIEW docs_sales_total AS SELECT SUM(amount) AS total FROM docs_sales;
SELECT total FROM docs_sales_total;
INSERT INTO docs_sales VALUES (3, 30);
REFRESH MATERIALIZED VIEW docs_sales_total;
SELECT total FROM docs_sales_total;

The first total is 30 and the refreshed total is 60. A materialized view is not automatically current with every write. Choose a refresh policy that matches the application and test failure behavior. Ordinary views and materialized views have different storage and refresh behavior.

SQL reference · Application guide · Troubleshooting