From: | Erik Wienhold <ewie(at)ewie(dot)name> |
---|---|
To: | Said Assemlal <sassemlal(at)neurorx(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: CREATE OR REPLACE MATERIALIZED VIEW |
Date: | 2024-07-05 23:42:48 |
Message-ID: | e4382244-6b55-450b-a4f0-32959056ade4@ewie.name |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2024-07-04 22:18 +0200, Said Assemlal wrote:
> +1 for this feature.
Thanks!
> I noticed replacing the materialized view is blocking all reads. Is that
> expected ? Even if there is a unique index ?
That is expected because AccessExclusiveLock is acquired on the existing
matview. This is also the case for CREATE OR REPLACE VIEW.
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?
--
Erik
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2024-07-05 23:57:21 | Re: PostgreSQL does not compile on macOS SDK 15.0 |
Previous Message | David Rowley | 2024-07-05 22:43:44 | Re: Should we document how column DEFAULT expressions work? |