#25789: Inefficient Queries Generated due to not using WHERE EXISTS
-------------------------------------+-------------------------------------
Reporter: Alex Rothberg | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: QuerySet.extra | 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):
Another ''nice to have'' that could be added here would be allow the usage
of transforms on related fields so we could have lookups of the form
`__exists` or `__count`
{{{#!python
Author.objects.filter(books__exists=Q(title__icontains="ring"))
Author.objects.filter(books__count__gt=4)
}}}
instead of
{{{#!python
Author.objects.filter(Exist(Book.objects.filter(author=OuterRef("pk"),
title__icontains="ring")))
Author.objects.filter(
GreaterThan(
Book.objects.filter(
author_id=OutRef("pk"),
).values(
"author_id"
).values(Count("id")), 4
)
)
}}}
I think it would go a long way in making it easier for users to work
around this issue and #10060.
--
Ticket URL: <https://code.djangoproject.com/ticket/25789#comment:10>
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/01070182cb73d904-84e6474c-1d6b-4e12-8198-b307b0d45c28-000000%40eu-central-1.amazonses.com.