N+1 database queries with eager loading cause connection exhaustion
criticalperformanceUpdated Sep 1, 2025(via Exa)
How to detect:
Routes with eager loading (include/join operations) that fetch nested relationships cause exponential database queries. Under load, this results in tens of thousands of simultaneous database connections (documented case: 50,000 connections during Black Friday traffic), exhausting connection pools and causing application outages.
Recommended action:
Limit SELECT attributes to only required fields using 'attributes' parameter. Add pagination with explicit 'limit' (e.g., 50 rows). Optimize 'include' clauses to fetch only minimal nested data. Review all routes for similar N+1 patterns and refactor before high-traffic events.