Bug #81796 Slow_queries not incremented if slow_query_log is OFF.
Submitted: 10 Jun 2016 4:09 Modified: 20 Jun 2016 10:46
Reporter: vishnu chanderraju (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.7.10, 5.7.13 OS:Linux
Assigned to: CPU Architecture:Any

[10 Jun 2016 4:09] vishnu chanderraju
Description:
As per the documentation for long_query_time:

"If a query takes longer than this many seconds, the server increments the Slow_queries status variable."

If the slow_query_log is enabled then this query is logged.

But

In 5.7, if the slow_query_log is OFF, the counter is not incremented even if the query took greater than long_query_time.

This used to work in 5.6.

How to repeat:
set long_query_time = 10;

set slow_query_log = 0;

select sleep(12); # ie. greater than 10 seconds

show global status like '%Slow_queries%'; 

the count will be 0
[20 Jun 2016 10:46] MySQL Verification Team
Hello Vishnu Rao,

Thank you for the report.

Thanks,
Umesh
[10 Mar 2022 9:37] Aftab Khan
This issue exists in mysql 8 too:

{code}

select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.26-16 |
+-----------+
1 row in set (0.00 sec)

 select @@slow_query_log, @@long_query_time;
+------------------+-------------------+
| @@slow_query_log | @@long_query_time |
+------------------+-------------------+
|                0 |          1.000000 |
+------------------+-------------------+
1 row in set (0.00 sec)

 show status like 'slow_queries';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries  | 0     |
+---------------+-------+
1 row in set (0.00 sec)

{code}

Run slow query

{code}
 select sleep(3);
+----------+
| sleep(3) |
+----------+
|        0 |
+----------+
1 row in set (3.00 sec)
{code}
slow_Queries counter doesn't increment

{code}
show status like 'slow_queries';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Slow_queries  | 0     |
+---------------+-------+
1 row in set (0.00 sec)
{code}