4 ms·
I haven't used this, but I see its in Oracle and MySQL - does this exist in Postgresql or is this just the same as wrapping in a transaction where you're select
by arthurcolle 3y ago
I haven't used this, but I see its in Oracle and MySQL - does this exist in Postgresql or is this just the same as wrapping in a transaction where you're selecting on the row by ID or something? Just curious
- Rapzid 3y agoPretty much every RDBMS has this: https://www.postgresql.org/docs/current/explicit-locking.html https://www.postgresql.org/docs/current/explicit-locking.htm... There are multiple flavors in PostgreSQL with different locking semantics. And the exact locking semantics may differ between database(for instance postgres does not have gap locks, while MySQL does) so you'd have to read the docs if that detail matters to you.
- dathinab 3y agoit does exist and I think it was even added to the SQL standard in some update what FOR UPDATE does is (simplified) to lock a mutex for each row the select statement returns which are released once the transaction commits this has the effect that parallel running transactions have to wait until the new computed value is visible before reading it and in turn there is no problem with lost updates just to be clear this is a very simplified explanation in many ways