#23518: Subquery does not respect explicit __exact
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: subquery subselect | Triage Stage: Accepted
exact |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by shaib):
Replying to [comment:5 john-parton]:
> `Parent.objects.filter(parent__slug='test')` is not the same query. It
uses a join instead of a subquery, and might have different performance
characteristics. Often I refactor a SQL query looking at the output of
`EXPLAIN`, and then try to recreate the query using the ORM.
Whether a specific ORM expression uses a join or a subquery is an
implementation detail which you should not count on; these things are
allowed to change (and have changed in the past) without notice, so long
as the semantics of the query is preserved. The performance
characteristics of a given SQL query, as well, may change between
different databases and even between versions of the same database
product. If your requirements really dictate that you use one form rather
than the other, you should be using raw SQL.
--
Ticket URL: <https://code.djangoproject.com/ticket/23518#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/069.e9215237c8563fd7e36f63453dec1d49%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.