我的 WordPress 网站上有 103775 个帖子。以下查询不断使我的 MySQL 数据库服务器超载。我怎样才能永久修复它?
我的 WordPress 网站上有 103775 个帖子,以下查询不断使我的 MySQL 数据库服务器超载。我怎样才能永久修复它?
第一个:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta
ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1
AND (wp_postmeta.meta_key = 'post_views_count')
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_postmeta.meta_value+0 DESC
LIMIT 0, 3
第二个:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1=1
AND (wp_term_relationships.term_taxonomy_id IN (127,188,190))
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
LIMIT 0, 4
第三个:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1=1
AND (wp_term_relationships.term_taxonomy_id IN (127,188,190))
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
LIMIT 0, 4
这些查询的作用是什么?如何避免因 MySQL 数据库服务器超载而生成这些查询?
I have 103775 posts on my WordPress site and the following queries constantly overloading my MySQL database server. How can I permanently fix it?
First one:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta
ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1
AND (wp_postmeta.meta_key = 'post_views_count')
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_postmeta.meta_value+0 DESC
LIMIT 0, 3
Second:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1=1
AND (wp_term_relationships.term_taxonomy_id IN (127,188,190))
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
LIMIT 0, 4
Third:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1=1
AND (wp_term_relationships.term_taxonomy_id IN (127,188,190))
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
LIMIT 0, 4
What does these queries do & how can I avoid generating these queries from overloading my MySQL database server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我首先验证 where 语句索引中使用的所有字段(应该是这种情况)。
SQL_CALC_FOUND_ROWS也存在性能问题
正如你在这里看到的:
wordpress 生成缓慢的 mysql 查询 - 是索引问题吗?
在这里
https://core.trac.wordpress.org/ticket/10964
然后我会检查mysql_cache是否启用并添加缓存插件。
i would start by verifying all fields used in where statements are indexed (chich should be the case).
There is also performance problems with SQL_CALC_FOUND_ROWS
as you can see here :
wordpress generating slow mysql queries - is it index problem?
and here
https://core.trac.wordpress.org/ticket/10964
Then i would check if mysql_cache is enabled and add a cache plugin.