]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
Be particular over check_set and series prefetch for /list/
authorStewart Smith <stewart@linux.ibm.com>
Fri, 10 Aug 2018 08:01:02 +0000 (18:01 +1000)
committerStephen Finucane <stephen@that.guru>
Mon, 10 Sep 2018 20:24:24 +0000 (14:24 -0600)
At this point it shaves at most 1-2ms off the query time for
/linuxppc-dev/list/

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/views/__init__.py

index f66963f586d256bbd4f8f1eaced72fed7119f34a..5942ded8e8e007e144b7fa87390e3263945c3279 100644 (file)
@@ -19,6 +19,7 @@
 
 from django.contrib import messages
 from django.shortcuts import get_object_or_404
+from django.db.models import Prefetch
 
 from patchwork.filters import Filters
 from patchwork.forms import MultiplePatchForm
@@ -26,6 +27,8 @@ from patchwork.models import Bundle
 from patchwork.models import BundlePatch
 from patchwork.models import Patch
 from patchwork.models import Project
+from patchwork.models import Check
+from patchwork.models import Series
 from patchwork.paginator import Paginator
 
 
@@ -290,7 +293,11 @@ def generic_list(request, project, view, view_args=None, filter_settings=None,
                            'name', 'date')
 
     # we also need checks and series
-    patches = patches.prefetch_related('check_set', 'series')
+    patches = patches.prefetch_related(
+        Prefetch('check_set', queryset=Check.objects.only(
+            'context', 'user_id', 'patch_id', 'state', 'date')))
+    patches = patches.prefetch_related(
+        Prefetch('series', queryset=Series.objects.only('name')))
 
     paginator = Paginator(request, patches)