The checks for each Patch are queried each time patches are listed.
This causes a deluge of queries (around one per patch). Mitigate this
by instead prefetching this related attribute. This reduces the number
of queries for a list of 100 patches from an average of 119 to 20.
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
# rendering the list template
patches = patches.select_related('state', 'submitter', 'delegate')
+ # we also need checks
+ patches = patches.prefetch_related('check_set')
+
paginator = Paginator(request, patches)
context.update({