Settings

Theme

Select FOR UPDATE considered harmful in PostgreSQL

cybertec-postgresql.com

44 points by samokhvalov 6 months ago · 2 comments

Reader

gmcabrita 6 months ago

> 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/

rickette 6 months ago

tl;dr "Unless you plan to delete a row or modify a key column, always use SELECT FOR NO KEY UPDATE".

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection