[prev] 37 [next]

Concurrency Control in PostgreSQL (cont)

Tx's always see a consistent version of the database.

But may not see the "current" version of the database.

E.g. T1 does select, then concurrent T2 deletes some of T1's selected tuples

This is OK unless tx's communicate outside the database system.

E.g. T1 counts tuples while T2 deletes then counts; then counts are compared

Use locks if application needs every tx to see same current version

  • LOCK TABLE locks an entire table
  • SELECT FOR UPDATE locks only the selected rows