Investigate if BranchesController#index.json can avoid loading some information from Gitaly by paginating
<!--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=345590)
</details>
<!--IssueSummary end-->
The following discussion from !74058 should be addressed:
- [ ] `@reprazent` started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74058#note_728047464): (+2 comments)
> I think this makes sense for all of these. But `#index` is busy enough to look into further.
>
> This endpoint also seems to have very different characteristics based on the format. The `json` format is called way more often, and only renders branch names: https://gitlab.com/gitlab-org/gitlab/blob/636f2ca5ba3769719dc865a01f9445f89fcf0ff9/app/controllers/projects/branches_controller.rb#L45
> An optimization there could be to not load branches that we'll filter out with `#paginate_array`, but instead use the pagination Gitaly provides: https://gitlab.com/gitlab-org/gitlab/blob/636f2ca5ba3769719dc865a01f9445f89fcf0ff9/app/finders/branches_finder.rb#L9
>
> I think we should be able to set a higher urgency for the more common JSON part of this.
issue