summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-10-06 19:57:16 +0000
committerRémy Coutable <remy@rymai.me>2016-10-11 12:52:14 +0200
commit4ebf6f4d8822d2504471ca9ba7e3a28aa4b422c2 (patch)
tree1556bc6db6459382bfaae32f17893099872455af
parentede46e60bf4d206f39dfa28edd479393a15a0630 (diff)
downloadgitlab-ce-4ebf6f4d8822d2504471ca9ba7e3a28aa4b422c2.tar.gz
Merge branch 'sh-fix-issue-perf-order-by-issue' into 'master'
Improve issue load time performance by avoiding ORDER BY in find_by call See merge request !6724 Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/issues_controller.rb3
2 files changed, 3 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c6c0670d365..b2368783f9c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.12.5
- Switch from request to env in ::API::Helpers. !6615
+ - Improve issue load time performance by avoiding ORDER BY in find_by call. !6724
v 8.12.4
- Fix "Copy to clipboard" tooltip to say "Copied!" when clipboard button is clicked. !6294 (lukehowell)
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index ef13e0677d2..96041b07647 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -159,7 +159,8 @@ class Projects::IssuesController < Projects::ApplicationController
protected
def issue
- @noteable = @issue ||= @project.issues.find_by(iid: params[:id]) || redirect_old
+ # The Sortable default scope causes performance issues when used with find_by
+ @noteable = @issue ||= @project.issues.where(iid: params[:id]).reorder(nil).take || redirect_old
end
alias_method :subscribable_resource, :issue
alias_method :issuable, :issue