#30079: Prefetch cache should be aware of database source and .using() should 
not
always trigger a new query
-------------------------------------+-------------------------------------
     Reporter:  Mike Lissner         |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Documentation        |                  Version:  master
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  prefetch,            |             Triage Stage:
  multidatabase                      |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => wontfix
 * has_patch:  0 => 1
 * component:  Database layer (models, ORM) => Documentation


Comment:

 OK, at best, this is a cleanup on the documentation. The admonition note
 in the
 
[https://docs.djangoproject.com/en/2.1/ref/models/querysets/#django.db.models.query.QuerySet.prefetch_related
 `prefech_related` docs] already covers this:

 > Remember that, as always with **QuerySets**, any subsequent chained
 methods which imply a different database query will ignore previously
 cached results, and retrieve data using a fresh database query.

 `using()` is a ''subsequent chained method''. It returns a new QuerySet,
 and the results and prefetch caches are not transferred.

 Arguably, `using()`, whilst returning a new QuerySet, doesn't actually
 imply a different query.

 As such I drafted the attached patch.

 > ... as always with ``QuerySets``, any subsequent chained methods which
 return a new ``QuerySet``, normally implying a different database query
 ...

 In my opinion, the patch unnecessarily complicates the meaning. We know
 from our use of QuerySets that all the
 [https://docs.djangoproject.com/en/2.1/ref/models/querysets/#methods-that-
 return-new-querysets Methods that return new QuerySets] behave this way,
 even if we might forget it occasionally. Thus `wontfix`.

 Thanks for the report Mike!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30079#comment:3>
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/066.9a293191d2f6aaf304c853bc39b82b11%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to