Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress Members Query Performance for Large Sites


  • nelsonkana
    Participant

    @nelsonkana

    I’m running a BuddyPress installation with over +50 000 members. At the time of writing, my versions are BP2.9 & WP4.8 While checking my log files I noticed a slow query log entry that pointed to a BuddyPress query which I’m very concerned about. It generates a subquery with a where IN clause with over +50 000 user IDs. I’m more concerned because my user base is growing and that number could become 75k or 100k. Here is a sample

    SELECT
    u.ID AS
    id
    FROM
    xxx_users u
    WHERE
    1 = 1
    AND u.ID IN (
    SELECT
    ID
    FROM
    xxx_users
    WHERE
    spam = 0
    AND deleted = 0
    AND user_status = 0
    )
    AND u.ID IN (
    1, 3, 13, 30,........,50000 <- Problem Area, +50000 IDs passed here
    )
    AND u.ID IN (
    SELECT
    ID
    FROM
    xxx_users
    WHERE
    (
    user_login LIKE '%%'
    OR user_login LIKE '%%'
    OR user_nicename LIKE '%%'
    OR user_nicename LIKE '%%'
    )
    )
    ORDER BY
    u.display_name ASC
    LIMIT
    43176, 21

    Ref: Query is generated in this file file:buddypress/bp-core/classes/class-bp-user-query.php method:BP_User_Query::prepare_user_ids_query

    My Questions:

    1. Is that something I should be concerned about?
    2. Is this something I should consider fixing with this hook $sql = apply_filters_ref_array( ‘bp_user_query_uid_clauses’, array( $sql,
      &$this ));
  • You must be logged in to reply to this topic.
Skip to toolbar