Spotting the N+1 Problem
Recognize the classic per-row query trap.
What N+1 Means
The N+1 problem is when your code runs one query to get a list, then one more query for each item in it. 🐢
Where It Hides
It usually hides in a loop over objects, where each pass quietly touches a related row in the database again and again.
All lessons in this course
- Spotting the N+1 Problem
- select_related for Foreign Keys
- prefetch_related for M2M
- Profiling with Debug Toolbar