OLTP Through the Looking Glass, and What We Found There
This paper by database legend Mike Stonebraker is an absolute classic. It profiles a transactional database in great detail, determining the purpose of each CPU instruction. The authors find that <10% of CPU instructions are actually performing useful work. The remaining are split roughly evenly between four sources of overhead:
- Buffer management (moving pages between a buffer pool and disk)
- Locking (heavyweight row-level locks providing transaction concurrency control)
- Latching (lightweight locks protecting data structure internals from concurrent accesses)
- Logging (recording operations before executing them to enable recovery)
One one hand, these results are discouraging because there's no "high pole in the tent." Overhead comes from multiple sources, all of which are critical for traditional database functionality. On the other hand, these results suggest a radically different database architecture that could achieve incredible performance: a database that's wholly in-memory (no buffer pool), single-threaded per-partition (no locking or latching) and replicated (no logging).
This insight spawned a long-running research project (H-Store, and later VoltDB), which have shown that if you're willing to accept slightly less flexibility from your database, truly incredible performance is possible.