advanced
Database cache
Rely on database buffer pools and query caches deliberately instead of hiding missing indexes or bad access patterns.
Databases cache internally via buffer pools keeping hot pages in memory and sometimes query result caches. These are not a substitute for application design — missing indexes and full table scans remain slow even with a warm buffer pool.
Size buffer memory relative to working set. Query cache features (where they exist) help repetitive identical reads but invalidate aggressively on writes. Prefer proper indexes and read replicas for predictable read scaling.
On interviews: explain buffer pool versus Redis layer, when adding indexes beats adding cache, and working set concept.
Common pitfalls: relying on DB cache while queries lack indexes; oversized buffer starving OS page cache; assuming query cache helps write-heavy workloads.
The trade-off is flexibility versus complexity—know when the simpler path is enough.
Checklist:
- Right-size buffer pool for working set.
- Fix access paths and indexes first.
- Layer app cache for cross-request hot data.
- Monitor cache hit ratios and slow queries.