mysql 查询慢日志大牛帮分析下

2015-07-20 16:52:12 +08:00
 YAFEIML
wp程序,后台点击任意连接慢成狗,1万多点文章,下面是慢日志,大牛给讲讲咋优化下:

/usr/local/mysql/bin/mysqld, Version: 5.5.42-log (Source distribution). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
/usr/local/mysql/bin/mysqld, Version: 5.5.42-log (Source distribution). started with:
Tcp port: 3306 Unix socket: /tmp/mysql.sock
Time Id Command Argument
# Time: 150720 15:44:47
# User@Host: root[root] @ localhost []
# Query_time: 1.731746 Lock_time: 0.000108 Rows_sent: 1 Rows_examined: 23720
use database;
SET timestamp=1437378287;
SELECT * FROM wp_posts WHERE ID = 23731 LIMIT 1;
# Time: 150720 15:44:49
# User@Host: root[root] @ localhost []
# Query_time: 1.490322 Lock_time: 0.000096 Rows_sent: 5 Rows_examined: 27032
SET timestamp=1437378289;
SELECT wp_posts.* FROM wp_posts WHERE ID IN (27042,27040,27038,27036,27034);
# Time: 150720 15:44:51
# User@Host: root[root] @ localhost []
# Query_time: 1.680649 Lock_time: 0.000124 Rows_sent: 10 Rows_examined: 3076
SET timestamp=1437378291;
SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format') AND tr.object_id IN (27034, 27036, 27038, 27040, 27042) ORDER BY t.name ASC;
1871 次点击
所在节点    问与答
2 条回复
qinglangee
2015-07-20 18:35:13 +08:00
wp_posts 表上 id 没建索引吧,建个索引试试
CREATE INDEX wp_posts_id ON wp_posts (ID);
YAFEIML
2015-07-20 18:38:37 +08:00
@qinglangee 建立了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/206991

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX