【发布时间】:2012-01-15 15:26:25
【问题描述】:
由于我的博客导致 mysql 过载,我的虚拟主机暂停了我的帐户。他们让我检查慢查询并通过“索引”它们来解决问题,但我不太明白我应该在这里做什么:
# Query_time: 1.116245 Lock_time: 0.000202 Rows_sent: 10 Rows_examined: 3486
use mydbname
select tag, t.tag_id, count(p2t.post_id) as count, ((count(p2t.post_id)/1070)*100) as weight, ((count(p2t.post_id)/109)*100) as relativeweight
from wp_tags t inner join wp_post2tag p2t on t.tag_id = p2t.tag_id
inner join wp_posts p on p2t.post_id = p.ID
WHERE post_date_gmt < '2011-12-06 09:00:01'
AND (post_type = 'post')
group by t.tag
order by weight desc
LIMIT 10
# Tue Dec 6 02:00:08 2011
# Query_time: 6.926785 Lock_time: 1.731793 Rows_sent: 10 Rows_examined: 3486
use mydbname
select tag, t.tag_id, count(p2t.post_id) as count, ((count(p2t.post_id)/1070)*100) as weight, ((count(p2t.post_id)/109)*100) as relativeweight
from wp_tags t inner join wp_post2tag p2t on t.tag_id = p2t.tag_id
inner join wp_posts p on p2t.post_id = p.ID
WHERE post_date_gmt < '2011-12-06 09:00:01'
AND (post_type = 'post')
group by t.tag
order by weight desc
LIMIT 10
我将不胜感激。
谢谢!
【问题讨论】:
标签: mysql performance wordpress indexing