Bug #105185 log_queries_not_using_indexes does nothing for full index scan
Submitted: 11 Oct 2021 8:36 Modified: 13 Oct 2021 6:24
Reporter: Cheng Zhou Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:8.0.25 OS:Any
Assigned to: CPU Architecture:Any

[11 Oct 2021 8:36] Cheng Zhou
Description:
A query that uses a full index scan is not logged when log_queries_not_using_indexes is ON.

How to repeat:
1、 create table t1(c1 int, c2 char(255), c3 varchar(1000), primary key(c1,c2), index(c1));
2、insert into t1 values(1,'c21','c31'),(2,'c22','c32'),(3,'c23','c33'),(4,'c24','c34'),(5,'c25','c35');
3、set global slow_query_log=on;
4、set global log_queries_not_using_indexes=on;
5、mysql> explain select c1 from t1 where c2='c21';
+----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+--------------------------+
| id | select_type | table | partitions | type  | possible_keys | key  | key_len | ref  | rows | filtered | Extra                    |
+----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+--------------------------+
|  1 | SIMPLE      | t1    | NULL       | index | PRIMARY,c1    | c1   | 4       | NULL |    5 |    20.00 | Using where; Using index |
+----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+--------------------------+
1 row in set, 1 warning (14.71 sec)
5、select c1 from t1 where c2='c21';
6、check the slow query log, the query above was not logged.
[11 Oct 2021 8:37] Cheng Zhou
select version
[13 Oct 2021 6:24] MySQL Verification Team
Hello Cheng Zhou,

Thank you for the report and test case.

regards,
Umesh