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

  1. #all
  2. #pipelines_using_cte
  3. #filter_by_sha
  4. #filter_by

Options

  1. Evaluate if we can .ids to fetch ids and use two separate queries
  2. Change how the feature is being used, and remove this method all together
  3. 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