• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

log-queries-not-using-indexes,该怎么处理

mysql 搞代码 7年前 (2018-06-04) 458次浏览 已收录 0个评论

log-queries-not-using-indexes
本来我想记录慢查询:

【my.cnf】

SQL code

 slow_query_log = /var/lib/mysql/slowquery.log  ##慢查询日志文件      long_query_time = 3  ###慢查询时间      log-queries-not-using-indexes 

欢迎大家阅读《log-queries-not-using-indexes,该怎么处理》,跪求各位点评,by 搞代码

[Warning] options –log-slow-admin-statements, –log-queries-not-using-indexes and –log-slow-sl ave-statements have no effect if –log_slow_queries is not set

重启有这个警告 
意思是 log_slow_queries 这个没设置 索引的就没作用:
然后我设置log_slow_queries
重启;
 [Warning] ‘–log_slow_queries’ is deprecated and will be removed in a future release. Please use ”–slow_query_log’/’–slow_query_log_file” instead.

又说 log_slow_queries 过时了!!

现在该怎么正确的设置呢? 
我想的到超过3秒的记录下sql语句 或者 没有索引的查询也记录下来!

——解决方案——————–
1 开慢查询不用重启

2 根本用不到log-queries-not-using-indexes这个参数

只需要set global slow_query_log=on;就可以了
——解决方案——————–
–log_slow_queries’ is deprecated 只是一个warning,它还是会生效的,当然,你最好是用它建议的
–slow_query_log
–slow_query_log_file
正确的用法是:
slow_query_log
slow_query_log_file=/var/lib/mysql/slowquery.log
log-queries-not-using-indexes

其中log-queries-not-using-indexes会记录所有没有用上索引全表扫描的语句,就算你的SQL没有超过long_query_time设置的时间。有些只有一二十条记录的表全表扫描并不是什么大事也会记录到你的慢查日志中,对慢查分析有一定的坏处,你需要斟酌加上这个参数。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:log-queries-not-using-indexes,该怎么处理

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址