Store the number of merge request commits in merge_request_diffs.commits_count
This removes the need for running a SELECT COUNT(*)
for every merge request diff just to figure out what the number of commits is. An alternative is to run 1 COUNT(*) for a group of diffs and use a GROUP BY
, but such a query can be quite expensive. See https://gitlab.com/gitlab-org/gitlab-ce/issues/36880#note_40753492 and the preceding comments for more information.