首页 文章

MySQL SET时间戳作为慢查询[重复]

提问于
浏览
2

可能重复:“设置时间戳”如何成为慢查询?

我正在使用PHP和MySQL 5.1运行Web应用程序和Wordpress博客,驻留在VPS服务器上 . 慢查询日志显示了许多条目,这些条目不应该花费很长时间才能完成 . 奇怪的是,当我点击我的博客链接时,通常需要很长时间才能加载,但之后很快就会加载 . 然后在几个小时内再次回到慢速第一次点击 . 似乎“SET timestamp =”查询几乎存在于所有慢速条目中 . 以下是它的外观示例:

# Time: 110129  4:02:06
# User@Host: appsadmin[appsadmin] @ localhost []
# Query_time: 1.367264  Lock_time: 0.000043 Rows_sent: 18  Rows_examined: 18
use apps;
SET timestamp=1296291726;
show tables;
# Time: 110129  4:02:07
# User@Host: wp_user[wp_user] @ localhost []
# Query_time: 0.635450  Lock_time: 0.000041 Rows_sent: 11  Rows_examined: 11
use wordpress_user;
SET timestamp=1296291727;
show tables;
# Time: 110130  4:02:03
# User@Host: appsadmin[appsadmin] @ localhost []
# Query_time: 0.592159  Lock_time: 0.000000 Rows_sent: 0  Rows_examined: 0
use apps;
SET timestamp=1296378123;
SELECT /*!40001 SQL_NO_CACHE */ * FROM `mail_queue`;
# Time: 110131  4:02:08
# User@Host: appsadmin[appsadmin] @ localhost []
# Query_time: 2.789990  Lock_time: 0.000047 Rows_sent: 18  Rows_examined: 18
SET timestamp=1296464528;
show tables;
# Time: 110131  4:02:09
# User@Host: wp_user[wp_user] @ localhost []
# Query_time: 0.535981  Lock_time: 0.000041 Rows_sent: 11  Rows_examined: 11
use wordpress_user;
SET timestamp=1296464529;
show tables;
# Time: 110201  3:19:03
# User@Host: wp_user[wp_user] @ localhost []
# Query_time: 1.401393  Lock_time: 0.000071 Rows_sent: 120  Rows_examined: 145
SET timestamp=1296548343;
SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes';

这表明它不是我的数据库设计的问题,而是某种配置问题 .

1 回答

  • 0

    您是否在使用VPS进行交换?也许缺少内存会导致查询速度变慢 . 此外,我会尝试启用mysql查询缓存并禁用系统上不必要的东西(例如,未使用的apache模块,系统服务等)来恢复内存 .

    稍微不相关,如果你的wordpress网站存在性能问题,我会调查“WP Super Cache”(http://wordpress.org/extend/plugins/wp-super-cache/)

相关问题