Skip to content

N+1 queries in MergeRequestsController#show

We've seem to have reintroduced a number of N+1 queries in :MergeRequestsController#show:

Gitlab::Profiler.profile("https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14061", logger: Logger.new(STDOUT), user: user)
<snip>
I, [2019-06-14T02:49:37.741576 #31336]  INFO -- : Completed 200 OK in 28469ms (Views: 25766.5ms | ActiveRecord: 1509.1ms | Elasticsearch: 0.0ms)
I, [2019-06-14T02:49:37.757583 #31336]  INFO -- : SystemNoteMetadata total (1): 297.7ms
I, [2019-06-14T02:49:37.757661 #31336]  INFO -- : JobArtifact total (30): 152.1ms
I, [2019-06-14T02:49:37.757679 #31336]  INFO -- : Note total (4): 100.5ms
I, [2019-06-14T02:49:37.757692 #31336]  INFO -- : Build total (30): 69.1ms
I, [2019-06-14T02:49:37.757704 #31336]  INFO -- : User total (28): 53.6ms
I, [2019-06-14T02:49:37.757726 #31336]  INFO -- : Project total (30): 52.0ms
I, [2019-06-14T02:49:37.757738 #31336]  INFO -- : CommitStatus total (4): 47.2ms
I, [2019-06-14T02:49:37.757750 #31336]  INFO -- : Route total (36): 37.5ms
I, [2019-06-14T02:49:37.757762 #31336]  INFO -- : Namespace total (21): 25.1ms
I, [2019-06-14T02:49:37.757774 #31336]  INFO -- : Pipeline total (14): 23.2ms
I, [2019-06-14T02:49:37.757785 #31336]  INFO -- : Label total (10): 22.2ms
I, [2019-06-14T02:49:37.757797 #31336]  INFO -- : AwardEmoji total (5): 22.1ms
I, [2019-06-14T02:49:37.757810 #31336]  INFO -- : MergeRequest total (7): 17.2ms
I, [2019-06-14T02:49:37.757821 #31336]  INFO -- : Issue total (5): 16.6ms
I, [2019-06-14T02:49:37.757832 #31336]  INFO -- : ProtectedBranch total (17): 16.5ms
I, [2019-06-14T02:49:37.757843 #31336]  INFO -- : GroupMember total (4): 16.2ms
I, [2019-06-14T02:49:37.757854 #31336]  INFO -- : Group total (9): 15.0ms
I, [2019-06-14T02:49:37.757866 #31336]  INFO -- : Stage total (3): 14.3ms
I, [2019-06-14T02:49:37.757878 #31336]  INFO -- : NoteDiffFile total (1): 12.0ms
I, [2019-06-14T02:49:37.757890 #31336]  INFO -- : Deployment total (4): 7.4ms
I, [2019-06-14T02:49:37.757901 #31336]  INFO -- : PipelineVariable total (4): 7.3ms
I, [2019-06-14T02:49:37.757911 #31336]  INFO -- : ProjectFeature total (6): 6.8ms
I, [2019-06-14T02:49:37.757922 #31336]  INFO -- : Event total (4): 6.7ms
I, [2019-06-14T02:49:37.757934 #31336]  INFO -- : ProtectedEnvironment total (6): 6.6ms
I, [2019-06-14T02:49:37.757945 #31336]  INFO -- : Environment total (4): 6.2ms
I, [2019-06-14T02:49:37.757957 #31336]  INFO -- : Todo total (1): 5.6ms
I, [2019-06-14T02:49:37.757968 #31336]  INFO -- : Upload total (3): 5.5ms
I, [2019-06-14T02:49:37.757980 #31336]  INFO -- : Variable total (4): 5.5ms
I, [2019-06-14T02:49:37.757991 #31336]  INFO -- : Suggestion total (1): 5.2ms
I, [2019-06-14T02:49:37.758014 #31336]  INFO -- : GroupVariable total (4): 4.7ms
I, [2019-06-14T02:49:37.758025 #31336]  INFO -- : ProjectMember total (2): 3.7ms
I, [2019-06-14T02:49:37.758036 #31336]  INFO -- : MergeRequestDiff total (1): 3.2ms
I, [2019-06-14T02:49:37.758048 #31336]  INFO -- : Milestone total (1): 2.8ms
I, [2019-06-14T02:49:37.758060 #31336]  INFO -- : UserStatus total (2): 2.7ms
I, [2019-06-14T02:49:37.758071 #31336]  INFO -- : ProjectAutoDevops total (2): 2.3ms
I, [2019-06-14T02:49:37.758082 #31336]  INFO -- : Metrics total (1): 2.0ms
I, [2019-06-14T02:49:37.758093 #31336]  INFO -- : ApprovalProjectRule total (1): 1.9ms
I, [2019-06-14T02:49:37.758104 #31336]  INFO -- : GitlabIssueTrackerService total (1): 1.8ms
I, [2019-06-14T02:49:37.758116 #31336]  INFO -- : ApprovalMergeRequestRule total (1): 1.8ms
I, [2019-06-14T02:49:37.758127 #31336]  INFO -- : MergeRequestDiffCommit total (1): 1.8ms
I, [2019-06-14T02:49:37.758138 #31336]  INFO -- : IssueAssignee total (1): 1.6ms
I, [2019-06-14T02:49:37.758148 #31336]  INFO -- : ProjectTracingSetting total (1): 1.4ms
I, [2019-06-14T02:49:37.758159 #31336]  INFO -- : Plan total (1): 1.3ms
I, [2019-06-14T02:49:37.758170 #31336]  INFO -- : UserCallout total (1): 1.2ms
I, [2019-06-14T02:49:37.758181 #31336]  INFO -- : ProjectCiCdSetting total (1): 1.2ms
I, [2019-06-14T02:49:37.758193 #31336]  INFO -- : PushAccessLevel total (1): 1.1ms
I, [2019-06-14T02:49:37.758204 #31336]  INFO -- : MergeRequestAssignee total (1): 1.1ms
I, [2019-06-14T02:49:37.758217 #31336]  INFO -- : License total (1): 1.1ms
I, [2019-06-14T02:49:37.758229 #31336]  INFO -- : Email total (1): 1.0ms

profile-mr-sql.txt

Related links:

Edited by Stan Hu