Changes between Initial Version and Version 1 of Ticket #33937


Ignore:
Timestamp:
Aug 18, 2022, 8:15:56 AM (2 years ago)
Author:
Adam Johnson
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33937

    • Property Triage Stage UnreviewedAccepted
    • Property Summary Serialize is loading full objects when serializing m2m fields.Optimize m2m serialization to avoid loading full model instances
    • Property Type UncategorizedCleanup/optimization
  • Ticket #33937 – Description

    initial v1  
    1 When not using natural keys, this function https://github.com/django/django/blob/main/django/core/serializers/python.py#L64 loads the full object for every entry in the m2m, when it only actually wants the pks which it could get off the m2m intermediate table without even joining to the target table.
     1When not using natural keys, the `handle_m2m_field` function([https://github.com/django/django/blob/aed60aee38215e293d6ec2f3c96ec55bb9a62fc2/django/core/serializers/python.py#L64 source]) loads the full object for every entry in the m2m model, when it only needs the pks. The pk's can even be obtained from the m2m intermediate table, without joining the target table.
    22
    33In my case the table we are m2m'ing to has files in it, so that's a weighty fetch.
Back to Top