OLTP
medium 28 minOLTP, online transaction processing, is the work of recording business events as they happen: an order, a payment, a booking.
Remember it
The few things worth knowing cold, and how to make them stick.
Memory hook
A busy ticket window: small, quick and exact, all day long.
The ticket window at a funfair. Coin, ticket and count change together, the last seat is sold once, the book survives a power cut, and long questions go to a copy at the back.
Cheat sheet
- Work
- short transactions, few rows
- Schema
- normalized, 3NF
- Guarantee
- ACID
- Answer time
- milliseconds
- Hot row
- 1 / lock time
- Connections
- rate × seconds each
- Overselling
- conditional update
- Reports
- on a copy (OLAP)
Spot it when you see
- Book, buy, pay, transfer.
- Something must never be sold twice.
- Several rows change together.
- Somebody waits for the answer.
Tricks that stick
- O is for Online: one request, answered now.
- L is for Low latency.
- T is for Thousands of users.
- P is for Point queries: few rows.
- Fast + writes + many users = OLTP.
Do not forget
- Read, decide in code, write without a lock.
- A remote call inside a transaction.
- Floating point money.
- Reports on the primary.
- One connection for every request.