Re: delta relations in AFTER triggers - Mailing list pgsql-hackers

From Robert Haas
Subject Re: delta relations in AFTER triggers
Date
Msg-id CA+TgmobpSP22vZuiaugvZr31=qnoCSJD_bW5=L6-Yjk=NYabsw@mail.gmail.com
Whole thread Raw
In response to delta relations in AFTER triggers  (Kevin Grittner <kgrittn@ymail.com>)
Responses Re: delta relations in AFTER triggers  (David Fetter <david@fetter.org>)
Re: delta relations in AFTER triggers  (Kevin Grittner <kgrittn@ymail.com>)
List pgsql-hackers
On Sat, Jun 14, 2014 at 7:56 PM, Kevin Grittner <kgrittn@ymail.com> wrote:
> I looked at the standard, and initially tried to implement the
> standard syntax for this; however, it appeared that the reasons
> given for not using standard syntax for the row variables also
> apply to the transition relations (the term used by the standard).
> There isn't an obvious way to tie that in to all the PLs we
> support.  It could be done, but it seems like it would intolerably
> ugly, and more fragile than what we have done so far.

I'm not too familiar with this area.  Can you describe what the
standard syntax for the row variables is, as opposed to our syntax?
Also, what's the standard syntax for the the transition relations?

> Some things which I *did* follow from the standard: these new
> relations are only allowed within AFTER triggers, but are available
> in both AFTER STATEMENT and AFTER ROW triggers.  That is, an AFTER
> UPDATE ... FOR EACH ROW trigger could use both the OLD and NEW row
> variables as well as the delta relations (under whatever names we
> pick).  That probably won't be used very often, but I can imagine
> some cases where it might be useful.  I expect that these will
> normally be used in FOR EACH STATEMENT triggers.

I'm concerned about the performance implications of capturing the
delta relations unconditionally.  If a particular trigger actually
needs the delta relations, then the time spent capturing that
information is well spent; but if it doesn't, then it's a waste.
There are lots of people using FOR EACH STATEMENT triggers right now
who won't be happy if those start requiring O(n) additional temporary
storage, where n is the number of rows modified by the statement.
This is likely an even bigger issue for per-row triggers, of course,
where as you say, it probably won't be used often.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pg_control is missing a field for LOBLKSIZE
Next
From: Robert Haas
Date:
Subject: Re: btreecheck extension