
SQL Fundamentals
N+1 Queries: What the ORM Is Actually Doing
One query for the list, then one more for every item in it. The cost is per statement, which is why the profiler shows a fast database and a slow request.
· 3 min
author
Database engineer · 14 articles
Elias Rowe writes about database engineering, SQL performance, and production systems. He focuses on measurable behavior, practical trade-offs, and conclusions that can be reproduced rather than assumed.
PostgreSQL · MySQL · Query optimization · Data modeling · Production operations

One query for the list, then one more for every item in it. The cost is per statement, which is why the profiler shows a fast database and a slow request.
· 3 min

An index the planner ignores is usually a row-estimate problem. The fix starts with what the optimizer expected, not with the index definition.
· 3 min