#26172: Don't query the database when filtering an already empty queryset
-------------------------------------+-------------------------------------
Reporter: seddonym | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: orm, queryset | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by seddonym):
Hmm, I see what you mean, but couldn't you make the same argument for
''any'' queryset caching? Consider:
{{{
>>> Foo.objects.all().delete()
>>> qs = Foo.objects.all()
>>> bool(qs)
False
>>> Foo.objects.create(pk=1)
>>> qs
# The cached results will be fetched
[]
}}}
I guess it depends on what you want the caching strategy to be. On the
one hand, returning an empty cached queryset is simply using the cache
that's available, which might be the right thing to do in some
circumstances. On the other, perhaps whenever filter() or exclude() are
applied, it should always invalidate the cache.
--
Ticket URL: <https://code.djangoproject.com/ticket/26172#comment:2>
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.c788c37126203207ad446f8e40d1942f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.