[buddypress-trac] [BuddyPress Trac] #5629: Slow queries with BP_Activity_Activity::get()

buddypress-trac noreply at wordpress.org
Sun May 11 18:28:15 UTC 2014

#5629: Slow queries with BP_Activity_Activity::get()
 Reporter:  Clean-Cole   |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  lowest       |   Milestone:  2.1
Component:  Activity     |     Version:  2.0
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |

Comment (by Clean-Cole):

 Hey Boone, I'm with you on that.  I think the biggest issue for me trying
 to come up with a solution is trying to determine the more common use
 cases of the BP_Activity_Activity::get().  I've started creating a
 function that will determine if the activity query being run is something
 that should be cached.

 Currently I'm playing around with a foreach statement that checks the
 following array against the {{{$filter}}} query parameter.  This is less
 of an actual code solution but more of me thinking out loud.  Integer keys
 in the array are only checked by an {{{isset()}}} call.  String key =>
 value pairs are checked for a matched value.  The positive and negative
 keys are hopefully self explanatory.

 $checks = array(
         'positive' => array( 0 => 'user_id', 'object' => 'activity' ),
         'negative' => array( 'since', 'action', 'primary_id',
 'secondary_id' ),

 So I figured any queries using {{{since}}}, {{{action}}}, or
 {{{primary}}}/{{{secondary}}} id should be excluded from a transient.  So
 basically an all activity count for a user is the only thing we can really
 cache reliably?  Another issue I considered was that if we save a user's
 total activity in a transient, the options table could easily get too
 bloated.  Do you think storing a user's total activity count inside
 BuddyPress user meta is a viable alternative?

 I must admit I'm not familiar enough with this query to truly know what
 should be included or excluded, so any input or thoughts you have would
 obviously be appreciated.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5629#comment:4>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list