• Resolved nicmare

    (@nicmare)


    This plugin is genius ! Works very well. But I’ve noticed that the search becomes 5-10 times slower with the plugin and 10.000+ posts and many custom fields in the database. I already ticked selected mode with only 3 custom fields. this is the current query:

    is there maybe a filter to insert the desired custom fields by hand instead of searching for them with acfbs_allow_search string in each serialized array? I could image that improves the performance. or there any other ideas to speed up the query? at the moment i am around 5 seconds with each search. Normally 1 second maximum.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @nicmare,

    Thank you for your message.

    Unfortunately, due to the structure of the database (most of the data is only in two tables – wp_posts and wp_postmeta), query performance may be limited. Data from the ACF plugin is also stored in these tables. In this situation, I recommend that you activate Lite mode in the plugin settings. This should significantly speed up search performance.

    Best,
    Mateusz

    Thread Starter nicmare

    (@nicmare)

    i found the filter to alter your query to provide static custom field name in the query where “name_de” is one of my custom fields:

    function improve_acfbs($join){
    	
    	$strings = explode("AND",$join);
    	foreach($strings as $key=>$string){
    				
    	if(str_contains($string,"acfbs_allow_search"))
    		unset($strings[$key]);
    	}
    	$strings[] = " ( c.post_title = 'name_de')) ";
    	$new_join = implode("AND",$strings);
    	
    	return $new_join;
    }
    add_filter("acfbs_sql_join", 'improve_acfbs');

    seems a little bit faster but still very slow. But i am sharing this code if someone needs it as well for some reason.

    • This reply was modified 1 year, 9 months ago by nicmare.
    Thread Starter nicmare

    (@nicmare)

    OR simply with the post_id of your custom field:

    function improve_acfbs($join){
    	if(!str_contains($join,"acfbs_allow_search")) return $join;
    
    	$strings = explode("AND",$join);
    	foreach($strings as $key=>$string){
    		
    	if(str_contains($string,"acfbs_allow_search"))
    			unset($strings[$key]);
    		if(str_contains($string,"acf-field"))
    			unset($strings[$key]);
    	}
    	$strings[] = sprintf(" ( c.ID = %s ) ",1925 ); // post_id of your custom field
    
    	$new_join = sprintf("%s )",implode("AND",$strings));
    	
    	return $new_join;
    }
    add_filter("acfbs_sql_join",'improve_acfbs');
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Weak Performance with 10.000+ Posts’ is closed to new replies.