【已解答】MYSQL中的慢查询日志,根本不是设置中的1秒以...
# mysql -u root -pEnter password:
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MySQL connection id is 280009
Server version: 5.7.44-log Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> SHOW GLOBAL VARIABLES LIKE 'long_query_time';
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| long_query_time | 1.000000 |
+-----------------+----------+
1 row in set (0.001 sec)
long_query_time = 1
但实际上0.000563秒的这种查询都会大量显示出来,造成慢查询日志中的数据太多,而很难捕捉到真正有问题的慢查询。
<blockquote>SHOW COLUMNS FROM `mysqlactor`;SHOW COLUMNS FROM `mysqlactor`;
# Time: 2025-06-13T09:19:09.370701Z
# User@Host: www_baidu_com @ localhost Id: 275023
# Query_time: 0.000563Lock_time: 0.000094 Rows_sent: 82Rows_examined: 82
SET timestamp=1749806349;
SHOW COLUMNS FROM `mysqlvod`;
# Time: 2025-06-13T09:19:09.405967Z
# User@Host: www_baidu_com @ localhost Id: 275023
# Query_time: 0.000370Lock_time: 0.000073 Rows_sent: 42Rows_examined: 42
SET timestamp=1749806349;
SHOW COLUMNS FROM `mysqlactor`;
# Time: 2025-06-13T09:19:09.987803Z
# User@Host: www_baidu_com @ localhost Id: 275031
# Query_time: 0.000431Lock_time: 0.000072 Rows_sent: 82Rows_examined: 82
SET timestamp=1749806349;
SHOW COLUMNS FROM `mysqlvod`;
# Time: 2025-06-13T09:19:10.014046Z
没人回答吗? mysql默认开启log_slow_admin_statements,即无论 long_query_time 设置为多少,管理命令(如 SHOW COLUMNS)就会被记录到慢日志中
你上面日志中出现SHOW COLUMNS FROM ... 属于管理命令,因此被记录
在mysql的配置文件中mysqld下添加log_slow_admin_statements = OFF,重启mysql,不记录管理命令 阿珂 发表于 2025-6-18 17:18
mysql默认开启log_slow_admin_statements,即无论 long_query_time 设置为多少,管理命令(如 SHOW COLUMNS ...
关闭这个又有什么不好的影响吗?
关闭后不记录管理命令,出现和管理命令相关的性能问题时,没有慢查询日志作为参考,会增加定位问题的难度
一般不建议关闭
页:
[1]