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

Print EXPLAIN [ANALYZE] in the slow query log

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None

    Description

      SHOW EXPLAIN allows to produce EXPLAIN during the query execution. We are now able to save it in the slow query log.

      The user interface is as follows:

      "explain" is a new flag in log-slow-verbosity argument:

      [mysqld]
      ...
      log-slow-verbosity=query_plan,explain

      The output is printed into slow query log like this:

      # User@Host: root[root] @ localhost []
      # Thread_id: 2  Schema: j4  QC_hit: No
      # Query_time: 0.000629  Lock_time: 0.000202  Rows_sent: 3  Rows_examined: 3
      # Full_scan: Yes  Full_join: No  Tmp_table: No  Tmp_table_on_disk: No
      # Filesort: No  Filesort_on_disk: No  Merge_passes: 0
      ## <explain>
      ##   id select_type     table   type    possible_keys   key     key_len ref     rows    Extra
      ##   1  SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    3       Using where
      ## </explain>
      SET timestamp=1381828772;
      select * from t1 where a between 1 and 3333;

      Attachments

        Issue Links

          Activity

            psergei Sergei Petrunia created issue -
            psergei Sergei Petrunia made changes -
            Field Original Value New Value
            psergei Sergei Petrunia made changes -
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ]
            psergei Sergei Petrunia made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            psergei Sergei Petrunia made changes -
            Description SHOW EXPLAIN allows to produce EXPLAIN during the query execution. We are now able to save it in the slow query log. SHOW EXPLAIN allows to produce EXPLAIN during the query execution. We are now able to save it in the slow query log.

            The user interface is as follows:

            "explain" is a new flag in log-slow-verbosity argument:

            {noformat}
            [mysqld]
            ...
            log-slow-verbosity=query_plan,explain
            {noformat}

            The output is printed into slow query log like this:
            {noformat}
            # Time: 130920 9:38:04
            # User@Host: root[root] @ localhost []
            # Thread_id: 2 Schema: test QC_hit: No
            # Query_time: 0.002969 Lock_time: 0.000941 Rows_sent: 132 Rows_examined: 132
            # Full_scan: Yes Full_join: No Tmp_table: No Tmp_table_on_disk: No
            # Filesort: No Filesort_on_disk: No Merge_passes: 0
            #
            # id select_type table type possible_keys key key_len ref rows Extra
            # 1 SIMPLE t0 ALL NULL NULL NULL NULL 1000
            #
            use test;
            SET timestamp=1379655484;
            select * from t0 limit 132;
            {noformat}

            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            elenst Elena Stepanova made changes -
            psergei Sergei Petrunia made changes -
            Description SHOW EXPLAIN allows to produce EXPLAIN during the query execution. We are now able to save it in the slow query log.

            The user interface is as follows:

            "explain" is a new flag in log-slow-verbosity argument:

            {noformat}
            [mysqld]
            ...
            log-slow-verbosity=query_plan,explain
            {noformat}

            The output is printed into slow query log like this:
            {noformat}
            # Time: 130920 9:38:04
            # User@Host: root[root] @ localhost []
            # Thread_id: 2 Schema: test QC_hit: No
            # Query_time: 0.002969 Lock_time: 0.000941 Rows_sent: 132 Rows_examined: 132
            # Full_scan: Yes Full_join: No Tmp_table: No Tmp_table_on_disk: No
            # Filesort: No Filesort_on_disk: No Merge_passes: 0
            #
            # id select_type table type possible_keys key key_len ref rows Extra
            # 1 SIMPLE t0 ALL NULL NULL NULL NULL 1000
            #
            use test;
            SET timestamp=1379655484;
            select * from t0 limit 132;
            {noformat}

            SHOW EXPLAIN allows to produce EXPLAIN during the query execution. We are now able to save it in the slow query log.

            The user interface is as follows:

            "explain" is a new flag in log-slow-verbosity argument:

            {noformat}
            [mysqld]
            ...
            log-slow-verbosity=query_plan,explain
            {noformat}

            The output is printed into slow query log like this:
            {noformat}
            # User@Host: root[root] @ localhost []
            # Thread_id: 2 Schema: j4 QC_hit: No
            # Query_time: 0.000629 Lock_time: 0.000202 Rows_sent: 3 Rows_examined: 3
            # Full_scan: Yes Full_join: No Tmp_table: No Tmp_table_on_disk: No
            # Filesort: No Filesort_on_disk: No Merge_passes: 0
            ## <explain>
            ## id select_type table type possible_keys key key_len ref rows Extra
            ## 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
            ## </explain>
            SET timestamp=1381828772;
            select * from t1 where a between 1 and 3333;
            {noformat}
            psergei Sergei Petrunia made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow defaullt [ 12712 ] MariaDB v2 [ 44654 ]
            psergei Sergei Petrunia made changes -
            ratzpo Rasmus Johansson (Inactive) made changes -
            Workflow MariaDB v2 [ 44654 ] MariaDB v3 [ 64019 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 64019 ] MariaDB v4 [ 131953 ]

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.