Change back to use pipeline.builds in Ci::UnlockPipelineService#builds_relation

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

The following discussion from !192103 (merged) should be addressed:

  • @drew started a discussion: (+4 comments)

    (see https://gitlab.com/gitlab-org/gitlab/-/issues/436361) which limits the pipeline size to maximum 2000.

    Therefore, there shouldn't be a problem in the future, plus this MR is mainly a fix for the performance issue of existing data.

    Thinking about this and that to some extent we're adding complexity to only handle existing data and we expect to never produce new data sets like these.

    Should we make a note about trying to put this back at some point? In theory these external statuses should go away eventually.

Problem

The CTE query is a optimized solution for large pipelines that have more than 150k (see the original issue and performance analyze at #435737 (comment 1700189753)).

When we get rid of these large pipelines, we should change back to use pipeline.builds to simplify the implementation for Ci::UnlockPipelineService#builds_relation

Edited by 🤖 GitLab Bot 🤖