Re: CREATE OR REPLACE MATERIALIZED VIEW - Mailing list pgsql-hackers

From Said Assemlal
Subject Re: CREATE OR REPLACE MATERIALIZED VIEW
Date
Msg-id d9db9bdb-593d-4cef-9274-0db640fcff42@neurorx.com
Whole thread Raw
In response to CREATE OR REPLACE MATERIALIZED VIEW  (Erik Wienhold <ewie@ewie.name>)
Responses Re: CREATE OR REPLACE MATERIALIZED VIEW
List pgsql-hackers

Hi,


+1 for this feature.

Replacing Matviews
------------------

With patch 0001, a matview can be replaced without having to drop it and
its dependent objects.  In our use case it is no longer necessary to
define the actual query in a separate view.  Replacing a matview works
analogous to CREATE OR REPLACE VIEW:

* the new query may change SELECT list expressions of existing columns
* new columns can be added to the end of the SELECT list
* existing columns cannot be renamed
* the data type of existing columns cannot be changed

In addition to that, CREATE OR REPLACE MATERIALIZED VIEW also replaces
access method, tablespace, and storage parameters if specified.  The
clause WITH [NO] DATA works as expected: it either populates the matview
or leaves it in an unscannable state.

It is an error to specify both OR REPLACE and IF NOT EXISTS.

I noticed replacing the materialized view is blocking all reads. Is that expected ? Even if there is a unique index ?


Best,
Saïd

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Improving PL/Tcl's error context reports
Next
From: Andres Freund
Date:
Subject: Re: Cleanup: PGProc->links doesn't need to be the first field anymore