#29078: Serializer handle_m2m_field should honour any previous prefetch
-------------------------------------+-------------------------------------
Reporter: xx396 | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: 2.0
(Serialization) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by xx396:
Old description:
> Example:
>
> from django.contrib.auth.models import Group
> from django.core import serializers
>
> groups = Group.objects.prefetch_related('permissions').all()
> serializers.serialize('json', groups)
>
> This will N+1 query the permissions as handle_m2m_field uses iterator()
> which bypasses any cache. Suggest serializers/python.py line 77 replaces
> iterator() with all()
New description:
Example:
from django.contrib.auth.models import Group
from django.core import serializers
groups = Group.objects.prefetch_related('permissions').all()
serializers.serialize('json', groups)
This will N+1 query the permissions as handle_m2m_field uses iterator()
which bypasses any cache. Suggest serializers/python.py line 78 replaces
iterator() with all()
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29078#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/063.8eb239a27cd8a03cdaf2f738470b11ac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.