On Feb 20, 12:18 am, Yo-Yo Ma <baxterstock...@gmail.com> wrote: > Speaking with regards to the ORM method documented > athttps://docs.djangoproject.com/en/dev/ref/models/querysets/#prefetch-... > > Of course, ``prefetch_related`` uses a Pythonic join to attach reverse- > related objects and avoids the N+1 queries problem, which of course is > great. However, if you use it like this: > > >>> Restaurant.objects.prefetch_related('best_pizza__toppings__topping_type') > > It doesn't seem to take advantage ``select_related`` (assuming that > ``topping_type`` is a ``ForeignKey`` from ``Topping``. It instead > sends a separate query for ``Topping`` and ``ToppingType``, joining > them in Python. Is it feasible to modify ``prefetch_related`` use > ``select_related`` when it encounters a ``ForeignKey``?
Basically a good idea. However, the current stage of prefetch_related development is "wait and see". That is, prefetch_related is new and there isn't too good knowledge of why and how people will use it. So, wait a month or two and after 1.4 has been out for a little while there is much better knowledge of the pain-points. - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.