Skip to content

Optimize merge request refresh by using the database to check commit SHAs

Stan Hu requested to merge sh-optimize-mr-commit-sha-lookup into master

Previously for a given merge request, we would:

  1. Create the array of commit SHAs involved in the push (A)
  2. Request all merge request commits and map the SHA (B)
  3. Reload the diff if there were any common commits between A and B

We can avoid additional database querying and overhead by checking with the database whether the merge request contains any of the commit SHAs.

Relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/53213

In https://gitlab.com/gitlab-org/gitlab-ce/issues/49703#note_113602024, we see that a push to the staging www-gitlab-com resulted in 204 queries for SELECT * FROM merge_request_diff_commits.

Edited by Stan Hu

Merge request reports

Loading