Re: CREATE OR REPLACE MATERIALIZED VIEW

From: Said Assemlal <sassemlal(at)neurorx(dot)com>
To: Erik Wienhold <ewie(at)ewie(dot)name>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE OR REPLACE MATERIALIZED VIEW
Date: 2024-07-04 20:18:11
Message-ID: d9db9bdb-593d-4cef-9274-0db640fcff42@neurorx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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_

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2024-07-04 20:20:46 Re: Cleanup: PGProc->links doesn't need to be the first field anymore
Previous Message Tom Lane 2024-07-04 19:42:49 Re: Improving PL/Tcl's error context reports