Almost rightLesson 071 min
Correct, and far slower than it should be
The code fetches a list of orders with one query, then sends another query for each order to look up the customer's name. With a hundred orders that is a hundred and one trips to the database. It feels instant on test data and crawls on a hundred thousand orders. This is the N plus one problem. A join returns everything in a single query.
Remember
A database query inside a loop is a warning sign, so count your queries.
