#30124: QuerySet.only() on reverse many-to-one relationship causes extra 
database
queries
-------------------------------------+-------------------------------------
     Reporter:  Beda Kosata          |                    Owner:  Dan Davis
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Having spent a bit of time in refactoring `only` and `defer` for #21204
 ([https://github.com/django/django/pull/15985 PR]) I think the proper
 solution is likely not to introspect aliases and try to make the best of
 it but to add a new attribute to `Query` that denotes fields that must
 always be present when the select mask is generated.

 We already do so for all primary keys of models involved in
 `select_related`/`only` or `defer` combinations so if this attribute was
 present and the `get_queryset` method of reverse manager set it as
 `queryset.query.select_mask = {rel}` and then a copy of this value could
 be used in ` _get_defer_select_mask` and ` _get_only_select_mask`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30124#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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070182ce18c352-822c9919-c3e9-49dc-8176-0b34a463e1bf-000000%40eu-central-1.amazonses.com.

Reply via email to