Fix `PipelinesForMergeRequestFinder` doing cross-join to `projects`, `merge_requests`, `commits`
From !62092 (closed) we have seen that PipelinesForMergeRequestFinder
needs to join across many tables to find a list of latest pipelines for merge requests:
Scopes to fix
#all
#pipelines_using_cte
#filter_by_sha
#filter_by
Options
- Evaluate if we can
.ids
to fetchids
and use two separate queries - Change how the feature is being used, and remove this method all together
- Take a look at some naive changes (not ideal, but breaking some aspects): https://gitlab.com/gitlab-org/gitlab/-/blob/a9c318847faad3b6db4e5d51440c009cff578dff/app/finders/ci/pipelines_for_merge_request_finder.rb