In plain words
An N+1 problem happens when code fetches a list with one query and then runs another query for each item, so a page showing 50 rows sends 51 queries instead of one or two.
Where you see it
Harbor's team page lists the members, then looks up each member's profile in a loop. It feels instant with five members on your laptop and takes three seconds for a large customer, and the query log shows the same select repeated 200 times with different ids.
What goes wrong
- Only testing with a little data
With three seed rows, four queries take no time at all. Seed a team with hundreds of members and the problem shows up on your laptop.
- A loop you can't see
An ORM relation loaded inside a map, or a list of server components that each fetch their own row, sends one query per item with no visible loop. Turn on query logging and count.
- Fixing it by fetching everything
Loading the whole users table to avoid 50 small queries trades one problem for another. Fetch only the rows you need, with a join or a single where id in (...) query.
What to tell your agent
Quick check
Sign in to earn +10 XP for itHarbor's invoice list runs 1 query to get 100 invoices, then 1 query per invoice to fetch its team. How many queries does each page load send?