Search code examples
databasepostgresqltransactionsisolation-level

serializable snapshot isolation and select for update


I just have read serializable snapshot isolation in PostgresQL and understood from it that using this isolation level DB by itself preventing so called writing skew.

The question: is it still meaningful for DB when I mark reads with FOR UPDATE sql postfix when it's going to be update after read?


Solution

  • Yes, it is meaningful. By using FOR UPDATE, you can prevent some serialization errors from happening (because you are explicitly serializing operations), which will improve performance if conflicts are frequent.