Project

General

Profile

Defect #26691

Updated by Toshi MARUYAMA over 7 years ago

Rails 4.2.7.1 
 20000 issues in the database 
 When rendering the GanttsController.show action, it will issue a lot of queries to get the the start_date and due_date of an project like: 


 <pre><code class="sql"> 
 SELECT MIN(`issues`.`start_date`) FROM `issues` WHERE `issues`.`project_id` = ?    [["project_id", 1436]] 
 SELECT MAX(`issues`.`due_date`) FROM `issues` WHERE `issues`.`project_id` = ?    [["project_id", 1436]] 
 SELECT MIN(`issues`.`start_date`) FROM `issues` WHERE `issues`.`project_id` = ?    [["project_id", 1317]] 
 SELECT MAX(`issues`.`due_date`) FROM `issues` WHERE `issues`.`project_id` = ?    [["project_id", 1317]] 
 </code></pre> 

 .... 
 Which will make the performance very bad. 

 My solution is that add cached_due_date and cached_start_date for projects.rb, and while constructing the project_tree, I will use a group query to retrieve the corresponding start_date and due_date for a group of projects, so that they don't need to issue N queries later on.

Back