Hello,
for the rendering of one View I want to execute two queries:
class A(model.Model):
i = models.CharField(max_length=10)
class B(model.Model):
f = models.ManyToManyField(A, on_delete...)
j = models.CharField(max_length=10)
- All objects of type A
queryset1 = A.objects.all()
- All objects of type B prefetching the related objects of type A:
queryset2 = B.objects.prefetch_related('f')
Under these conditions the table A is SELECTEd twice: once all elements are
picked up and the result is cached in queryset1. The second time the columns
of table A are touched again, if they stay in relation to B objects.
Is there any way to feed into queryset2 the (prefetched) results from
queryset1, so that the second SELECT ... FROM A can be prevented (and the join
can still happen python-side in RAM)?
Thanks in advance for your answer
Dilian
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/0f964f60-d683-4338-bfea-e108d74e036a%40aegee.org.
For more options, visit https://groups.google.com/d/optout.