$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>database - Slow Query On Search|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

database - Slow Query On Search

matteradmin8PV0评论

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

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

Share Improve this question edited Sep 11, 2018 at 5:32 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Sep 11, 2018 at 4:59 Godwin Alex OgbondaGodwin Alex Ogbonda 1192 silver badges13 bronze badges 2
  • Could you use approaches as shown in these answers? What exactly is the LIKE doing in ORDER BY .. LIKE ..? – kero Commented Sep 11, 2018 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 Commented Sep 11, 2018 at 6:27
Add a comment  | 

2 Answers 2

Reset to default 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/blog/improve-internal-search-in-wordpress/

https://winningwp/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.

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/plugins/wow-fulltext-search/

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far