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

EXPLAIN FORMAT=JSON does not print HAVING

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.1
    • Fix Version/s: 10.1.8
    • Component/s: Optimizer
    • Labels:
    • Sprint:
      10.1.6-2, 10.1.7-1, 10.1.8-1, 10.1.8-2

      Description

      EXPLAIN FORMAT=JSON does not print HAVING.

      Testcase (not necessarily minimal):

      create table t0(a int);
      insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
      create table t1(a int);
      insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
      create table t2 (
        a int, 
        b int, 
        key (a)
      );
      insert into t2 select A.a*1000 + B.a, A.a*1000 + B.a from t0 A, t1 B;
      

      Now, the test query:

      explain format=json select a, max(b) as TOP from t2 group by a having TOP > a\G
      *************************** 1. row ***************************
      EXPLAIN: {
        "query_block": {
          "select_id": 1,
          "table": {
            "table_name": "t2",
            "access_type": "index",
            "key": "a",
            "key_length": "5",
            "used_key_parts": ["a"],
            "rows": 10443,
            "filtered": 100
          }
        }
      }
      

      HAVING is not printed. GROUP BY is not printed, either, but it's a topic of another issue.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            psergey Sergei Petrunia added a comment -

            MySQL 5.6 doesn't print it either:

            MySQL [j5]> explain format=json select a, max(b) as TOP from t2 group by a having TOP > a\G
            *************************** 1. row ***************************
            EXPLAIN: {
              "query_block": {
                "select_id": 1,
                "grouping_operation": {
                  "using_filesort": false,
                  "table": {
                    "table_name": "t2",
                    "access_type": "index",
                    "possible_keys": [
                      "a"
                    ],
                    "key": "a",
                    "used_key_parts": [
                      "a"
                    ],
                    "key_length": "5",
                    "rows": 10157,
                    "filtered": 100
                  }
                }
              }
            }
            
            Show
            psergey Sergei Petrunia added a comment - MySQL 5.6 doesn't print it either: MySQL [j5]> explain format=json select a, max(b) as TOP from t2 group by a having TOP > a\G *************************** 1. row *************************** EXPLAIN: { "query_block": { "select_id": 1, "grouping_operation": { "using_filesort": false, "table": { "table_name": "t2", "access_type": "index", "possible_keys": [ "a" ], "key": "a", "used_key_parts": [ "a" ], "key_length": "5", "rows": 10157, "filtered": 100 } } } }
            Hide
            sanja Oleksandr Byelkin added a comment -

            revision-id: 8983790df9a16520e69905fc4c35d20f7c935c3e (mariadb-10.1.6-119-g8983790)
            parent(s): 3fcd84c2891f4d2c881f13b53bc5a2401870b80a
            committer: Oleksandr Byelkin
            timestamp: 2015-09-09 16:29:50 +0200
            message:

            MDEV-7970: EXPLAIN FORMAT=JSON does not print HAVING

            Printing non-trivial HAVING added.

            Show
            sanja Oleksandr Byelkin added a comment - revision-id: 8983790df9a16520e69905fc4c35d20f7c935c3e (mariadb-10.1.6-119-g8983790) parent(s): 3fcd84c2891f4d2c881f13b53bc5a2401870b80a committer: Oleksandr Byelkin timestamp: 2015-09-09 16:29:50 +0200 message: MDEV-7970 : EXPLAIN FORMAT=JSON does not print HAVING Printing non-trivial HAVING added. —
            Hide
            sanja Oleksandr Byelkin added a comment -

            revision-id: 848cc7097f99b675b9b05878efd63c6fb125f138 (mariadb-10.1.7-2-g848cc70)
            parent(s): 3fcd84c2891f4d2c881f13b53bc5a2401870b80a
            committer: Oleksandr Byelkin
            timestamp: 2015-09-15 12:13:14 +0200
            message:

            MDEV-7970: EXPLAIN FORMAT=JSON does not print HAVING

            Printing non-trivial HAVING added.

            Show
            sanja Oleksandr Byelkin added a comment - revision-id: 848cc7097f99b675b9b05878efd63c6fb125f138 (mariadb-10.1.7-2-g848cc70) parent(s): 3fcd84c2891f4d2c881f13b53bc5a2401870b80a committer: Oleksandr Byelkin timestamp: 2015-09-15 12:13:14 +0200 message: MDEV-7970 : EXPLAIN FORMAT=JSON does not print HAVING Printing non-trivial HAVING added. —
            Hide
            psergey Sergei Petrunia added a comment -

            Ok to push

            Show
            psergey Sergei Petrunia added a comment - Ok to push

              People

              • Assignee:
                sanja Oleksandr Byelkin
                Reporter:
                psergey Sergei Petrunia
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Agile