Message ID | 1458069390-18442-1-git-send-email-stephen.finucane@intel.com |
---|---|
State | Accepted |
Headers | show |
On 03/15/2016 02:16 PM, Stephen Finucane wrote: > 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 from an average of 119 to 20. > > Signed-off-by: Stephen Finucane <stephen.finucane@intel.com> Reviewed-by: Andy Doan <andy.doan@linaro.org>
On 15 Mar 16:01, Andy Doan wrote: > On 03/15/2016 02:16 PM, Stephen Finucane wrote: > >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 from an average of 119 to 20. > > > >Signed-off-by: Stephen Finucane <stephen.finucane@intel.com> > > Reviewed-by: Andy Doan <andy.doan@linaro.org> Merged. Thanks for the review.
On 16 Mar 09:52, Finucane, Stephen wrote: > On 15 Mar 16:01, Andy Doan wrote: > > On 03/15/2016 02:16 PM, Stephen Finucane wrote: > > >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 from an average of 119 to 20. > > > > > >Signed-off-by: Stephen Finucane <stephen.finucane@intel.com> > > > > Reviewed-by: Andy Doan <andy.doan@linaro.org> > > Merged. Thanks for the review. Also backported to 'stable/1.1', as this is pretty much a performance bug.
diff --git a/patchwork/views/__init__.py b/patchwork/views/__init__.py index 00ff96e..ae0d561 100644 --- a/patchwork/views/__init__.py +++ b/patchwork/views/__init__.py @@ -263,6 +263,9 @@ def generic_list(request, project, view, # 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({
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 from an average of 119 to 20. Signed-off-by: Stephen Finucane <stephen.finucane@intel.com> --- patchwork/views/__init__.py | 3 +++ 1 file changed, 3 insertions(+)