MySQL Variables log_queries_not_using_indexes 数据库 参数变量解释及正确配置使用

本站中文解释

log_queries_not_using_indexes是MySQL服务器的一个重要参数,用于记录执行操作时未使用索引的查询。该参数有两个可能的值是ON或OFF。

如果将该参数设置为ON,MySQL服务器就会记录未使用索引的查询,并将其保存在MySQL慢查询日志中。这样,您就可以检查这些查询来改进查询性能。

要将此参数设置为ON,请执行以下操作:

1. 在MySQL命令提示符下,使用root用户凭据登录MySQL服务器。

2. 使用命令“SET GLOBAL log_queries_not_using_indexes=1”将此参数的值设置为ON。

3. 如果要将该参数的值设置为OFF,请使用命令“SET GLOBAL log_queries_not_using_indexes=0”。

4. 在完成设置后,请使用命令“FLUSH LOGS”刷新MySQL日志,以便将更改保存到磁盘上的日志文件中。

官方英文解释

log_queries_not_using_indexes

Command-Line Format --log-queries-not-using-indexes[={OFF|ON}]
System Variable log_queries_not_using_indexes
Scope Global
Dynamic Yes
Type Boolean
Default Value OFF

If you enable this variable with the slow query log enabled,
queries that are expected to retrieve all rows are logged. See
Section 5.4.5, “The Slow Query Log”. This option does not
necessarily mean that no index is used. For example, a query
that uses a full index scan uses an index but would be logged
because the index would not limit the number of rows.


数据运维技术 » MySQL Variables log_queries_not_using_indexes 数据库 参数变量解释及正确配置使用