Re: UPDATE many records - Mailing list pgsql-general

From Michael Lewis
Subject Re: UPDATE many records
Date
Msg-id CAHOFxGoLdeWT8ed5pmVEM6QsSQDFPyFkmyEaV1Nt6bNvQ4yYMg@mail.gmail.com
Whole thread Raw
In response to RE: UPDATE many records  (Mark Zellers <markz@adaptiveinsights.com>)
List pgsql-general
On Mon, Jan 6, 2020 at 2:34 PM Mark Zellers <markz@adaptiveinsights.com> wrote:

Just out of curiosity, what kind of trigger are you using, a row level trigger or a statement level trigger?  If you are using a row level trigger, see if you can achieve your requirements using a statement level trigger instead.  I’m relatively new to Postgres, so there could be some limit that I’m not aware of, but my understanding is that you have access to the old and new values of the updated rows in the after statement trigger.  It would likely be much more performant to do your operation once after the statement is done rather than firing a trigger on every changed row.


My experience/understanding is that statement level triggers can be a big performance boost, but only for changing *other* tables and not the table that the trigger is on since it is *AFTER* only and can't modify NEW record directly.

pgsql-general by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: jsonb_set() strictness considered harmful to data
Next
From: Justin
Date:
Subject: Re: UPDATE many records