Advanced SQL
Q89 / 100

What is the "N+1 query problem" often encountered in application code using an ORM, and how does SQL help avoid it?

Correct! Well done.

Incorrect.

The correct answer is B) It occurs when an application executes one query to fetch a list of N records, then executes N additional queries to fetch related data for each record individually — fixable by using a JOIN or a single batched query with IN/WHERE

B

Correct Answer

It occurs when an application executes one query to fetch a list of N records, then executes N additional queries to fetch related data for each record individually — fixable by using a JOIN or a single batched query with IN/WHERE

Explanation

The N+1 problem causes excessive round trips to the database; rewriting the access pattern to use a JOIN or a single query with "WHERE id IN (...)" retrieves all needed data in one or few queries instead of N+1.

Progress
89/100