Improve performance for Vulnerability Report
<!--
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
-->
## Why are we doing this work
[This test](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51081#note_481125860) is failing intermittently because of performance issues on the group security dashboard.
It is likely that the issue is frustrating users with a large number of projects/vulnerabilities.
## Relevant links
- [slack thread](https://gitlab.slack.com/archives/CV09DAXEW/p1610025792174500) (internal link). Please copy contents to issue if any information will be vital after 90 days (deleted then due to slack retention policy)
- The [sentry error](https://sentry.gitlab.net/gitlab/gitlabcom/issues/2447500/?query=is%3Aunresolved%20correlation_id%3A01EWNN4B4Y06BP1JB06D9N921B) for the **project** security dashboard.
- The [sentry error](https://sentry.gitlab.net/gitlab/gitlabcom/issues/2453143/) for the **group** security dashboard.
## Non-functional requirements
<!--
Add details for required items and delete others.
-->
- [ ] Documentation:
- [ ] Feature flag:
- [ ] Performance:
- [ ] Testing:
## Implementation plan
<!--
Steps and the parts of the code that will need to get updated. The plan can also
call-out responsibilities for other team members or teams.
-->
- [ ] gitlab~2492649 identify slow DB queries
- Run the scopes in `ee/app/models/ee/vulnerability.rb` through the DB analyzer in #database-lab
- Test against projects with different counts of vulnerabilities
- https://gitlab.com/gitlab-org/gitlab
- https://gitlab.com/gitlab-org/threat-management/defend/demos/webgoat
- The analyzer should provide suggestions to improve the queries.
- For each query that the analyzer has suggestions, create an issue in this epic.
- [ ] gitlab~2492649 implement indices and verify improvement
<!--
Workflow and other relevant labels
~"group::" ~"Category:" gitlab~3207279
-->
<!--
Other settings you might want to include when creating the issue.
-->
epic