mysql慢日志

        MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响应时间超过阀值的语句。

#开启慢SQL日志功能
set GLOBAL slow_query_log=on;
#慢SQL执行时间阈值,单位(秒) ,1毫秒=0.001
#不建议超过300ms,最终结果视情况而定
set global long_query_time=0.001;
#指定慢SQL文件名为slow-sql,慢SQL日志保存在mysql/data目录下
set global slow_query_log_file="slow-sql.log";
#是否记录没有使用索引的SQL语句
set global log_queries_not_using_indexes=on;
#但是以上设置在mysql重启后都会失效,如果需要持久化,就将以上设置写入到my.cnf文件中

#并且以上设置需要在下次数据库连接的时候才能生效,需要重启Navicat

 

重启后检查一下设置是否生效

 

慢日志的说明

 

# Time: 2019-05-14T07:07:36.814164Z - 执行时间
# User@Host: root[root] @ localhost [::1] Id: 29 - 环境信息
# Query_time: 0.020783 - 查询时间 *****
# Lock_time: 0.000105 - 资源锁定时间
# Rows_sent: 9539 - 查询结果总行数
# Rows_examined: 19078 - 扫描的行数 *****
#SET timestamp=1557817656; - 时间戳
#=======SQL==========
#select gc.*, g.title from t_goods g , t_goods_cover gc
#where g.goods_id = gc.goods_id and g.goods_id > 60;

select * from t_goods where goods_id <> 10;

 

posted @ 2020-08-04 15:59  wuxiaomiao  阅读(258)  评论(0编辑  收藏  举报