log_slow_queries? off? 表示"慢查询"是"关闭的状态"
slow_queries_log? off? 表示慢查询日志开关是关着的
使用命令:set global log_slow_queries=on;? 这样就开启了慢查询的功能,此参数打开了,slow_query_log就自动变成了on,关闭了的话也跟着关闭.
如果thread create的时间超过了这个值,这变量slow_launch_time的值加1.
set global log_launch_time=1? 这里的时间值必须是整数,否则的话就话执行出错
慢查询的查询阀值是long_query_time 默认是10秒
要真正修改慢查询得去修改mysql的文件,内容添加如下
并且还得重新启动mysql才会生效
慢查询的日志结构如下:
MySQLa, Version: ⑤⑤40-log (MySQL Community Server (GPL)). started with: TCP Port: 3306, Named Pipe: (null) Time Id Command Argument # Time: 150705 18:31:54 # User@Host: root[root] @ localhost [12⑦0.0.1] # Query_time: 0.012001 Lock_time: 0.001000 Rows_sent: 51 Rows_examined: 51 use weixin; SET timestamp=1436092314; show databases; # Time: 150705 18:32:55 # User@Host: root[root] @ localhost [12⑦0.0.1] # Query_time: 0.002000 Lock_time: 0.001000 Rows_sent: 1 Rows_examined: 1 SET timestamp=1436092375; show variables like "%query_time%"; # Time: 150705 18:33:03 # User@Host: root[root] @ localhost [12⑦0.0.1] # Query_time: 0.001000 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 use chlitina; SET timestamp=1436092383; use ◆chlitina◆; # User@Host: root[root] @ localhost [12⑦0.0.1] # Query_time: 0.031001 Lock_time: 0.001000 Rows_sent: 869 Rows_examined: 869 SET timestamp=1436092383; select * from wp_consultant; # Time: 150705 18:33:40 # User@Host: root[root] @ localhost [12⑦0.0.1] # Query_time: 0.052003 Lock_time: 0.001000 Rows_sent: 869 Rows_examined: 1738 SET timestamp=1436092420; select * from wp_consultant order by id desc;
以上就是土嘎嘎小编为大家整理的mysql优化 慢查询_一)相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!