#30842: Prefetch_related spends considerable time constructing querysets.
-------------------------------------+-------------------------------------
Reporter: Alex Aktsipetrov | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: prefetch_related | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* stage: Unreviewed => Accepted
Comment:
Thanks for the report Alex, this was a concern raised during the
implementation https://code.djangoproject.com/ticket/26226#comment:2.
I'm tentatively accepting as we should definitely address this if
possible.
Ideally only proxies to the original queryset would be created to defer
the creation of querysets to only if needed. FWIW
[https://github.com/django/django/pull/6159/commits/c92123cc1dceeb800b3b8900e2e530ed19d78863
#diff-5b0dda5eb9a242c15879dc9cd2121379L1625 N querysets were created
prefetching even before] c92123cc1dceeb800b3b8900e2e530ed19d78863. It's
true that the latter made the matter worse though by performing an
addition `filter` call.
I wonder if performing some form of local memoization per related manager
class to call `manager._apply_rel_filters` only once manager type and
using queryset cloning could speed up things a bit here. Happy to give it
a broad try if that can get you started Alex.
--
Ticket URL: <https://code.djangoproject.com/ticket/30842#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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.92418d5a56f9aa534294014535171e20%40djangoproject.com.