Commit 1f7a9edb authored by jplang's avatar jplang
Browse files

#lock_nested_set very slow on mysql with thousands of subtasks (#23318).

Patch by Stephane Evr.

git-svn-id: e93f8b46-1217-0410-a6f0-8f06a7374b81
parent cd0f618f
......@@ -158,7 +158,8 @@ module Redmine
self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
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
inner_join_statement = sets_to_lock).distinct(:root_id).to_sql
self.class.reorder(:id).joins("INNER JOIN (#{inner_join_statement}) as i2 ON #{self.class.table_name}.root_id = i2.root_id").lock.ids
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment