What is the N+1 query problem?
Model answer
Running one query to get N rows and then N more queries to fetch related data for each row, often caused by ORMs. Fix it with a join, a batch query (WHERE id IN (...)), or eager loading. It is a very common cause of slow pages.
Learn this topic
Indexes and Faster Queries: EXPLAIN for Beginners in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.