Skip to:

Opened 8 years ago

Closed 8 years ago

#7208 closed defect (bug) (fixed)

`bp_get_user_groups()` performance issues

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: Groups Keywords:


Working with bp_get_user_groups() on a site where a user is a member of many hundreds of groups, I've noted some performance issues.

First: when looping through groups and casting keys to integer or boolean, the key whitelist is being regenerated each time through the loop. This only needs to be done once.

Second: wp_list_filter() is slow. I wonder if there's a way to filter these items earlier.

Change History (3)

#1 @boonebgorges
8 years ago

In 10977:

In bp_get_user_groups(), initialize key whitelists only once.

Creating them during every iteration of the groups loop is unnecessary.

See #7208.

#2 @boonebgorges
8 years ago

In 10978:

Reduce the number of loops in bp_get_user_groups().

By applying $filters before adding to the found $groups array, we
eliminate one loop through the list of groups, and also eliminate a
costly call to wp_list_filter().

See #7208.

#3 @boonebgorges
8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

The function can still be costly when running over huge numbers of groups. But further optimization will require digging into our sorting algorithms, which is more work than I can devote to the issue at the moment.

Note: See TracTickets for help on using tickets.