Re: stable for each row before insert trigger

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: Олег Самойлов <splarv(at)ya(dot)ru>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: stable for each row before insert trigger
Date: 2019-10-18 11:24:12
Message-ID: CAKoxK+51uQ71w1mR9_Rqrg7Bw8rvt3f-Bt01qON=_MykievWTQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 18, 2019 at 11:18 AM Олег Самойлов <splarv(at)ya(dot)ru> wrote:
> > STABLE indicates .... (It is inappropriate for AFTER triggers that wish to query rows modified by the current command.)
>
> So, STABLE is inappropriate for such trigger, but is appropriate for BEFORE trigger?
>

Well, a before trigger will not see data changes in any way, so I read
it as "it does not matter for before triggers".
And I would speculate that, being in a trigger, the function is
invoked every time, so there should not be any caching that produces
performance boosts.

> For instance, I expect that the FOR EACH ROW BEFORE trigger marked as STABLE will be faster than VOLATILE without important negative side effects. I observed 3% benefit. IMMUTABLE trigger is slightly slower then STABLE, but I am not sure, too low difference.

It could be faster, but I would not speculate on that rather than an
inling of the code.

Luca

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Steele 2019-10-18 11:47:05 Re: Postgres Point in time Recovery (PITR),
Previous Message Guillaume Lelarge 2019-10-18 11:13:31 Re: Execute a function through fdw