Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-18333

Slow_queries count doesn't increase when slow_query_log is turned off

    XMLWordPrintable

Details

    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

          Activity

            People

              bar Alexander Barkov
              niljoshi Nilnandan Joshi
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.