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

(Feature) Database name missing from Slow Query Log entires

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 10.3.20
    • N/A
    • Server
    • RHEL 7

    Description

      When searching through the Slow Query Log we cannot identify the database which had the slow query. We have a number of databases on our instances, most of which do not include the name of the database in the query itself.

      It would be helpful to include the name of the database somewhere in the log entry. One recommendation is to place it on the same line as the User (user@host/database).

      Attachments

        Activity

          It already has the database field, it is called db in the log table and Schema in the log file (I'm not sure which of them you are talking about).
          Naturally, it is populated with the current default database name, if any; but it's the only important one, because if you don't have a current database or you are using tables from different ones, table names will be fully qualified anyway.

          MariaDB [(none)]> create database test;
          Query OK, 1 row affected (0.000 sec)
           
          MariaDB [(none)]> use test;
          Database changed
          MariaDB [test]> set long_query_time=0.1;
          Query OK, 0 rows affected (0.000 sec)
           
          MariaDB [test]> create table t1 as select sleep(0.5);
          Query OK, 1 row affected (0.805 sec)
          Records: 1  Duplicates: 0  Warnings: 0
          

          log table

              start_time: 2020-01-13 15:43:02.474999
               user_host: root[root] @ localhost [::1]
              query_time: 00:00:00.804504
               lock_time: 00:00:00.204743
               rows_sent: 0
           rows_examined: 0
                      db: test
          last_insert_id: 0
               insert_id: 0
               server_id: 1
                sql_text: create table t1 as select sleep(0.5)
               thread_id: 41
           rows_affected: 1
          

          log file

          # Time: 200113 15:43:02
          # User@Host: root[root] @ localhost [::1]
          # Thread_id: 41  Schema: test  QC_hit: No
          # Query_time: 0.804504  Lock_time: 0.204743  Rows_sent: 0  Rows_examined: 0
          # Rows_affected: 1  Bytes_sent: 50
          use test;
          SET timestamp=1578922982;
          create table t1 as select sleep(0.5);
          

          elenst Elena Stepanova added a comment - It already has the database field, it is called db in the log table and Schema in the log file (I'm not sure which of them you are talking about). Naturally, it is populated with the current default database name, if any; but it's the only important one, because if you don't have a current database or you are using tables from different ones, table names will be fully qualified anyway. MariaDB [(none)]> create database test; Query OK, 1 row affected (0.000 sec)   MariaDB [(none)]> use test; Database changed MariaDB [test]> set long_query_time=0.1; Query OK, 0 rows affected (0.000 sec)   MariaDB [test]> create table t1 as select sleep(0.5); Query OK, 1 row affected (0.805 sec) Records: 1 Duplicates: 0 Warnings: 0 log table start_time: 2020-01-13 15:43:02.474999 user_host: root[root] @ localhost [::1] query_time: 00:00:00.804504 lock_time: 00:00:00.204743 rows_sent: 0 rows_examined: 0 db: test last_insert_id: 0 insert_id: 0 server_id: 1 sql_text: create table t1 as select sleep(0.5) thread_id: 41 rows_affected: 1 log file # Time: 200113 15:43:02 # User@Host: root[root] @ localhost [::1] # Thread_id: 41 Schema: test QC_hit: No # Query_time: 0.804504 Lock_time: 0.204743 Rows_sent: 0 Rows_examined: 0 # Rows_affected: 1 Bytes_sent: 50 use test; SET timestamp=1578922982; create table t1 as select sleep(0.5);

          People

            Unassigned Unassigned
            elmorej Johnathan Elmore
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.