PostgreSQL – Definition of a Materialized View

pg_matviews lists each PostgreSQL Materialized View and its reconstructed SELECT definition. A cross-platform customer requested this metadata.

A stored mosaic panel sits beside its blank construction folio, source tiles and separate fittings.

SELECT schemaname,matviewname,matviewowner,tablespace,hasindexes,ispopulated,definition
FROM pg_catalog.pg_matviews ORDER BY schemaname,matviewname;

The catalog includes schema, name, owner, tablespace, indexes, population state and definition. Filter by schema and view name for one object. NULL tablespace identifies the default.

ispopulated does not establish a nonempty or current result. hasindexes can describe present or recently existing indexes. Check the index catalogs for exact current details.

A materialized view persists a result that needs a refresh plan. Its definition is a reconstructed SELECT rather than complete original DDL. Preserve indexes, grants and operational settings separately. This catalog is not newly introduced whenever the current release changes.

Reference: PostgreSQL materialized-view catalog columns.

Related reading

A population flag is not a freshness guarantee, it is catalog state separate from row count and source changes.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

PostgreSQL
Previous Post
SQL SERVER – Last 5 SQL in Sixty Seconds Video
Next Post
Shredding JSON Into Relational Tables in One Pass

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.