At this point it shaves at most 1-2ms off the query time for
/linuxppc-dev/list/

Signed-off-by: Stewart Smith <stew...@linux.ibm.com>
---
 patchwork/views/__init__.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py
index 96fd0798af5a..64d3d5f9f22d 100644
--- a/patchwork/views/__init__.py
+++ b/patchwork/views/__init__.py
@@ -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.compat import is_authenticated
 from patchwork.filters import Filters
@@ -27,6 +28,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,8 @@ def generic_list(request, project, view, view_args=None, 
filter_settings=None,
     patches = 
patches.only('state','submitter','delegate','project','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)
 
-- 
2.17.1

_______________________________________________
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to