[buddypress-trac] [BuddyPress] #4018: @mentions (slow query)

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Sat Feb 18 19:07:50 UTC 2012

#4018: @mentions (slow query)
 Reporter:  webraket     |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Activity     |     Version:  1.5.3
 Severity:  major        |  Resolution:
 Keywords:               |
Changes (by webraket):

 * component:  Core => Activity


 I added a fulltext index to bp_activity.content and wrote a small plugin.
 Query's now take less than 0,01 sec

 function bp_activity_fulltext_search($q){

         //check if query contains LIKE operator
         if(strpos($q,"WHERE a.content LIKE '%")!==FALSE){

                 global $wpdb;

                 //extract search_terms (escape again just to be sure)
                 $aParts = explode("%",$q);
                 $search_terms = $wpdb->escape($aParts[1]);

                 //modify query
                 $q = preg_replace("/WHERE /", "WHERE MATCH(`content`)
 AGAINST('".$search_terms."') AND ", $q, 1);

         return $q;


 Still think this should be fixed in core...

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4018#comment:2>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list