databases
10 minFix Slow SQL: N+1 Queries, Missing Indexes, and Bad Cardinality Estimates
A systematic approach to diagnosing ORM query explosions and slow database plans without guessing at indexes.
Loading page...
databases
10 minA systematic approach to diagnosing ORM query explosions and slow database plans without guessing at indexes.
Q&A
Q&ACount repeated statements per request, then batch-load without changing result cardinality.
Trace or log normalized SQL for one request and look for the same child lookup repeated once per parent row. Replace the loop with an eager/batch load or a query at the correct grain. Verify query count and returned rows; a broad join can fix round trips while accidentally multiplying results.