Bug #108818 Reference Manual Error: Slow_queries counter will not increase when disabled
Submitted: 19 Oct 2022 7:33 Modified: 31 Oct 2022 14:24
Reporter: beon feng Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[19 Oct 2022 7:33] beon feng
Description:
As described, Slow_queries counter will not increase when disabled, while Reference Manual says "Slow_queries : The number of queries that have taken more than long_query_time seconds. This counter increments regardless of whether the slow query log is enabled."

How to repeat:
1. initial status
MySQL [testdb]> show variables like '%slow%';
+---------------------------+---------------------------+
| Variable_name             | Value                     |
+---------------------------+---------------------------+
| log_slow_admin_statements | OFF                       |
| log_slow_extra            | OFF                       |
| log_slow_slave_statements | OFF                       |
| slow_launch_time          | 2                         |
| slow_query_log            | ON                        |
| slow_query_log_file       | /mysql/logs/slow13336.log |
+---------------------------+---------------------------+
6 rows in set (0.02 sec)

MySQL [testdb]> show global status like '%slow%';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| Slow_launch_threads | 0     |
| Slow_queries        | 1     |
+---------------------+-------+
2 rows in set (0.00 sec)

MySQL [testdb]> show variables like '%long%';
+----------------------------------------------------------+----------+
| Variable_name                                            | Value    |
+----------------------------------------------------------+----------+
| long_query_time                                          | 0.300000 |

2. set global slow_query_log=0;
MySQL [testdb]> set global slow_query_log=0;
Query OK, 0 rows affected (0.00 sec)

MySQL [testdb]> select *,sleep(0.5) from t1;
+----+----------+------+------------+
| id | name     | age  | sleep(0.5) |
+----+----------+------+------------+
|  1 | zhangsan |   18 |          0 |
|  2 | lisi     |   21 |          0 |
|  3 | jack     |   17 |          0 |
|  4 | alei     |   25 |          0 |
+----+----------+------+------------+
4 rows in set (2.00 sec)

MySQL [testdb]> show global status like '%slow%';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| Slow_launch_threads | 0     |
| Slow_queries        | 2     |
+---------------------+-------+
2 rows in set (0.00 sec)

MySQL [testdb]> select *,sleep(1) from t1;
+----+----------+------+----------+
| id | name     | age  | sleep(1) |
+----+----------+------+----------+
|  1 | zhangsan |   18 |        0 |
|  2 | lisi     |   21 |        0 |
|  3 | jack     |   17 |        0 |
|  4 | alei     |   25 |        0 |
+----+----------+------+----------+
4 rows in set (4.01 sec)

MySQL [testdb]> show global status like '%slow%';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| Slow_launch_threads | 0     |
| Slow_queries        | 2     |
+---------------------+-------+

3. set global slow_query_log=1;
MySQL [testdb]> set global slow_query_log=1;
Query OK, 0 rows affected (0.01 sec)

MySQL [testdb]> select *,sleep(1) from t1;
+----+----------+------+----------+
| id | name     | age  | sleep(1) |
+----+----------+------+----------+
|  1 | zhangsan |   18 |        0 |
|  2 | lisi     |   21 |        0 |
|  3 | jack     |   17 |        0 |
|  4 | alei     |   25 |        0 |
+----+----------+------+----------+
4 rows in set (4.00 sec)

MySQL [testdb]> show global status like '%slow%';
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| Slow_launch_threads | 0     |
| Slow_queries        | 3     |
+---------------------+-------+
[20 Oct 2022 12:10] MySQL Verification Team
Hello beon feng,

Thank you for the report and feedback.
Could you please specify the version in which you are seeing this issue? This is most likely duplicate of Bug #91496 which is fixed in 8.0.30 release.

regards,
Umesh
[21 Oct 2022 3:15] beon feng
I see that from the following web:
https://dev.mysql.com/doc/refman/8.0/en/server-status-variables.html#statvar_Slow_queries
[21 Oct 2022 3:19] beon feng
This is the Reference Manual for the MySQL Database System, version 8.0, through release 8.0.31.
[31 Oct 2022 14:24] MySQL Verification Team
Hi Mr. feng,

Thank you, very much, for your bug report.

However, this is not a bug.

Our documentation is quite correct .  Slow query counter and slow query log are completely unrelated. You have other variables that control slow query counter.

Not a bug.