WordPress RSS源查询速度慢:如何修复/预防

2ledvvac  于 2022-11-22  发布在  WordPress
关注(0)|答案(1)|浏览(195)

我们的主要网站是运行WordPress 6.0.3在PHP 8.0与MariaDB 10.x数据库。
我们正在使用New Relic(NR)作为系统和应用程序指标,并注意到NR“慢速SQL跟踪”表中始终显示一个特定的SQL查询。进一步缩小范围后,这些慢速查询来自WP RSS源。
以下是一些例子:

我们几乎可以点击任何RSS提要URL,并在大约10到30秒内显示在NR“Slow SQL traces”表中。
查询看起来像这样的庞然大物:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE ?=? AND 
(((wp_posts.post_title LIKE ?) OR (wp_posts.post_excerpt LIKE ?) OR 
(wp_posts.post_content LIKE ?))) AND (wp_posts.post_password = ?) AND 
((wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?)) OR 
(wp_posts.post_type = ? AND (wp_posts.post_status = ? OR wp_posts.post_status = ?))) 
ORDER BY wp_posts.post_title LIKE ? DESC, wp_posts.post_date DESC LIMIT ?, ?

您知道如何优化此RSS查询,或者缓存它吗?

谢谢
乔恩

eh57zj3b

eh57zj3b1#

索引数据库表字段:

wp_posts:
post_title, post_excerpt, post_content, post_password, post_type and post_date etc.

在查询中使用。请执行以下步骤:https://dev.mysql.com/doc/refman/8.0/en/mysql-indexes.html

相关问题