Choosing a locking strategy
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
choose between atomic SQL, optimistic, and pessimistic locking.
Planned topics
- Low conflict, user edits spanning requests: optimistic.
- High conflict on a hot row (stock): atomic
UPDATEfirst, otherwise pessimistic. - Optimistic under heavy conflict wastes work on retries.
- Pessimistic holds connections and risks deadlocks; keep it inside one short transaction.
Draft outline details
Demonstration
a decision table: workload / conflict rate / chosen strategy / reason, with product edits, stock decrement, and nightly price job.
Check your understanding
Which strategy for two admins editing a product description?
Show answer
Optimistic, with a 409 on conflict.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.