Global Milestones page loads all milestones into memory
<!--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=20313)
</details>
<!--IssueSummary end-->
The page https://gitlab.com/dashboard/milestones will load all milestones into memory, then paginate them as an array:
```ruby
def index
respond_to do |format|
format.html do
@milestone_states = GlobalMilestone.states_count(@projects)
@milestones = Kaminari.paginate_array(milestones).page(params[:page]) # <- here
end
format.json do
render json: milestones
end
end
end
```
This is _really_ bad because given enough milestones this will:
1. Require sending a lot of data over the wire
1. The data queried will be loaded into the PG buffer caches, even if it won't be displayed until page 100
1. All this data will be loaded into memory
1. All of this combined means it can take quite a long time to load these pages (e.g. we currently already spend 326 ms in SQL)
This page needs to be fixed so we:
1. Only load 20 rows at a time
2. Paginate this data using Kaminari, without using `Kaminari.paginate_array`
3. Don't issue an additional COUNT(*) to get the number of pages, instead re-using the state counters displayed in the tabs at the top (just like we do with issues and MRs)
issue