#25464: Allow skipping IN clause on prefetch queries
-------------------------------------+-------------------------------------
     Reporter:  ecederstrand         |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by adamchainz):

 1) Presumably the reason {{{prefetch_related}}} is being used is to avoid
 fetching the category data repeated many times, is {{{select_related}}}
 does by including it in the join. You can keep the prefetching with:

 {{{
 Item.objects.filter(category__type=5).prefetch_related('category')
 }}}

 2) See #25279 for my simple suggestion of making
 {{{prefetch_related_objects}}} a public API, which simply exposes the pre-
 existing prefetch code for "joining in python" mechanism. I don't know if
 it would actually solve this problem though.

--
Ticket URL: <https://code.djangoproject.com/ticket/25464#comment:6>
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/070.4e0ef8abfb38dcb89b5a62d2ba567b2a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to