#5895: inline-edit performance problem after changeset 6655
----------------------------------------------+-----------------------------
Reporter: Karen Tracey <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Component: django.newforms
Version: newforms-admin | Keywords:
Stage: Unreviewed | Has_patch: 1
----------------------------------------------+-----------------------------
I noticed a massive performance problem today after updating to the latest
newforms-admin. Attempting to load a change page for one of my models
that has another model edited inline pegged the CPU and started eating
memory. I tracked it down to this code in /django/newforms/models.py, in
the init for BaseModelFormSet:
{{{
if self.queryset:
kwargs['initial'] = [initial_data(obj) for obj in
self.get_queryset()]
}}}
Problem is self.queryset is an unfiltered queryset for the entire inline-
edited model, it is not filtered by the pk of the parent instance until
the self.get_queryset() call in the 2nd line, and "if self.queryset:"
actually (apparently) calls {{{ __len__ }}} on the queryset. {{{ __len__
}}} in turn calls _get_data(), which in my case meant going and retrieving
over 800,000 rows from the database, bringing my machine to its knees.
Fix (attached) is simple:
{{{
if self.queryset is not None:
kwargs['initial'] = [initial_data(obj) for obj in
self.get_queryset()]
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/5895>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---