← Fullstack with Vue.jsQuestion 44 of 62
When you call select_related("author") on a Book queryset, what kind of SQL join does Django generate? Does it always use the same join type?
📘 Explanation
Django chooses the join type based on the field's nullability: INNER JOIN when the ForeignKey is required, and LEFT OUTER JOIN when it's nullable so related-less rows aren't excluded. The wrong answers claim a single fixed join type regardless of nullability or describe mechanisms like CROSS JOIN with Python filtering that Django doesn't actually use.
Related questions
- What Django ORM feature lets you get "top N per group" (e.g. most expensive product per category) while handling ties…
- What's the difference between annotate() vs values().annotate() in Django ORM?
- What does Django's extra() method do, and when would you use it?
- When do you use selectrelated() vs prefetchrelated() in Django?
- Given a Book model with a ForeignKey to Author, how do you query the most expensive book per author in Django ORM?
← PreviousNo login needed