Branches search is slow on projects with many branches
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=440427) </details> <!--IssueSummary end--> <!-- Implementation issues are used break-up a large piece of work into small, discrete tasks that can move independently through the build workflow steps. They're typically used to populate a Feature Epic. Once created, an implementation issue is usually refined in order to populate and review the implementation plan and weight. Example workflow: https://about.gitlab.com/handbook/engineering/development/threat-management/planning/diagram.html#plan --> ## Summary On `gitlab-org/gitlab`, searching for a branch takes a long time. ![branches_search](/uploads/f37fdc539bab2d78c7e7a61b5a42f356/branches_search.mov) At the time of this writing, the project has over 17,000 branches and this search is implemented as [an O(n) search in `GitRefsFinder`](https://gitlab.com/gitlab-org/gitlab/-/blob/1aa6cd0ee1620eb2318e109cd6aff699d7ebf4ea/app/finders/git_refs_finder.rb#L39), which could be the reason behind the slowness. This could potentially be optimized.
issue