Re: stable for each row before insert trigger

Поиск
Список
Период
Сортировка
От Luca Ferrari
Тема Re: stable for each row before insert trigger
Дата
Msg-id CAKoxK+56R4KHM1sUhUbsH2=J3GTUn+HXD6gp9di_nD9UsRQM-w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: stable for each row before insert trigger  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Fri, Oct 18, 2019 at 9:16 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= <splarv@ya.ru> writes:
> > According to documentation the words "VOLATILE, STABLE, IMMUTABLE" is somehow useful with trigger functions, for
instancementioned that the AFTER INSERT trigger should be VOLATILE. The question is how this words affect a for each
rowbefore 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



В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: stable for each row before insert trigger
Следующее
От: Luca Ferrari
Дата:
Сообщение: Re: Postgres Point in time Recovery (PITR),