diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-08 09:15:55 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-08 09:15:55 +0000 |
commit | e7f1780d7dba000aa399535547f0c6607d0a9b69 (patch) | |
tree | d0e00eede726ddfcacabc60885c43c3be3daa6df /lib | |
parent | 960b322388300856a6dfd9d2b9f2d054ce47cf57 (diff) | |
download | redmine-e7f1780d7dba000aa399535547f0c6607d0a9b69.tar.gz redmine-e7f1780d7dba000aa399535547f0c6607d0a9b69.zip |
#lock_nested_set very slow on mysql with thousands of subtasks (#23318).
Patch by Stephane Evr.
git-svn-id: http://svn.redmine.org/redmine/trunk@15891 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/nested_set/issue_nested_set.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/redmine/nested_set/issue_nested_set.rb b/lib/redmine/nested_set/issue_nested_set.rb index afbe6b995..e939f96b6 100644 --- a/lib/redmine/nested_set/issue_nested_set.rb +++ b/lib/redmine/nested_set/issue_nested_set.rb @@ -158,7 +158,10 @@ module Redmine self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids else sets_to_lock = [id, parent_id].compact - self.class.reorder(:id).where("root_id IN (SELECT root_id FROM #{self.class.table_name} WHERE id IN (?))", sets_to_lock).lock.ids + self.class.reorder(:id). + joins("INNER JOIN #{self.class.table_name} t2 ON #{self.class.table_name}.root_id = t2.root_id"). + where("t2.id IN (?)", sets_to_lock). + lock.ids end end |