##// END OF EJS Templates
#lock_nested_set very slow on mysql with thousands of subtasks (#23318)....
Jean-Philippe Lang -
r15671:10b3e3e32394
parent child
Show More
@@ -158,7 +158,8 module Redmine
158 self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
158 self.class.reorder(:id).where(:root_id => sets_to_lock).lock(lock).ids
159 else
159 else
160 sets_to_lock = [id, parent_id].compact
160 sets_to_lock = [id, parent_id].compact
161 self.class.reorder(:id).where("root_id IN (SELECT root_id FROM #{self.class.table_name} WHERE id IN (?))", sets_to_lock).lock.ids
161 inner_join_statement = self.class.select(:root_id).where(id: sets_to_lock).distinct(:root_id).to_sql
162 self.class.reorder(:id).joins("INNER JOIN (#{inner_join_statement}) as i2 ON #{self.class.table_name}.root_id = i2.root_id").lock.ids
162 end
163 end
163 end
164 end
164
165
General Comments 0
You need to be logged in to leave comments. Login now