Home
About
Blog
Courses
Contact
More about Django
· Module 2 - Models and the ORM in depth
2.5 Killing N+1 queries
22 min
Back to the curriculum
Video coming soon
The recording for this lesson has not been published yet.
What we cover
Why the post list suddenly makes 200 queries
select_related for ForeignKey and OneToOne
prefetch_related and Prefetch objects
only, defer and values for narrow queries
Meta.indexes and when an index helps
Written notes for this lesson are being prepared. The outline above already shows what the recording will cover.
← 2.4 Custom managers and querysets
2.6 Slugs, timestamps and abstract base models →
After this lesson you will
Spot an N+1 query problem in a template loop
Fix it with the right prefetching strategy
Module 2
2.1
Relations between models
2.2
Migrations for real
2.3
QuerySets you actually need
2.4
Custom managers and querysets
2.5
Killing N+1 queries
2.6
Slugs, timestamps and abstract base models