Card 02/ 06
All 6 cards
ExampleDifficulty: Intermediate1 min
What N+1 Costs in Milliseconds
A single query taking 20 milliseconds is nothing to notice. Thirty of them, one per row in a list endpoint, is a different number entirely — and it's paid before anything else in the request has even started.
| Queries | Each | Before any other processing |
|---|---|---|
| 30 | 20ms | 600ms |
That 600ms is a floor, not a total — serialising the response, running any business logic, and the network round trip to the client all still come after it. A list endpoint that feels sluggish "for no reason" very often has exactly this shape underneath: not one slow thing, but thirty fast things that were never meant to run one at a time.
- Spring Boot
- Performance