- 论坛徽章:
- 0
|
本帖最后由 big_turnip 于 2013-07-16 15:28 编辑
- [root@tw-web tmp]# mysqldumpslow -t 3 -s at /var/log/mysql/slowquery.log
- Reading mysql slow query log from /var/log/mysql/slowquery.log
- Count: 2 Time=57.00s (114s) Lock=0.00s (0s) Rows=0.0 (0), xxxxxxxxxxxxxxxxxx
- # Thread_id: N Schema: xxxx Last_errno: N Killed: N
- # Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N Rows_read: N
- # Bytes_sent: N
- SET timestamp=N;
- SELECT `id`,`uname`,`alias`,`pid`,`limit` FROM `xxxxxxx`
- Count: 1 Time=57.00s (57s) Lock=0.00s (0s) Rows=0.0 (0), xxxxxxxxxxxxxxxxxxxxx
- # Thread_id: N Schema: xxxx Last_errno: N Killed: N
- # Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N Rows_read: N
- # Bytes_sent: N
- SET timestamp=N;
- SELECT `uname`,`email`,`pwd`,`spwd` FROM `xxxxxx` WHERE ( `email` = 'S' ) AND ( `uname` = 'S' ) LIMIT N
- Count: 1 Time=57.00s (57s) Lock=0.00s (0s) Rows=0.0 (0), xxxxxxxxxxxxxxxxxxxxxxx
- # Thread_id: N Schema: xxxxx Last_errno: N Killed: N
- # Query_time: N.N Lock_time: N.N Rows_sent: N Rows_examined: N Rows_affected: N Rows_read: N
- # Bytes_sent: N
- SET timestamp=N;
- SELECT * FROM `xxxxx`
复制代码
- [root@tw-web-223 tmp]# grep Query_time /var/log/mysql/slowquery.log |sort -r |head -n 3
- # Query_time: 0.003627 Lock_time: 0.000060 Rows_sent: 732 Rows_examined: 732 Rows_affected: 0 Rows_read: 732
- # Query_time: 0.003410 Lock_time: 0.000058 Rows_sent: 732 Rows_examined: 732 Rows_affected: 0 Rows_read: 732
- # Query_time: 0.003395 Lock_time: 0.000026 Rows_sent: 732 Rows_examined: 732 Rows_affected: 0 Rows_read: 732
复制代码 slowquery.log中最久的查询都没有超过1秒,为什么,用mysqldumpslow处理后的log会有那个多个57秒呢- mysql> show variables like 'long%';
- +-----------------+----------+
- | Variable_name | Value |
- +-----------------+----------+
- | long_query_time | 1.000000 |
- +-----------------+----------+
- 1 row in set (0.00 sec)
复制代码 配置中long_query_time = 1不是设定为慢查询为1s,为什么1s以下的查询也被记录到slowquery.log了
|
|