Optimize merge request refresh by using the database to check commit SHAs
Previously for a given merge request, we would:
- Create the array of commit SHAs involved in the push (A)
- Request all merge request commits and map the SHA (B)
- 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