Re: Feature: triggers on materialized views

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Mitar <mmitar(at)gmail(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Kevin Grittner <kgrittn(at)gmail(dot)com>
Subject: Re: Feature: triggers on materialized views
Date: 2018-12-26 03:05:24
Message-ID: 20181226030524.ysjxcfsstulqkm3x@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018-Dec-25, Mitar wrote:

> On Tue, Dec 25, 2018 at 6:47 PM Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:
> > > I made another version of the patch. This one does UPDATEs for changed
> > > row instead of DELETE/INSERT.
> > >
> > > All existing regression tests are still passing (make check).
> >
> > Okay, but you don't add any for your new feature, which is not good.
>
> Yes, I have not yet done that. I want first to also add calling
> triggers for non-concurrent refresh, but I would need a bit help there
> (what to call, example of maybe code which does something similar
> already).

Well, REFRESH CONCURRENTLY runs completely different than non-concurrent
REFRESH. The former updates the existing data by observing the
differences with the previous data; the latter simply re-runs the query
and overwrites everything. So if you simply enabled triggers on
non-concurrent refresh, you'd just see a bunch of inserts into a
throwaway data area (a transient relfilenode, we call it), then a swap
of the MV's relfilenode with the throwaway one. I doubt it'd be useful.
But then I'm not clear *why* you would like to do a non-concurrent
refresh. Maybe your situation would be best served by forbidding non-
concurrent refresh when the MV contains any triggers.

Alternatively, maybe reimplement non-concurrent refresh so that it works
identically to concurrent refresh (except with a stronger lock). Not
sure if this implies any performance penalties.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mitar 2018-12-26 03:16:46 Re: Feature: triggers on materialized views
Previous Message Mitar 2018-12-26 02:56:48 Re: Feature: triggers on materialized views