Learn VisualLearn DB Visual
JA

Count Queries Across the Whole Request

N+1 begins with one query for N parent rows and then sends one child query per parent. For example, loading 6 customers and then one order query per customer sends 7 queries in total. The repeated overhead grows with N, but a join or batched IN query can fetch the same relationship in as few as 2 queries.

Why can N+1 be slow even when each query is fast?