Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

#7208 closed defect (bug) (fixed)

`bp_get_user_groups()` performance issues

Reported by: boonebgorges Owned by:
Priority: normal Milestone: 2.7
Component: Groups Version:
Severity: normal Keywords:
Cc:

Description

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
10 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
10 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
10 years ago

  • Resolutionfixed
  • Status newclosed

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.