Stand P · ₹2,400
Pitch this way
- Free
- Held
- Sold
Select a seat
F12v7 · freeF13v2 · freeF14v3 · free
Stand P · ₹2,400
Pitch this way
Select a seat
F12v7 · freeF13v2 · freeF14v3 · freeStand P · ₹2,400
Pitch this way
Select a seat
F12freeF13freeF14freeBookMyShow selling seats for RCB’s next home match: two fans pick the same seat, one walks away mid-payment, then the sale opens. Illustrative prices, versions and counts.
When two people rarely touch the same thing, like editing your own profile, use optimistic: no locks, just a check when you save. When many fight over the same thing, like the last seats, lock it first, and keep the lock short.
| Difference | Optimistic | Pessimistic |
|---|---|---|
| When a clash is caught | When you save: the version has moved on | When you pick: the row is already locked |
| What the loser sees | Refused at the end, after filling everything in | “Held” at once, and picks another |
| What it costs | Wasted work when many want the same thing | A held seat blocks everyone while its holder thinks |
| Pick it for | Rare clashes: profiles, settings, carts | Fierce contention: last seats, stock, money |
One BookMyShow seat, booked two ways. On the left, optimistic locking: nothing is locked, and when you save, the database checks nobody changed the seat since you read it. On the right, pessimistic locking: the seat is locked the moment you pick it, and nobody else can take it until you’re done. Let’s sell tickets for RCB’s next home match.
First, Rajat and DK both open the seat map and pick seat F12. The database gives each of them the seat at version seven.
Both fill in their details. Nothing is locked, so neither knows about the other.
Rajat pays first. The database checks: still version seven? Yes. The seat is his, and it becomes version eight.
DK pays a moment later. Still version seven? No, it’s eight now. His booking is refused: this seat was just taken.
Now the same two fans with pessimistic locking. Rajat taps F12 first, and the database locks the seat for him.
DK taps F12 a moment later. It’s locked, so he’s told at once: this seat is held. He picks F13 instead.
Rajat pays, the seat is his, and the lock is let go.
Next, Rajat picks F14, then takes a phone call with the payment page still open.
Nothing is locked, so DK can still buy F14, and he gets it. When Rajat comes back, his save is refused.
With pessimistic locking, F14 is locked the moment Rajat picks it.
DK wants it too, but it stays held all through Rajat’s call. Nobody can buy it until he pays, or his ten-minute hold runs out.
Finally, the sale opens: ten thousand fans for the last fifty seats. With optimistic locking, they all pick seats freely.
Most pick the same few seats, and only the first save on each one wins. Thousands fill in their details, only to be refused at the end, and try again.
With pessimistic locking, each tap locks a seat for one fan. Everyone else is told at once that it’s held, and picks another.
No one fills in their details for a seat they can’t have.
So which should you pick? When two people rarely touch the same thing, like editing your own profile, use optimistic: no locks, just a check when you save. When many fight over the same thing, like the last seats, lock it first, and keep the lock short.