N+1 Queries
A common ORM performance problem where an application executes 1 initial query followed by N additional queries to fetch related data.
Definition
A common ORM performance problem where an application executes 1 initial query followed by N additional queries to fetch related data.
Use case
Fetching 50 user posts and triggering 50 separate SQL calls for author info instead of using a single JOIN or IN batch query.
Related terms
Documentation
Eager loading associations
The classic ORM trap and the one-query fix, shown in Rails.