﻿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
14396	Admin generates a query burst on ForeignKey with null = True	piro	Daniel Roseman	"When the The admin loads a list of objects to display the change list, it is supposed to [http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_select_related use select_related()] to fetch ForeignKey fields in the display list.

Because it uses the form select_related() without the filed name, [http://docs.djangoproject.com/en/1.2/ref/models/querysets/#django.db.models.QuerySet.select_related the records are not fetched if the property has null=True]. This generates a burst of up of 100 query to display the admin page for such a model.

Attached there is a preliminary patch to fix the issue. It is probably to be improved as it doesn't kick in if the model is configured with list_select_related=True or if select_related() was already called on the query.
"	Cleanup/optimization	closed	contrib.admin	1.2	Normal	duplicate	admin database performance	semenov@… Brillgen Developers erik.wognsen@…	Accepted	1	0	0	0	0	0
