这个问题研究了n次,每次都以失败告终,今天又突然想研究下,但是还是没有进展。大家帮忙看下。先谢过了!
我描述下问题,我手头有个网站,用PHP+mysql+iis+windows 2003 配置,网站间歇性变慢,大概持续15分钟,每天1-2次。网站变慢后,网站打开速度从5s提高的20s,慢的速度难以让人接受。
在网站变慢的时候,我查看了下服务器cpu使用,不到10%。然后使用mysql命令
show processlist;
打印出结果如下:
mysql> show processlist;
+----------+------+-----------------+------+---------+------+--------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----------+------+-----------------+------+---------+------+--------------------+------------------+
| 19021447 | root | 127.0.0.1:28253 | o2o | Query | 17 | removing tmp table | DESC fanwe_user |
| 19025616 | root | 127.0.0.1:32578 | NULL | Query | 0 | NULL | show processlist |
+----------+------+-----------------+------+---------+------+--------------------+------------------+
持续打印 show processlist;命令 state还会变成close table等状态 Time时间有时候会增加到20s。
sql语句 DESC fanwe_user 我在phpmyadmin里执行 执行时间几乎统计不到,为什么在这里要花费 20s的查询时间呢
我去查询了下 mysql 慢查询日志:
输出结果 如下:
# Time: 140611 10:14:16
# User@Host: root[root] @ [127.0.0.1]
# Query_time: 6.218750 Lock_time: 0.000000 Rows_sent: 67 Rows_examined: 67
SET timestamp=1402452856;
DESC fanwe_user;
# Time: 140611 10:14:30
# User@Host: root[root] @ [127.0.0.1]
# Query_time: 7.718750 Lock_time: 0.015625 Rows_sent: 67 Rows_examined: 67
SET timestamp=1402452870;
DESC fanwe_user;
# Time: 140611 10:14:40
# User@Host: root[root] @ [127.0.0.1]
# Query_time: 7.531250 Lock_time: 0.000000 Rows_sent: 67 Rows_examined: 67
SET timestamp=1402452880;
DESC fanwe_user;
# Time: 140611 10:15:12
# User@Host: root[root] @ [127.0.0.1]
# Query_time: 23.765625 Lock_time: 0.000000 Rows_sent: 67 Rows_examined: 67
SET timestamp=1402452912;
DESC fanwe_user;
# Time: 140611 10:15:28
# User@Host: root[root] @ [127.0.0.1]
# Query_time: 10.296875 Lock_time: 0.000000 Rows_sent: 67 Rows_examined: 67
SET timestamp=1402452928;
DESC fanwe_user;
# Time: 140611 10:15:53
# User@Host: root[root] @ [127.0.0.1]
# Query_time: 10.812500 Lock_time: 0.000000 Rows_sent: 67 Rows_examined: 67
SET timestamp=1402452953;
DESC fanwe_user;
。。。。。后面还有很多 都是在DESC table。有时候 table的名字会变化。但只是2个表
现在对于这个一点头绪没有,希望各位能帮忙解决下。
===================================
mysql> show global variables like '%table%';
+----------------------------------------+----------+
| Variable_name | Value |
+----------------------------------------+----------+
| big_tables | OFF |
| innodb_file_per_table | OFF |
| innodb_table_locks | ON |
| lower_case_table_names | 1 |
| max_heap_table_size | 16777216 |
| max_tmp_tables | 32 |
| old_alter_table | OFF |
| performance_schema_max_table_handles | 100000 |
| performance_schema_max_table_instances | 50000 |
| sql_big_tables | OFF |
| table_definition_cache | 400 |
| table_open_cache | 1520 |
| tmp_table_size | 70254592 |
| updatable_views_with_limit | YES |
+----------------------------------------+----------+
14 rows in set (0.00 sec)
=========================show create table fanwe_user 数据==================================
mysql> show create table fanwe_user\G;
*************************** 1. row ***************************
Table: fanwe_user
Create Table: CREATE TABLE `fanwe_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) NOT NULL,
`user_pwd` varchar(255) NOT NULL,
`create_time` int(11) NOT NULL,
`update_time` int(11) NOT NULL,
`login_ip` varchar(255) NOT NULL,
`group_id` int(11) NOT NULL,
`is_effect` tinyint(1) NOT NULL,
`is_delete` tinyint(1) NOT NULL,
`email` varchar(255) NOT NULL,
`mobile` varchar(255) NOT NULL,
`score` int(11) NOT NULL,
`money` double(20,4) NOT NULL,
`verify` varchar(255) NOT NULL,
`code` varchar(255) NOT NULL COMMENT '鐧诲綍鐢ㄧ殑鏍囪瘑鐮?,
`pid` int(11) NOT NULL,
`login_time` int(11) NOT NULL,
`referral_count` int(11) NOT NULL,
`password_verify` varchar(255) NOT NULL,
`integrate_id` int(11) NOT NULL,
`sina_id` int(11) NOT NULL,
`renren_id` int(11) NOT NULL,
`kaixin_id` int(11) NOT NULL,
`sohu_id` int(11) NOT NULL,
`lottery_mobile` varchar(255) NOT NULL,
`lottery_verify` varchar(255) NOT NULL,
`verify_create_time` int(11) NOT NULL,
`tencent_id` varchar(255) NOT NULL,
`referer` varchar(255) NOT NULL,
`login_pay_time` int(11) NOT NULL,
`focus_count` int(11) NOT NULL COMMENT '鍏虫敞鍒汉鐨勬暟閲?,
`focused_count` int(11) NOT NULL COMMENT '绮変笣鏁?,
`province_id` int(11) NOT NULL,
`city_id` int(11) NOT NULL,
`sex` tinyint(1) NOT NULL DEFAULT '-1',
`my_intro` varchar(255) NOT NULL,
`is_merchant` tinyint(1) NOT NULL,
`merchant_name` varchar(255) NOT NULL,
`is_daren` tinyint(1) NOT NULL,
`daren_title` varchar(255) NOT NULL,
`step` tinyint(1) NOT NULL,
`byear` int(4) NOT NULL,
`bmonth` int(2) NOT NULL,
`bday` int(2) NOT NULL,
`locate_time` int(11) DEFAULT '0' COMMENT '鐢ㄦ埛鏈
另外,我还有个问题没有说,我的这个数据库选择的是innodb类型的,但是我的表都是MyISAM类型的,不知道这会不会影响性能