Search Postgresql Archives

Re: stable for each row before insert trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 18, 2019 at 9:16 AM Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
>
> =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= <splarv@xxxxx> writes:
> > According to documentation the words "VOLATILE, STABLE, IMMUTABLE" is somehow useful with trigger functions, for instance mentioned that the AFTER INSERT trigger should be VOLATILE. The question is how this words affect a for each row before insert trigger? Can be some optimisation here?
>
> Where did you read that?  There's no optimization that considers the
> volatility of trigger functions --- they'll be called exactly when
> specified, no more or less.

I suspect this sentence could have raised the OP doubt:

"For best optimization results, you should label your functions with
the strictest volatility category that is valid for them."

(from <https://www.postgresql.org/docs/11/xfunc-volatility.html>).

However, here <https://www.postgresql.org/docs/11/trigger-datachanges.html>
it is specified that:

"If your trigger function is written in any of the standard procedural
languages, then the above statements apply only if the function is
declared VOLATILE. Functions that are declared STABLE or IMMUTABLE
will not see changes made by the calling command in any case."

which I hope is the answer to the original question.

Luca






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux