Try impact of prefetch_related data
from db.models.build_jobs import BuildJob
-builds = BuildJob.objects.select_related(
+builds = BuildJob.objects.select_related('status')
+builds = builds.prefetch_related(
'user',
'project',
- 'project__user',
- 'status')
+ 'project__user',)
builds_details = builds.select_related('code_reference')
