Materialized views
Store a query result and refresh it when the source changes.
Example
Section titled “Example”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;Behavior
Section titled “Behavior”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.
Related
Section titled “Related”This site uses Google Analytics cookies to count visits. Privacy · License