Persist query results for faster reads.
Section: Views, Functions, Triggers, and Extensions
Create materialized view
sql
sql
CREATE MATERIALIZED VIEW daily_sales AS
SELECT date_trunc('day', created_at) AS day, sum(total_amount) AS revenue
FROM orders
GROUP BY 1;Explanation
See summary for usage details.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Views, Functions, Triggers, and Extensions
Create database with owner
Create a database with explicit owner and template.
Create identity column
Use a SQL-standard identity column instead of serial.