Reduce N+1 queries when approvals by committers are not allowed
What does this MR do and why?
This reverts commit 6cf9fb71, reversing changes made to 92c318af.
Preload merge_request_diff_commits
association of each MR when mergeRequests
are queried via GraphQL.
We also need to batch load committers and lazy load the value of mergeable
and detailed_merge_status
to prevent N+1 queries for querying committers by their emails.
This also introduces a change to memoize MergeRequest#committers with arguments.
This is to prevent ArgumentError
being raised when MergeRequest#committers
was previously called with lazy: true
and then called again with lazy: false
but with a different expectation of return value (e.g. #select(:id)
gets called on return value).
This also introduces lazy_merge_request_committers
feature flag to only call CommitCollection#committers
with lazy: true
when enabled. This is ensure safety in case this results to errors and can easily be disabled.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Related to #441204 (closed)