Using the example of id:
20180720035941.6844-1-khandual@linux.vnet.ibm.com
with my test dataset of a chunk of a variety of mailing lists, has
this cover letter have 67 comments from a variety of people. Thus,
it's on the larger side of things.
Originally, displaying the /patch/550/ for this (redirected to /cover)
would take 81 SQL queries in ~60ms on my laptop.
After this optimisation, it's down to 14 queries in 14ms.
When the cache is cold, it's down to 32ms from 83ms.
The effect of this patch is to execute a join in the database to
get the submitter information for each comment at the same time as
getting all the comments rather than doing a one-by-one lookup after
the fact.
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
</pre>
</div>
-{% for item in submission.comments.all %}
+{% for item in comments %}
{% if forloop.first %}
<h2>Comments</h2>
{% endif %}
'project': cover.project,
}
+ comments = cover.comments.all()
+ comments = comments.select_related('submitter')
+ comments = comments.only('submitter', 'date', 'id', 'content',
+ 'submission')
+ context['comments'] = comments
+
return render(request, 'patchwork/submission.html', context)
if request.user.is_authenticated:
context['bundles'] = request.user.bundles.all()
+ comments = patch.comments.all()
+ comments = comments.select_related('submitter')
+ comments = comments.only('submitter', 'date', 'id', 'content',
+ 'submission')
+
+ context['comments'] = comments
context['submission'] = patch
context['patchform'] = form
context['createbundleform'] = createbundleform