id summary reporter owner description type status priority milestone component version severity resolution keywords cc 8591 Improve query that runs to find total activities count in spam activity table oztaser imath "An unlimited query is running to find total activities count in the spam activity table and then it causes PHP memory limit error. In our case we have more than 2m activity records. https://github.com/buddypress/buddypress/blob/master/src/bp-activity/classes/class-bp-activity-list-table.php#L215 {{{#!php 'ids', 'show_hidden' => true, 'count_total' => 'count_query', ) ); }}} Query log: {{{ # There is no need to run this query IMO. SELECT DISTINCT a.id FROM wp_bp_activity a WHERE a.is_spam = 0 AND a.type NOT IN ('activity_comment', 'last_activity') ORDER BY a.date_recorded DESC, a.id DESC # This query runs for finding the total count. SELECT count(DISTINCT a.id) FROM wp_bp_activity a WHERE a.is_spam = 1 AND a.type NOT IN ('last_activity') }}} " enhancement closed normal 10.0.0 Activity normal fixed has-patch