0

Please I have a very slow query on my wordpress search, checking the processes it takes upto 40sec to execute using SHOW FULL PROCESSLIST; below is a sample of query

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND (((wp_posts.post_title LIKE '%Industreet%') OR (wp_posts.post_excerpt LIKE '%Industreet%') OR (wp_posts.post_content LIKE '%Industreet%')))  AND (wp_posts.post_password = '')  AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish')  ORDER BY wp_posts.post_title LIKE '%Industreet%' DESC, wp_posts.post_date DESC LIMIT 0, 25 

I have tried my best to fix this, but nothing is working out. though I have a total post of 120k on my site. I really need help.

Thanks in advance

  • Could you use approaches as shown in these answers? What exactly is the LIKE doing in ORDER BY .. LIKE ..? – kero Sep 11 '18 at 5:23
  • I don't know, I am looking for any way to speed it up. I did not understand the link you provided, because I am not master of query solving. – Godwin Alex Ogbonda Sep 11 '18 at 6:27
1

This is the query generated by the internal search function on Wordpress.

It is criticised for being inefficient, and there are a few drop-in replacements available as plugins. You may be able to find something that helps you by doing more research around these. For example:

https://themeisle.com/blog/improve-internal-search-in-wordpress/

https://winningwp.com/best-wordpress-search-plugins/

I don't have a specific recommendation to offer as I'm just digging into this myself, hence having to link elsewhere.

  • Thank you for your support I really appreciate, The I limited the search to only title and the buggy slow query was fixed, Thank once again – Godwin Alex Ogbonda Jan 19 at 13:01
0

Search functionality WordPress queries are slow by it's nature unfortunately, since it can use only SQL and it's not designed for full-text searches. The only working solution when your database becomes large enough is to use search engine software instead and call it from inside WordPress using some plugin.

One another free drop-in replacement we've made is https://wordpress.org/plugins/wow-fulltext-search/

  • Thank you very much, I limited search query to only title using functions, and it fix the issue for me, Let me check out your plugins on my other sites – Godwin Alex Ogbonda Mar 11 at 4:04
  • Yeah, if limiting a list of fields is acceptable for your business logic - it will help for sure for some time, but indexes are still not used for LIKE '%x%' queries so it may return to you again as database grows. And of course things like plural/singlular matching is missing anyway. – WowPress.host Mar 12 at 6:07
  • Please mainly allow Google to index my search, which I used to replace tag, due to large database, and performance issue, so I dont know if your plugin will be able to allow google index my search links – Godwin Alex Ogbonda Mar 12 at 6:21
  • looks interesting what you've reached. am i right you had tags associated to posts, like "apple", "cherry" tags to e.g. post "my apple pie with cherries". and you have removed tags and replaced those tag links with "?s=apple", ""?s=cherry" links instead? or there's something different? – WowPress.host Mar 12 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.