Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › very slow search
This topic contains 6 replies, has 2 voices, and was last updated by 23volt 1 year, 4 months ago.
- AuthorPosts
- December 19, 2022 at 3:18 pm #40557
Hello friend,
we using your powerfull plugin. We have some custom post types and some custom taxomonies.
And we using this code in our functions.php to limit the search. This is the code from our functions.phpadd_filter('asp_query_cpt', 'asp_change_query_directly', 10, 1); function asp_change_query_directly($q) { global $wpdb; $q = preg_replace('/AND ' . preg_quote("$wpdb->posts.post_parent IN ") . '\((.*?)\)/im', "OR ($wpdb->posts.post_type IN ('post', 'page', 'dealer', 'vehicle', 'contact-person') AND $wpdb->posts.post_status LIKE 'publish' AND $wpdb->posts.post_parent IN($1))", $q); return $q; } add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 ); function asp_include_only_parent_ids( $args, $id ) { if ( $id == 3 ) { $args['post_parent'] = array(11748, 11754, 29487, 29888, 13423); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b9acbc2709e'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 12 ) { $args['post_parent'] = array(3239, 24819); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b996ad1edbc', '62b997647e701', '62b99783635d8', '62b9979cd0b48'), 'operator' => 'ELIKE', 'allow_missing' => false ); }
We activate indexer mode of your search, but the search is still very slow. It takes more then 30seconds to find a result.
You can test it here:https://www.my-mobility.group/best/
We running this project on maxcluster server. Its an dedicated managed server with 32 cores and 16GB RAM.
Redis and WP-Rocket is enabled and working.
Indexer mode enabled.We try to enable ajax search pro caching. But the initial keyword search is still slow: more then 30 seconds.
Do you have a idea why the search is still so slow?
BR
TommyDecember 19, 2022 at 4:11 pm #40564Hi,
Thank you for the kind words and the details, it helps a lot!
Does anything change if you remove these custom codes? The first one should not even work at all with the indexed queries, the index table queries are not possible to change via filters.
Best,
Can you please check if the index table is indeed enabled on in the search instance settings?
If yes, then the first custom code should not work at all.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 19, 2022 at 4:22 pm #40566Hello Ernest,
thank you for your fast feedback.
I removed your customcode / filter from functions.php file. But the slow search query still resist.
I do not understand why the indexer not making the search faster. Do you have an ideaßSecond point:
If we enable indexer mode we cant have functions.php code to filter search?
If yes, i need to find a solution with normal mode (without indexer) with you. You can help us to make that search faster?
We also can pay for this job.BR
TommyDecember 20, 2022 at 3:36 pm #40593Hi Tommy,
It is something else probably – but first you need to enable the index table search engine so the plugin uses that for sure, and then test again.
2) The first hook will not work with it (asp_change_query_directly), the second one will. That hook is not applied to the indexed queries, and even if it was, it would not work, because the index queries are not executed on the posts table.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 20, 2022 at 6:44 pm #40608Hello friend,
coud you explain please what we have to change for the first hook (asp_change_query_directly)?
So we can try this solution.BR
TommyDecember 21, 2022 at 3:16 pm #40619Hi Tommy,
Well, the function is simply not executed for the indexed searches, the hook is not applied to them. The problem is not with the code, but the fact that the
Best,asp_change_query_directly
hook does not exist for indexed queries.
Even if we added that hook there is no way to make that code work with it, as the index does not store post parent and status information, so subqueries/table joins would be required – and in that case the queries are no longer in indexed mode, and will result in the same peformance as the regular queries (due to the table join/sub queries).
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 23, 2022 at 8:47 am #40635Thank you for your feedback friend.
I disabled the indexer mode but not i have all the time the samme qty of results:
https://wp-dreams.com/forums/topic/search-show-all-results/ - AuthorPosts
You must be logged in to reply to this topic.