Use p_ci_build_names table to improve queries searching for build name (Part 2)

This issue is part 2 of #423904 (closed)

In the previous issue, we created the new table, the models as well as filling the table with builds and build names.

In this Issue, we'll tackle actually using the table and the database queries involved in getting it performant and complete.

What we want to accomplish in the end:

https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/26602/commands/83371

Note: This'll be a huge improvement if we can add this functionality to the API as well. We can use #22027 to track API changes once this current issue is completed

Edited by Max Fan