← All notes

PostgreSQL materialized views

Answer: A materialized view stores a query's results in a table-like form, so reads are fast but data is only as fresh as the last REFRESH MATERIALIZED VIEW. Use `REFRESH ...

CREATE MATERIALIZED VIEW sales_summary AS
  SELECT seller_no, invoice_date, sum(invoice_amt) AS sales_amt
  FROM invoice GROUP BY seller_no, invoice_date;

CREATE UNIQUE INDEX ON sales_summary (seller_no, invoice_date);

REFRESH MATERIALIZED VIEW CONCURRENTLY sales_summary;

Refresh rules

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 39.3. Materialized Views, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: REFRESH MATERIALIZED VIEW, PostgreSQL License.

Cite this

Permanent ID: iil:note:e66q42pr

iinventedlight. 2026. "PostgreSQL materialized views." iinventedlight Library, iil:note:e66q42pr, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-materialized-views/. License: CC-BY-4.0.

@misc{iil_note_e66q42pr,
  author = {{iinventedlight}},
  title = {{PostgreSQL materialized views}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-materialized-views/},
  note = {Permanent ID iil:note:e66q42pr. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-materialized-views.md.