#26318: Unexpected / duplicated queries on nested Prefetch queryset with 
repeated
model
-------------------------------------+-------------------------------------
     Reporter:  aleontiev            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  queryset             |             Triage Stage:  Accepted
  prefetch_related duplicate         |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by melinath):

 I just ran into this as well, but without recursion. i.e. (with apologies
 for the implied structure)

 {{{
 users = User.objects.prefetch_related(
     Prefetch(
         'person',
         queryset=Person.objects.prefetch_related(
             'books',
         ),
     ),
 )
 }}}

 would generate 4 queries instead of three (because the books are
 duplicated).

 To be clear, this is a trimmed down version of the actual query I'm trying
 to construct. I haven't tested it (and I don't know whether I'll be able
 to any time soon.) Someone should try tweaking the test case to not use
 recursion, is all I'm saying.

--
Ticket URL: <https://code.djangoproject.com/ticket/26318#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.6baa95982eaefdc99c25dfe17d27bfac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to