How do you optimize database performance in DevOps?
⚡
Quick Answer
Add appropriate indexes, optimize slow queries, cache hot reads (Redis), use connection pooling, and scale via read replicas or partitioning/sharding — guided by query analysis and monitoring.
Detailed Answer
Start from evidence: profile slow queries (EXPLAIN), fix N+1 patterns, and index selectively (indexes speed reads but slow writes). Then relieve load with caching and read replicas, and scale writes with partitioning/sharding when a single node is the bottleneck. Monitor query latency and connection saturation continuously.
💡
Interview Tip
Say to profile first (EXPLAIN/slow query log) before optimizing, and note indexes trade write cost for read speed.
databaseperformancescaling