Opened 5 years ago

Last modified 5 years ago

#30842 closed Cleanup/optimization

Prefetch_related spends considerable time constructing querysets. — at Version 1

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 (last modified by Alex Aktsipetrov)

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, roughly 2/3 of the time are spent there.

Change History (2)

by Alex Aktsipetrov, 5 years ago

Attachment: prefetch.svg.gz added

comment:1 by Alex Aktsipetrov, 5 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top