dhanasingh / redmine_wktime

ERPmine is an open source free ERP for Service Industries. It runs within Redmine
https://erpmine.org/
Other
120 stars 78 forks source link

Edit Timesheet Pageload Performance #298

Open JeffDess opened 9 months ago

JeffDess commented 9 months ago

I've noticed a performance issue when loading the edit timesheet page, the request can become blocking if multiple users load the page simultaneously. It is more obvious when impersonating an admin account on a Redmine instance with lots of projects and users (see #242 for more details) . The slowdown comes from the project list being iterated in Ruby, then each members of each projects being added to a list then deduped.

The solution is to make a single SQL query to get the users by filtering them by their projects (listed in the members table). That doesn't require looping through a large list and it has proven to be much more efficient. From the benchmark I've run on my production environment, pageload went from 4000\~6000ms to 500\~800ms, the SQL query being < 10ms.