#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 Dan Davis):
I'd guess the key is in understanding how the alias_map will look under
different circumstances. When the WorkSet is the base table, and I
examine this:
{{{
WorkSet.objects.filter(works__name='Flying
Car').query.alias_map['queries_work'].__dict__
}}}
I see this:
{{{
{'table_name': 'queries_work',
'parent_alias': 'queries_workset',
'table_alias': 'queries_work',
'join_type': 'INNER JOIN',
'join_cols': (('id', 'work_set_id'),),
'join_field': <ManyToOneRel: queries.wolrk>,
'nullable': True,
'filtered_relation': None}
}}}
The other problem is that even if beginner Django Dev me can fix this
particular problem, getting the treatment of only/defer in the presence of
joins completely consistent will be a bit of a challenge. I know
annotations will not excluded by only() or defer().
--
Ticket URL: <https://code.djangoproject.com/ticket/30124#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/064.8c35f32f6655445eb8dfa6a9eb1c71fa%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.