Re: CREATE OR REPLACE MATERIALIZED VIEW

From: Said Assemlal <sassemlal(at)neurorx(dot)com>
To: Erik Wienhold <ewie(at)ewie(dot)name>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE OR REPLACE MATERIALIZED VIEW
Date: 2024-07-12 14:49:14
Message-ID: e55c4930-f788-4bb0-a684-743621d6cfc5@neurorx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> That is expected because AccessExclusiveLock is acquired on the existing
> matview. This is also the case for CREATE OR REPLACE VIEW.

Right, had this case many times.

>
> My initial idea, while writing the patch, was that one could replace the
> matview without populating it and then run the concurrent refresh, like
> this:
>
> CREATE OR REPLACE MATERIALIZED VIEW foo AS ... WITH NO DATA;
> REFRESH MATERIALIZED VIEW CONCURRENTLY foo;
>
> But that won't work because concurrent refresh requires an already
> populated matview.
>
> Right now the patch either populates the replaced matview or leaves it
> in an unscannable state. Technically, it's also possible to skip the
> refresh and leave the old data in place, perhaps by specifying
> WITH *OLD* DATA. New columns would just be null. Of course you can't
> tell if you got stale data without knowing how the matview was replaced.
> Thoughts?

I believe the expectation is to get materialized views updated whenever
it gets replaced so likely to confuse users ?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Sabino Mullane 2024-07-12 14:57:40 Re: Send duration output to separate log files
Previous Message Alexander Korotkov 2024-07-12 13:59:13 Re: Removing unneeded self joins