Skip to content

Commit 53f3977

Browse files
committed
xmlrpc/patch_list: only fetch required fields
OzLabs noticed *massive* slowdowns in queries like this one: SELECT "patchwork_submission"."id", "patchwork_submission"."msgid", "patchwork_submission"."date", "patchwork_submission"."headers", "patchwork_submission"."submitter_id", "patchwork_submission"."content", "patchwork_submission"."project_id", "patchwork_submission"."name", "patchwork_patch"."submission_ptr_id", "patchwork_patch"."diff", "patchwork_patch"."commit_ref", "patchwork_patch"."pull_url", "patchwork_patch"."delegate_id", "patchwork_patch"."state_id", "patchwork_patch"."archived", "patchwork_patch"."hash" FROM "patchwork_patch" INNER JOIN "patchwork_submission" ON ("patchwork_patch"."submission_ptr_id" = "patchwork_submission"."id") WHERE ("patchwork_submission"."project_id" = 2 AND "patchwork_patch"."state_id" = 1) ORDER BY "patchwork_submission"."date" ASC These appear to be a result of pwclient list operations. We *do not* need content/headers/diff in this case - so do not fetch them as it is incredibly expensive - queries in excess of 50s have been observed. This should go to stable/2.0. Reported-by: Stephen Rothwell <[email protected]> Reported-by: Michael Ellerman <[email protected]> Cc: Jeremy Kerr <[email protected]> Signed-off-by: Daniel Axtens <[email protected]> Reviewed-by: Stephen Finucane <[email protected]> (cherry picked from commit 76c3dae)
1 parent 8940289 commit 53f3977

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

patchwork/views/xmlrpc.py

+5
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@ def patch_list(filt=None):
585585

586586
patches = Patch.objects.filter(**dfilter)
587587

588+
# Only extract the relevant fields. This saves a big db load as we
589+
# no longer fetch content/headers/etc for potentially every patch
590+
# in a project.
591+
patches = patches.defer('content', 'headers', 'diff')
592+
588593
return _get_objects(patch_to_dict, patches, max_count)
589594

590595

0 commit comments

Comments
 (0)