Skip to content

N+1 queries in /-/jira/pulls

Proposal

For our integration with the Jira Server Development Panel, 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 are min: 36, max 4k, average: 391.

Click to see original issue problem description (which was solved at some earlier point) 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. #29741 (closed) was a similar, but much worse, issue in the same API.

Issue created from !18329 (comment 228030019).

Impact

A significant (10x) improvement was achieved, see details below #33741 (comment 545655423).

cc @deuley @nhxnguyen

Edited by Chun Du