Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.3.7, 10.4.2, 10.1.37, 10.2.21
-
None
Description
As per the manual,
Slow_queries
Description: Number of queries which took longer than long_query_time to run. The slow query log does not need to be active for this to be recorded.
https://mariadb.com/kb/en/library/server-status-variables/#slow_queries
But in real scenario, we have to active slow query log otherwise, it will not be recoded.
MariaDB [test]> select @@long_query_time, @@slow_query_log;
|
+-------------------+------------------+
|
| @@long_query_time | @@slow_query_log |
|
+-------------------+------------------+
|
| 10.000000 | 0 |
|
+-------------------+------------------+
|
1 row in set (0.029 sec)
|
|
MariaDB [test]> show global status like 'slow_queries';
|
+---------------+-------+
|
| Variable_name | Value |
|
+---------------+-------+
|
| Slow_queries | 0 |
|
+---------------+-------+
|
1 row in set (0.005 sec)
|
|
MariaDB [test]> set global long_query_time=0.1;
|
Query OK, 0 rows affected (0.027 sec)
|
|
MariaDB [test]> \r
|
Connection id: 10
|
Current database: test
|
|
MariaDB [test]> select sleep(1) from mysql.user limit 2;
|
+----------+
|
| sleep(1) |
|
+----------+
|
| 0 |
|
| 0 |
|
+----------+
|
2 rows in set (2.079 sec)
|
|
MariaDB [test]> show global status like 'slow_queries';
|
+---------------+-------+
|
| Variable_name | Value |
|
+---------------+-------+
|
| Slow_queries | 0 |
|
+---------------+-------+
|
1 row in set (0.005 sec)
|
|
MariaDB [test]> set global slow_query_log=ON;
|
Query OK, 0 rows affected (0.038 sec)
|
|
MariaDB [test]> \r
|
Connection id: 11
|
Current database: test
|
|
MariaDB [test]> select @@long_query_time, @@slow_query_log;
|
+-------------------+------------------+
|
| @@long_query_time | @@slow_query_log |
|
+-------------------+------------------+
|
| 0.100000 | 1 |
|
+-------------------+------------------+
|
1 row in set (0.001 sec)
|
|
MariaDB [test]> select sleep(1) from mysql.user limit 2;
|
+----------+
|
| sleep(1) |
|
+----------+
|
| 0 |
|
| 0 |
|
+----------+
|
2 rows in set (1.996 sec)
|
|
MariaDB [test]> show global status like 'slow_queries';
|
+---------------+-------+
|
| Variable_name | Value |
|
+---------------+-------+
|
| Slow_queries | 1 |
|
+---------------+-------+
|
1 row in set (0.005 sec)
|
Attachments
Issue Links
- relates to
-
MDEV-18892 Regression in slow log and admin statements
-
- Closed
-
-
MDEV-18907 Slow log: RENAME TABLE is not "admin", while ALTER TABLE..RENAME is
-
- Closed
-
The difference was introduced by this commit:
commit e2b2bde358f434d945e9730acfbc6eedeb9ab8a2
Author: Monty
Date: Sun Aug 3 15:26:47 2014 +0300
Made sql_log_slow a session variable
mysqldump:
- Added --log-queries to allow one to disable logging for the dump
sql/log_event.cc:
- Removed setting of enable_slow_log as it's not required anymore.
sql/sql_parse.cc:
- Set enable_slow_log to value of thd->variables.sql_log_slow as this will speed up tests if slow log is disabled.
- opt_log_slow_admin_statements can now only disable slow log, not enable it.
sql/sql_explain.cc:
- Minor cleanup
Other things:
- Added sql_log_slow to system variables.
- Changed opt_slow_log to global_system_variables.sql_log_slow in all files
- Updated tests to reflect changes
If we want to keep it this way, documentation needs to be updated.