How to Explain an N+1 Query Problem in English

Learn the English phrasing for explaining an N+1 query problem to teammates or stakeholders, from spotting the pattern to describing the fix.

An N+1 query problem is one of the most common performance bugs in backend engineering, and it’s also one of the easiest to explain badly — either too much jargon for a non-technical stakeholder, or too vague for an engineer who needs the actual mechanism. This guide covers phrasing for both audiences.

Key Vocabulary

N+1 query — a pattern where one query fetches a list of N items, followed by N additional queries (one per item) to fetch related data, instead of a single query that joins or batches the related data upfront. “This endpoint runs one query for the twenty orders, then twenty more queries to fetch each order’s customer — that’s a textbook N+1, and it’s why the page takes three seconds to load.”

Lazy loading — a pattern where related data is fetched on-demand, the first time it’s accessed, rather than upfront — a common underlying cause of N+1 problems when it happens inside a loop without anyone noticing. “The ORM is lazy loading the customer relationship, so every iteration of that loop silently triggers its own query — nobody wrote twenty queries on purpose, it happened one access at a time.”

Eager loading — explicitly fetching related data upfront, in the same query or a single batched follow-up query, avoiding the per-item query pattern that causes N+1 problems. “We switched to eager loading the customer relationship with a single join, so instead of twenty-one queries, this endpoint now runs exactly one.”

Batching — combining what would be multiple individual queries into a single query using an IN clause or similar, fetching all the related rows for a set of items at once instead of one row at a time. “Rather than a full join, we batched the customer lookups into a single query with WHERE id IN (...) — same result as eager loading, cheaper to implement given how the code was already structured.”

Common Phrases

  • “This is an N+1 — one query for the list, then one per item for the related data.”
  • “Is this being lazy loaded inside a loop, which is probably why it’s slow?”
  • “Can we eager load this relationship instead of fetching it per item?”
  • “How many actual database round trips is this endpoint making per request?”
  • “Would batching this into one query with an IN clause fix it?”

Example Sentences

Explaining the bug to an engineer in a code review: “This loop is calling order.customer for each of the twenty orders, and since that relationship is lazy loaded, it’s firing a separate query every single time — that’s twenty-one total queries for what should be one or two. Can we eager load the customer relationship in the initial query instead?”

Explaining the impact to a non-technical stakeholder: “The page is slow because of how we’re fetching the data behind the scenes — instead of asking the database once for everything it needs, the code is asking it once per item on the page. For a list of fifty items, that’s fifty separate round trips instead of one, and each round trip adds up.”

Describing the fix in a PR description: “Fixes the N+1 on the order list endpoint. Previously fetching each order’s customer with a separate lazy-loaded query; now eager loading via a join, which took this from ~40 queries per request down to 1.”

Professional Tips

  • Say N+1, not “it’s making too many queries,” when the pattern is confirmed — it’s the precise, universally recognized name for this exact failure mode and tells a teammate immediately what to look for.
  • Point to the specific lazy loading call causing the loop when reviewing code — “this relationship is lazy loaded inside a loop” is actionable; “the ORM is doing something inefficient” isn’t.
  • Propose eager loading or batching explicitly as the fix, not just “reduce the number of queries” — naming the specific technique tells the author exactly what change to make.
  • For non-technical audiences, translate the concept into round trips (“asking the database fifty times instead of once”) rather than using ORM jargon — the impact is what they need, not the mechanism’s name.

Practice Exercise

  1. Write a sentence explaining an N+1 query problem to a non-technical stakeholder.
  2. Explain the difference between lazy loading and eager loading in your own words.
  3. Describe how you’d phrase a PR review comment flagging a suspected N+1.