Optimistic vs Pessimistic Locking in PostgreSQL

When two users edit the same record at once, one of them is about to overwrite the other's changes without knowing it.