From f1047dd4b330d5f9011076f346422f2b322ada9f Mon Sep 17 00:00:00 2001 From: Evangelos Foutras Date: Tue, 26 Jan 2010 07:03:40 +0200 Subject: Drastically reduce loading time of Todo lists Use Django's select_related() on the TodolistPkg QuerySet to avoid making 4 database queries per package. This way we're making just one query, regardless of the number of packages in the Todo list. Local testing with 1000 entries in a Todo list show that the loading time has been reduced from 2675 ms to around 560 ms, while the number of queries has been cut down from 8005, to only 5. Signed-off-by: Dan McGee --- main/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main') diff --git a/main/models.py b/main/models.py index d65c8470..71b9e181 100644 --- a/main/models.py +++ b/main/models.py @@ -303,7 +303,7 @@ def __unicode__(self): @property def packages(self): - return TodolistPkg.objects.filter(list=self.id).order_by('pkg') + return TodolistPkg.objects.select_related().filter(list=self).order_by('pkg') @property def package_names(self): -- cgit v1.2.3-54-g00ecf