From 17252fd17bfbfcc1f495954d075118df834c5f9f Mon Sep 17 00:00:00 2001 From: George Hickman Date: Tue, 15 Aug 2023 14:06:54 +0100 Subject: [PATCH] Only select needed columns for the first run job query Locally this ~halves the execution time for this query, the most expensive on the page. --- jobserver/views/projects.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jobserver/views/projects.py b/jobserver/views/projects.py index 05b4380e5..b83c2111d 100644 --- a/jobserver/views/projects.py +++ b/jobserver/views/projects.py @@ -45,6 +45,7 @@ def get(self, request, *args, **kwargs): job = ( Job.objects.filter(job_request__workspace__project=project) + .only("pk", "job_request_id", "created_at", "started_at") .annotate(first_run=Min(Least("started_at", "created_at"))) .order_by("first_run") .first()