Project

General

Profile

Actions

Patch #23378

closed

Speedup Project Settings with many members

Added by Victor Campos over 8 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Performance
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Hi,
There is a .sort in _members.html.erb partial that take a lot of time for project that have more than 12s to execute, so I change for .order('roles.builtin, roles.position, users.firstname, users.lastname')

- members = @project.memberships.active.includes(:member_roles, :roles, :principal).to_a.sort
+ members = @project.memberships.active.includes(:member_roles, :roles, :principal).order('roles.builtin, roles.position, users.firstname, users.lastname')
Benchmark.measure { project.memberships.active.includes(:member_roles, :roles, :principal).order('roles.builtin, roles.position, users.firstname, users.lastname').to_a }

#<Benchmark::Tms:0x00000008a427e0 @label="", @real=0.7370121359999757, @cstime=0.0, @cutime=0.0, @stime=0.0, @utime=0.6500000000000004, @total=0.6500000000000004>

Benchmark.measure { project.memberships.active.includes(:member_roles, :roles, :principal).to_a.sort }

#<Benchmark::Tms:0x0000000c68f450 @label="", @real=12.094179325009463, @cstime=0.0, @cutime=0.0, @stime=0.019999999999999962, @utime=12.029999999999998, @total=12.049999999999997>
Actions #1

Updated by Go MAEDA over 8 years ago

Interesting. Reducing 12 sec to 0.6 sec is big improvement. How many members on the project?

Here is a diff made from the first post.

Index: app/views/projects/settings/_members.html.erb
===================================================================
--- app/views/projects/settings/_members.html.erb    (revision 15732)
+++ app/views/projects/settings/_members.html.erb    (working copy)
@@ -1,5 +1,5 @@
 <% roles = Role.find_all_givable
-   members = @project.memberships.active.includes(:member_roles, :roles, :principal).to_a.sort %>
+   members = @project.memberships.active.includes(:member_roles, :roles, :principal).order('roles.builtin, roles.position, users.firstname, users.lastname')

 <p><%= link_to l(:label_member_new), new_project_membership_path(@project), :remote => true, :class => "icon icon-add" %></p>
Actions #2

Updated by Victor Campos over 8 years ago

6K members

Actions #3

Updated by Toshi MARUYAMA over 8 years ago

I think SQL "users.firstname, users.lastname" order is not acceptable because AFAIK user sort is configurable.
source:tags/3.3.0/app/models/user.rb#L24

Actions #4

Updated by Go MAEDA 10 months ago

  • Status changed from New to Closed

Closing this issue for the reason described in #note-3.

Actions #5

Updated by Holger Just 10 months ago

This was already fixed in Redmine 3.4.0 with r16040 by using Principal.fields_for_order_statement

Actions

Also available in: Atom PDF