Detect a Conflict Before or After Work
Pessimistic locking reserves a row before changing it — for example, when two people edit the same product, it makes the second one wait. Optimistic locking updates only when a version still matches, and zero updated rows signals a conflict. The first favors expensive or frequent conflicts; the second favors low contention and interactive edits.
Which strategy avoids holding a database lock while a user edits a form?