From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | REFRESH MATERIALIZED VIEW locklevel |
Date: | 2013-03-07 17:30:43 |
Message-ID: | 20130307173043.GB17650@alap2.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-advocacy pgsql-hackers |
Hi,
if I understand things correctly REFRESH MATERIALIZED VIEW locks the
materialized view with an AcessExclusiveLock even if the view already
contains data.
I am pretty sure that will - understandably - confuse users, so I vote
for at least including a note about that in the docs.
This fact imo reduces the usability of the matviews features as it
stands atm considerably. I think we should be very careful not to
advocate its existance much and document very clearly that its work in
progress.
Working incrementally is a sensible thing to do, don't get me wrong...
Making the refresh work concurrently doesn't seem to be too hard if its
already initialized:
1) lock relation exlusively in session mode (or only ShareUpdateExlusive?)
2) build new data into a separate relfilenode
3) switch relfilenode
4) wait till all potential users of the old relfilenode are gone
(VirtualXactLock games, just as in CREATE INDEX CONCURRENTLY)
5) drop old relfilenode
The only problem I see right now is that we might forget to delete the
old relation if we crash during 4). Even if we WAL log it, due to
checkpoints causing that action not to be replayed.
But that seems to be nothing new, I think the same problem exists during
normal table rewrites as well, just the other way round (i.e. we forget
about the new relfilenode).
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2013-03-07 17:36:29 | Re: REFRESH MATERIALIZED VIEW locklevel |
Previous Message | Josh Berkus | 2013-03-05 01:31:57 | Re: Open Database Camp in Cambridge, MA, USA is looking for speakers |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2013-03-07 17:36:29 | Re: REFRESH MATERIALIZED VIEW locklevel |
Previous Message | Fujii Masao | 2013-03-07 17:28:51 | Re: odd behavior in materialized view |