]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/views/__init__.py
views/generic_list: reduce number of queries in list rendering
[patchwork] / apps / patchwork / views / __init__.py
index 4c636182ed30fc82e3e927286776816934b85289..9d1d144fcb7b30e555a870fa80230d9d507b39d6 100644 (file)
@@ -108,6 +108,14 @@ def generic_list(request, project, view,
     if not editable_order:
         patches = order.apply(patches)
 
+    # we don't need the content or headers for a list; they're text fields
+    # that can potentially contain a lot of data
+    patches = patches.defer('content', 'headers')
+
+    # but we will need to follow the state and submitter relations for
+    # rendering the list template
+    patches = patches.select_related('state', 'submitter')
+
     paginator = Paginator(request, patches)
 
     context.update({