Message ID | 20180810080106.10714-10-stewart@linux.ibm.com |
---|---|
State | Accepted |
Headers | show |
Series | Performance for ALL THE THINGS! | expand |
On Fri, 2018-08-10 at 18:01 +1000, Stewart Smith wrote: > Prior to this patch, a typical /patch// query for linuxppc-dev > (which has about half a dozen checks per patch) took around 20 queries > and 16.5ms in the database. About half of those queries were fetching > the checks and who did the check. > > We can just do one query to get all that needed information, so we do > that. This brings a page load down to 10 queries in 12ms. > > Signed-off-by: Stewart Smith <stewart@linux.ibm.com> Yet again, "don't do stuff in templates". This is the fix I referenced in the review for patch 1. I'm actually rather annoyed I didn't see this myself sooner. Reviewed-by: Stephen Finucane <stephen@that.guru> Stephen > --- > patchwork/templates/patchwork/submission.html | 4 ++-- > patchwork/views/patch.py | 1 + > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html > index 3b6f9fbe909e..72bc947c3f2d 100644 > --- a/patchwork/templates/patchwork/submission.html > +++ b/patchwork/templates/patchwork/submission.html > @@ -216,7 +216,7 @@ function toggle_div(link_id, headers_id) > >{{ submission.pull_url }}</a> > {% endif %} > > -{% if submission.checks %} > +{% if checks %} > <h2>Checks</h2> > <table class="checks"> > <tr> > @@ -224,7 +224,7 @@ function toggle_div(link_id, headers_id) > <th>Check</th> > <th>Description</th> > </tr> > -{% for check in submission.checks %} > +{% for check in checks %} > <tr> > <td>{{ check.user }}/{{ check.context }}</td> > <td> > diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py > index e1d0cdcfcf39..fbde04280844 100644 > --- a/patchwork/views/patch.py > +++ b/patchwork/views/patch.py > @@ -119,6 +119,7 @@ def patch_detail(request, patch_id): > comments = comments.only('submitter','date','id','content','submission') > > context['all_series'] = patch.series.all().order_by('-date') > + context['checks'] = patch.check_set.all().select_related('user') > context['comments'] = comments > context['submission'] = patch > context['patchform'] = form
diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 3b6f9fbe909e..72bc947c3f2d 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -216,7 +216,7 @@ function toggle_div(link_id, headers_id) >{{ submission.pull_url }}</a> {% endif %} -{% if submission.checks %} +{% if checks %} <h2>Checks</h2> <table class="checks"> <tr> @@ -224,7 +224,7 @@ function toggle_div(link_id, headers_id) <th>Check</th> <th>Description</th> </tr> -{% for check in submission.checks %} +{% for check in checks %} <tr> <td>{{ check.user }}/{{ check.context }}</td> <td> diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index e1d0cdcfcf39..fbde04280844 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -119,6 +119,7 @@ def patch_detail(request, patch_id): comments = comments.only('submitter','date','id','content','submission') context['all_series'] = patch.series.all().order_by('-date') + context['checks'] = patch.check_set.all().select_related('user') context['comments'] = comments context['submission'] = patch context['patchform'] = form
Prior to this patch, a typical /patch// query for linuxppc-dev (which has about half a dozen checks per patch) took around 20 queries and 16.5ms in the database. About half of those queries were fetching the checks and who did the check. We can just do one query to get all that needed information, so we do that. This brings a page load down to 10 queries in 12ms. Signed-off-by: Stewart Smith <stewart@linux.ibm.com> --- patchwork/templates/patchwork/submission.html | 4 ++-- patchwork/views/patch.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)