﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5895	inline-edit performance problem after changeset 6655	Karen Tracey <kmtracey@…>	jkocherhans	"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()]

}}}

"		closed	Forms	newforms-admin		fixed			Accepted	1	0	0	0	0	0
