SELECT FOR UPDATE considered harmful in PostgreSQL
© Laurenz Albe 2025
The motivation behind SELECT FOR UPDATE avoiding lost updatesHow PostgreSQL uses locks to maintain foreign key consistencyThe row locks taken by UPDATE and DELETEThe problem with SELECT FOR UPDATE in PostgreSQLWhat? SELECT FOR UPDATE is not the correct row lock for an UPDATE?Conclusion
Recently, while investigating a deadlock for a customer, I was again reminded how harmful SELECT FOR UPDATE can be for database concurrency. This is nothing new, but I find that many people don...
Read more at cybertec-postgresql.com