Diagnostic Queries
Symptoms
A query tried to read a materialized view that was created WITH NO DATA and never refreshed. PostgreSQL raises SQLSTATE 55000 (object_not_in_prerequisite_state).
- The materialized view holds no data yet.
- It was created WITH NO DATA and not refreshed.
- Reads are blocked until it is populated.
What the server log shows
ERROR: materialized view "sales_summary" has not been populated
HINT: Use the REFRESH MATERIALIZED VIEW command.
Why PostgreSQL raises this — what the manual says
the REFRESH MATERIALIZED VIEW reference (Parameters):
“If WITH NO DATA is specified no new data is generated and the materialized view is left in an unscannable state.”
A materialized view created WITH NO DATA is marked unscannable. Until a REFRESH populates it, querying it has no valid contents, so PostgreSQL reports 55000.
Common causes
- The matview was created
WITH NO DATA. - A scheduled refresh hasn’t run yet.
- A failed/aborted refresh left it unpopulated.
How to fix it
- Populate it:
REFRESH MATERIALIZED VIEW sales_summary;. - Schedule refreshes appropriately for your data freshness needs.
- Use
REFRESH … CONCURRENTLY(needs a unique index) to avoid blocking readers on later refreshes.
Related & next steps
Reference: PostgreSQL 18 — REFRESH MATERIALIZED VIEW.
Thanks — noted. This helps keep the database accurate.