Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Thought the update would be no-op because nothing changed.

You can use a specific trigger function just to prevent this: suppress_redundant_updates_trigger

https://www.postgresql.org/docs/current/functions-trigger.ht...

> The suppress_redundant_updates_trigger function, when applied as a row-level BEFORE UPDATE trigger, will prevent any update that does not actually change the data in the row from taking place. This overrides the normal behavior which always performs a physical row update regardless of whether or not the data has changed.



I just tested that and the trigger causes the INSERT to return no rows if the row already exists.

It basically turns the ON CONFLICT DO UPDATE into ON CONFLICT DO NOTHING.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: