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 |
+---------------------+-------+