Re: REFRESH MATERIALIZED VIEW locklevel

From: "anarazel(at)anarazel(dot)de" <andres(at)anarazel(dot)de>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Andres Freund <andres(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: REFRESH MATERIALIZED VIEW locklevel
Date: 2013-03-07 19:00:08
Message-ID: 5af0c8bd-4b0c-41d0-8442-70372818a749@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-hackers

Kevin Grittner <kgrittn(at)ymail(dot)com> schrieb:

>Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>
>> if I understand things correctly REFRESH MATERIALIZED VIEW locks
>> the materialized view with an AcessExclusiveLock even if the view
>> already contains data.
>
>Yeah.  At the time I had to make a decision on that, REINDEX
>CONCURRENTLY did not seem reliable with a weaker lock, and REFRESH
>MATERIALIZED VIEW has to rebuild indexes (among other things).  If
>we have all the issues sorted out with REINDEX CONCURRENTLY then
>the same techniques will probably apply to RMV without too much
>difficulty.  It's a bit late to think about that for 9.3, though.
>
>> I am pretty sure that will - understandably - confuse users, so I
>> vote for at least including a note about that in the docs.
>
>Will see about working that in.

In the ride home I realized that unless - not that unlikely - you thought about something I didtn't REFRESH will behave similar to TRUNCATE for repeatable read+ transactions that only access it after REFRESH finished. That is, they will appear empty. If that's the case, it needs to be documented prominently as well.

It would be possible to get different behaviour by immediately freezing all tuples, but that would also result in violations of visibility by showing tuples that are not yet visible.

Andres

---
Please excuse brevity and formatting - I am writing this on my mobile phone.

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Kevin Grittner 2013-03-07 19:50:11 Re: REFRESH MATERIALIZED VIEW locklevel
Previous Message Andres Freund 2013-03-07 18:23:55 Re: REFRESH MATERIALIZED VIEW locklevel

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2013-03-07 19:48:45 Duplicate JSON Object Keys
Previous Message Ray Stell 2013-03-07 18:42:36 Re: Trust intermediate CA for client certificates