Re: UPDATE many records
Michael Lewis <[email protected]> Mon, 6 Jan 2020 14:38:53 -0700
| Newsgroups | gmane.comp.db.postgresql.general |
|---|---|
| Message-ID | <CAHOFxGoLdeWT8ed5pmVEM6QsSQDFPyFkmyEaV1Nt6bNvQ4yYMg@mail.gmail.com> |
On Mon, Jan 6, 2020 at 2:34 PM Mark Zellers <[email protected]> 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.