1. Index Strategy Matters More Than You Think
Covering indexes, composite index ordering, and understanding the difference between B-tree and hash indexes transformed our query performance.
2. Query Pattern Analysis
Using EXPLAIN ANALYZE regularly revealed that our "optimized" queries were doing full table scans on tables with millions of rows.
3. Connection Pooling Is Non-Negotiable
At scale, creating a new database connection per request becomes a bottleneck. PgBouncer and ProxySQL became essential infrastructure.
Results
Combined, these changes reduced our p99 query time from 850ms to 127ms—a 85% improvement that directly impacted user experience.