News for hackers. Stuff that matters.
Re:Select FOR UPDATE considered harmful in PostgreSQL by rickette on Thursday June 19, 2025 @02:47PM (#44321373)
tl;dr "Unless you plan to delete a row or modify a key column, always use SELECT FOR NO KEY UPDATE".
Re:Select FOR UPDATE considered harmful in PostgreSQL by gmcabrita on Thursday June 19, 2025 @05:17PM (#44322604)
> PostgreSQL takes FOR UPDATE on rows before a DELETE, or before an UPDATE that modifies a column that is part of a unique index that neither contains expressions nor is partial

This also happens when you UPDATE the same row twice within the same transaction.

https://goncalo.mendescabrita.com/blog/cross-table-lock/