# Optimistic and Pessimistic Locking

+ In optimistic locking: 
  + A record is locked only when changes are committed to the database
  + The record changes are validated only when the record is committed
  + It avoids the overhead of locking a record for the duration of the action
+ In pessimistic locking:
  + A record is locked while it is edited
  + It prevents simultaneous updates to records
  + It avoids the issue of conflict resolution by preventing conflicts
  
------------------------------------------------------------
  + Optimistic locking: If one user successfully updates the record, the other users attempting to commit their concurrent updates are informed that a conflict exists. If there are no simultaneous updates, then this model provides fast updates. Optimistic locking is a useful approach when concurrent record updates are expected to be infrequent or the locking overhead is high.
  + Pessimistic locking: As soon as one user starts to update a record, a lock is placed on it. Other users who attempt to update this record are informed that another user has an update in progress. The other users must wait until the first user has finished committing their changes, thereby releasing the record lock.