wordfor

N+1 query

noun

Distributed systems

  1. A performance bug where code runs one query to fetch a list, then one more query for each item in it. Listing 50 orders ran 51 queries, one for the list and one per customer: an N+1 query. A single join replaced them.

In plain words

  • hundreds of database queries for one page
  • the page gets slower with more items
  • a query inside a loop
  • the ORM makes too many queries

See also premature optimization observability

Find similar words