Opened 5 years ago

Last modified 5 years ago

#30842 closed Cleanup/optimization

Prefetch_related spends considerable time constructing querysets. — at Initial Version

Reported by: Alex Aktsipetrov Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: prefetch_related
Cc: Simon Charette Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As part of the bugfix django started constructing N+1 querysets during a typical prefetch_related call while only 2 sql queries are executed.

This adds a noticeable slowdown. Attaching the flamegraph for queryset fetching 100 objects.

Change History (1)

by Alex Aktsipetrov, 5 years ago

Attachment: prefetch.svg.gz added
Note: See TracTickets for help on using tickets.
Back to Top