Project

General

Profile

Actions

Feature #36696

closed

Improve performance of adding or removing members of a group

Added by James H over 2 years ago. Updated over 2 years ago.

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

0%

Estimated time:
Resolution:
Fixed

Description

In situations where groups are applied to hundreds of projects (with or without subprojects, with or without inherit members), adding or removing a user from the group takes VERY LONG (more than 5-10 minutes).

Would like to request:
  1. Better querying optimization?
  2. Bulk edit capability

1. not sure how because I do not know how it queries. maybe something like consolidate multiple queries into fewer big queries?
2. When looking at the "users" tab under Groups, have a checkmark selection and "Apply All" button at the bottom for actions applied for multiple users at once. This way it can try to optimize the query for that?


Files

36696.patch (2.87 KB) 36696.patch Go MAEDA, 2022-02-28 08:56
36696-v2.patch (3.42 KB) 36696-v2.patch Go MAEDA, 2022-02-28 16:25

Related issues

Related to Redmine - Patch #36730: Replace Member.find_or_new with ActiveRecord's find_or_initialize_byClosedGo MAEDA

Actions
Actions #1

Updated by James H over 2 years ago

or maybe make it a background job similar to like #36691

Actions #2

Updated by Go MAEDA over 2 years ago

I wrote a patch that speeds up the adding of a group member. In my test environment with 500+ projects, I got a speedup of about 30%.

Before:

Completed 200 OK in 1674ms (Views: 10.3ms | ActiveRecord: 275.6ms | Allocations: 924861)
Completed 200 OK in 1691ms (Views: 2.7ms | ActiveRecord: 278.2ms | Allocations: 921060)
Completed 200 OK in 1734ms (Views: 2.1ms | ActiveRecord: 294.0ms | Allocations: 921192)
Completed 200 OK in 1928ms (Views: 3.0ms | ActiveRecord: 305.9ms | Allocations: 921065)
Completed 200 OK in 1655ms (Views: 2.7ms | ActiveRecord: 277.6ms | Allocations: 921057)

After:

Completed 200 OK in 1309ms (Views: 4.1ms | ActiveRecord: 185.9ms | Allocations: 754306)
Completed 200 OK in 1264ms (Views: 2.1ms | ActiveRecord: 169.1ms | Allocations: 745979)
Completed 200 OK in 1392ms (Views: 2.7ms | ActiveRecord: 184.0ms | Allocations: 745980)
Completed 200 OK in 1299ms (Views: 2.1ms | ActiveRecord: 173.2ms | Allocations: 746013)
Completed 200 OK in 1256ms (Views: 2.1ms | ActiveRecord: 168.8ms | Allocations: 745976)

Actions #3

Updated by Go MAEDA over 2 years ago

Updated the patch. Now it also improves the speed of removing a group member. The speedup of GroupsController#remove_user is about 20% in my test environment.

Before:

Completed 200 OK in 1555ms (Views: 8.9ms | ActiveRecord: 281.5ms | Allocations: 951235)
Completed 200 OK in 1605ms (Views: 2.3ms | ActiveRecord: 295.5ms | Allocations: 947796)
Completed 200 OK in 1551ms (Views: 2.7ms | ActiveRecord: 290.3ms | Allocations: 947743)
Completed 200 OK in 1566ms (Views: 3.6ms | ActiveRecord: 289.5ms | Allocations: 947744)
Completed 200 OK in 1610ms (Views: 2.7ms | ActiveRecord: 300.5ms | Allocations: 947749)

After:

Completed 200 OK in 1247ms (Views: 4.6ms | ActiveRecord: 221.6ms | Allocations: 732887)
Completed 200 OK in 1364ms (Views: 2.1ms | ActiveRecord: 248.6ms | Allocations: 729979)
Completed 200 OK in 1255ms (Views: 2.1ms | ActiveRecord: 231.0ms | Allocations: 730074)
Completed 200 OK in 1399ms (Views: 2.0ms | ActiveRecord: 261.1ms | Allocations: 729955)
Completed 200 OK in 1285ms (Views: 2.2ms | ActiveRecord: 232.4ms | Allocations: 729953)

Actions #4

Updated by James H over 2 years ago

That was quick, thank you for your efforts!

Actions #5

Updated by Go MAEDA over 2 years ago

  • Subject changed from Group members - query optimization & bulk edit to Improve performance of adding or removing members of a group
  • Category changed from Groups to Performance
  • Target version set to 5.0.0

Setting the target version to 5.0.0.

Actions #6

Updated by Go MAEDA over 2 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch.

Actions #7

Updated by Go MAEDA over 2 years ago

  • Related to Patch #36730: Replace Member.find_or_new with ActiveRecord's find_or_initialize_by added
Actions

Also available in: Atom PDF