N+1 queries in /-/jira/pulls
### Proposal For our [integration with the Jira Server Development Panel](https://docs.gitlab.com/ee/integration/jira_development_panel.html), we have to mimic the GitHub API. (See https://bitbucket.org/atlassian/jira-dvcs-connector/pull-requests/100/gitlab-support-for-jira-63x for some background on why.) The `/-/jira/pulls` endpoint has N+1 SQL query issues when loading associations for merge requests. Current [SQL requests per request](https://dashboards.gitlab.net/d/api-rails-controller/api-rails-controller?orgId=1&var-PROMETHEUS_DS=Global&var-action=All&var-controller=Grape&var-environment=gprd&var-stage=main&from=1616526120000&to=1616547779999) are `min: 36, max 4k, average: 391`. <details> <summary>Click to see original issue problem description (which was solved at some earlier point)</summary> The endpoint `/-/jira/pulls` has an N+1 query when checking plans on projects for merge requests: https://gitlab.com/gitlab-org/gitlab/blob/v12.3.0-ee/ee%2Flib%2Fapi%2Fv3%2Fgithub.rb#L65 This is not too bad because N is limited by the page size, but we should address it. https://gitlab.com/gitlab-org/gitlab/issues/29741 was a similar, but much worse, issue in the same API. Issue created from https://gitlab.com/gitlab-org/gitlab/merge_requests/18329#note_228030019. </details> ### Impact A significant (10x) improvement was achieved, see details below https://gitlab.com/gitlab-org/gitlab/-/issues/33741#note_545655423. cc @deuley @nhxnguyen
issue