免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1416 | 回复: 1
打印 上一主题 下一主题

mysqldumpslow输出错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-16 15:06 |只看该作者 |倒序浏览
本帖最后由 big_turnip 于 2013-07-16 15:28 编辑
  1. [root@tw-web tmp]# mysqldumpslow -t 3 -s at /var/log/mysql/slowquery.log

  2. Reading mysql slow query log from /var/log/mysql/slowquery.log
  3. Count: 2  Time=57.00s (114s)  Lock=0.00s (0s)  Rows=0.0 (0), xxxxxxxxxxxxxxxxxx
  4.   # Thread_id: N  Schema: xxxx  Last_errno: N  Killed: N
  5.   # Query_time: N.N  Lock_time: N.N  Rows_sent: N  Rows_examined: N  Rows_affected: N  Rows_read: N
  6.   # Bytes_sent: N
  7.   SET timestamp=N;
  8.   SELECT `id`,`uname`,`alias`,`pid`,`limit` FROM `xxxxxxx`

  9. Count: 1  Time=57.00s (57s)  Lock=0.00s (0s)  Rows=0.0 (0), xxxxxxxxxxxxxxxxxxxxx
  10.   # Thread_id: N  Schema: xxxx  Last_errno: N  Killed: N
  11.   # Query_time: N.N  Lock_time: N.N  Rows_sent: N  Rows_examined: N  Rows_affected: N  Rows_read: N
  12.   # Bytes_sent: N
  13.   SET timestamp=N;
  14.   SELECT `uname`,`email`,`pwd`,`spwd` FROM `xxxxxx` WHERE ( `email` = 'S' ) AND ( `uname` = 'S' ) LIMIT N

  15. Count: 1  Time=57.00s (57s)  Lock=0.00s (0s)  Rows=0.0 (0), xxxxxxxxxxxxxxxxxxxxxxx
  16.   # Thread_id: N  Schema: xxxxx  Last_errno: N  Killed: N
  17.   # Query_time: N.N  Lock_time: N.N  Rows_sent: N  Rows_examined: N  Rows_affected: N  Rows_read: N
  18.   # Bytes_sent: N
  19.   SET timestamp=N;
  20.   SELECT * FROM `xxxxx`

复制代码

  1. [root@tw-web-223 tmp]# grep Query_time /var/log/mysql/slowquery.log |sort -r |head -n 3
  2. # Query_time: 0.003627  Lock_time: 0.000060  Rows_sent: 732  Rows_examined: 732  Rows_affected: 0  Rows_read: 732
  3. # Query_time: 0.003410  Lock_time: 0.000058  Rows_sent: 732  Rows_examined: 732  Rows_affected: 0  Rows_read: 732
  4. # 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秒呢
  1. mysql> show variables like 'long%';
  2. +-----------------+----------+
  3. | Variable_name   | Value    |
  4. +-----------------+----------+
  5. | long_query_time | 1.000000 |
  6. +-----------------+----------+
  7. 1 row in set (0.00 sec)
复制代码
配置中long_query_time = 1不是设定为慢查询为1s,为什么1s以下的查询也被记录到slowquery.log了

论坛徽章:
0
2 [报告]
发表于 2013-07-17 11:09 |只看该作者
关于mysql slow quary log。我们一般在设置时有下面几个参数需要注意:
1、long_query_time   这个是查询的时间。
2、log_queries_not_using_indexes  如果这个选项开启,则查询时间小于long_quary_time,也会记录在slowlog里。
3、slow_query_log  slow_query_log_file  开启slowlog和slowlog的存放位置。

所以,关于你的问题,请你看下你的 log_queries_not_using_indexes 参数是否开启。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP