MySQL 5.6+版本设置long_query_time的值无效的原因及解决方法
2016-07-29 11:43
417 查看
开启慢日志的方法:
编辑my.cnf文件:# vim /etc/my.cnf long_query_time = 1 slow_query_log = 1
然后再重启MySQL。
在实际生产环境中测试,配置确实生效,但是查看MySQL慢日志发现,慢日志中出现了很多小于1秒的查询。
原因:
在MySQL官方手册5.4.5 The Slow Query Log中的描述:
The query must either not be an administrative statement, or log_slow_admin_statements must be enabled.
The query must have taken at least long_query_time seconds, or log_queries_not_using_indexes must be enabled and the query used no indexes for row lookups.
The query must have examined at least min_examined_row_limit rows.
The query must not be suppressed according to the log_throttle_queries_not_using_indexes setting.
从第二条中可以看到,当log_queries_not_using_indexes为enable状态时,没有使用所有的查询将被记录到慢查询日志中。经测试得知,log_queries_using_indexes默认状态为enable(MySQL5.7.12)。
解决方法:
修改my.cnf配置文件,添加如下行或修改为:
log_queries_not_using_indexes = 0
然后重启MySQL。
登录MySQL,设置log_queries_not_using_indexes的全局状态为0:
set global log_queries_not_using_indexes = 0;
相关文章推荐
- 获取到UITableView的cell
- java 后台action继承ActionSupport想要使用使用request
- [leetcode] 303. Range Sum Query - Immutable
- easyui的dialog数据初始化问题解决
- js---mui返回上一页并刷新数据
- BluetoothChat之BluetoothChatService.java解析
- IOS笔记1 UIViewAnimation 向y移动
- loadrunner 函数web.custom_request使用
- easyui combogrid下拉表格的分页/按键/动态搜索
- easyui datagrid请求两次解决方法
- UI设计师必知道的设计要素
- Java--StringBuilder equals
- luigi学习8--使用中央调度器
- Juery Ajax语法
- Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION **
- leetcode 51. N-Queens
- UVA1252 Twenty Questions dp & set
- UE4学习笔记(5)—— Material Parameter Collection
- UITableViewCell添加UICollectionView,能够左右滚动用于展示不同图片。利用UICollectionView的优点,从而性能上有很大优化
- Storm ui 展示字段说明