summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-08-28 17:35:10 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-08-28 17:36:31 +0200
commitb870ae1f59ab0b3f4a10f9dbb2d64324b90ba38b (patch)
treeefb40ea43015d170fae9fbd82a61c1f019aed2bb
parent073811074bf15742a86572b933b0e3ad0f06107b (diff)
downloadgitlab-ce-b870ae1f59ab0b3f4a10f9dbb2d64324b90ba38b.tar.gz
Eager load head pipeline projects for MRs indexmr-index-eager-load
This ensures the project of an MR's head pipeline is eager loaded, preventing an N+1 query problem from occurring when viewing the list of MRs of a project.
-rw-r--r--app/controllers/concerns/issuable_collections.rb12
-rw-r--r--changelogs/unreleased/mr-index-eager-load.yml5
2 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb
index b43b2c5621f..a34a82b7ba6 100644
--- a/app/controllers/concerns/issuable_collections.rb
+++ b/app/controllers/concerns/issuable_collections.rb
@@ -15,7 +15,17 @@ module IssuableCollections
end
def merge_requests_collection
- merge_requests_finder.execute.preload(:source_project, :target_project, :author, :assignee, :labels, :milestone, :head_pipeline, target_project: :namespace, merge_request_diff: :merge_request_diff_commits)
+ merge_requests_finder.execute.preload(
+ :source_project,
+ :target_project,
+ :author,
+ :assignee,
+ :labels,
+ :milestone,
+ head_pipeline: :project,
+ target_project: :namespace,
+ merge_request_diff: :merge_request_diff_commits
+ )
end
def issues_finder
diff --git a/changelogs/unreleased/mr-index-eager-load.yml b/changelogs/unreleased/mr-index-eager-load.yml
new file mode 100644
index 00000000000..11c33055b17
--- /dev/null
+++ b/changelogs/unreleased/mr-index-eager-load.yml
@@ -0,0 +1,5 @@
+---
+title: Eager load head pipeline projects for MRs index
+merge_request:
+author:
+type: other