From: Stewart Smith Date: Fri, 10 Aug 2018 08:01:06 +0000 (+1000) Subject: Fetch maintainer information in one query X-Git-Tag: v2.2.0-rc1~291 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=880ec8c5;p=thirdparty%2Fpatchwork.git Fetch maintainer information in one query Viewing the /project/ page lists maintainers. Prior to this patch, this was done in one query to fetch the maintainer IDs, and then one query per mainatiner to get the name/email address. Now, with this patch, it's all in one query (yay joins) and saves a few ms of database queries for displaying the page. Realistically, this doesn't save us too much time as counting how many patches are there takes 99% of the database time for this page. Signed-off-by: Stewart Smith Reviewed-by: Stephen Finucane --- diff --git a/patchwork/views/project.py b/patchwork/views/project.py index b83dabfa..a0c4db42 100644 --- a/patchwork/views/project.py +++ b/patchwork/views/project.py @@ -70,7 +70,7 @@ def project_detail(request, project_id): context = { 'project': project, 'maintainers': User.objects.filter( - profile__maintainer_projects=project), + profile__maintainer_projects=project).select_related('profile'), 'n_patches': n_patches[False] if False in n_patches else 0, 'n_archived_patches': n_patches[True] if True in n_patches else 0, 'enable_xmlrpc': settings.ENABLE_XMLRPC,