Reading a Code Review Thread
5 exercises — read a realistic GitHub code review thread about an N+1 query problem. Understand reviewer-author communication, eager loading, and code review vocabulary.
Reading code review threads
- Identify the type of each comment: blocker, suggestion, question, or praise
- Track how the author responds: acknowledgement, explanation, question, or fix
- LGTM = Looks Good To Me (approval); nit: = minor optional suggestion
- Look for the resolution — was the issue fixed? How was it verified?
- N+1 query = 1 query for the list + N queries for each item = performance problem
0 / 5 completed
1 / 5
Code Review Thread — PR #612
{ex.passage} What specific technical problem does Priya identify in Comment 1?
N+1 query problem — one SQL query per loop iteration:
Priya's Comment 1 identifies: "calling UserRepository.findById(userId) for each activity item... this will fire 100+ separate SQL queries."
What is the N+1 problem?
Imagine 100 activity items:
Why it matters for performance:
Each SQL query has network overhead, connection overhead, and parse/plan cost. 100 queries vs. 2 can mean 500ms vs. 5ms on a loaded database — a 100x difference that's invisible in development but catastrophic in production.
Why the name "N+1":
The "1" is the initial query (get the list), and the "N" is the per-item query that should have been batched. The pattern is named for the count: 1 + N total queries.
Priya's Comment 1 identifies: "calling UserRepository.findById(userId) for each activity item... this will fire 100+ separate SQL queries."
What is the N+1 problem?
Imagine 100 activity items:
- Query 1: fetch all 100 activities
- Query 2: fetch user for activity #1
- Query 3: fetch user for activity #2
- ... 100 more queries ...
- Query 101: fetch user for activity #100
Why it matters for performance:
Each SQL query has network overhead, connection overhead, and parse/plan cost. 100 queries vs. 2 can mean 500ms vs. 5ms on a loaded database — a 100x difference that's invisible in development but catastrophic in production.
Why the name "N+1":
The "1" is the initial query (get the list), and the "N" is the per-item query that should have been batched. The pattern is named for the count: 1 + N total queries.