How do optimistic and pessimistic locking differ?

2 stars Asked often.

In one or two sentences
Pessimistic locking assumes conflicts are common and locks first. Optimistic locking assumes they are rare and only checks at write time whether the row changed.

Think of your own answer first

Say it out loud, or type it below. What you type never leaves this device.

Follow-up questions

These are likely next questions from an interviewer. Think of your answer first, then press the button.

  1. 1 / 3

    How do you implement optimistic locking?

Sources checked