Re: Linear slow-down while inserting into a table with an ON INSERT trigger ?
В списке pgsql-performance по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Linear slow-down while inserting into a table with an ON INSERT trigger ? |
| Дата | |
| Msg-id | 62962.1626532389@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Linear slow-down while inserting into a table with an ON INSERT trigger ? (David Rowley <dgrowleyml@gmail.com>) |
| Список | pgsql-performance |
David Rowley <dgrowleyml@gmail.com> writes: > On Sat, 17 Jul 2021 at 16:40, Justin Pryzby <pryzby@telsasoft.com> wrote: >> You could run a single UPDATE rather than 30k triggers. >> Or switch to an INSERT on the table, with an index on it, and call >> max(last_parent_table_change) from whatever needs to ingest it. And prune the >> old entries and vacuum it outside the transaction. Maybe someone else will >> have a better suggestion. > Maybe just change the UPDATE statement to: > UPDATE data_sync SET last_parent_table_change=CURRENT_TIMESTAMP WHERE > last_parent_table_change <> CURRENT_TIMESTAMP; > That should reduce the number of actual updates to 1 per transaction. Or, if it's impractical to make the application do that for itself, this could be a job for suppress_redundant_updates_trigger(). https://www.postgresql.org/docs/current/functions-trigger.html regards, tom lane
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера