[MDEV-7970] EXPLAIN FORMAT=JSON does not print HAVING Created: 2015-04-09  Updated: 2015-09-18  Resolved: 2015-09-18

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.1
Fix Version/s: 10.1.8

Type: Bug Priority: Major
Reporter: Sergei Petrunia Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: explain_json

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.



 Comments   
Comment by Sergei Petrunia [ 2015-04-09 ]

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
      }
    }
  }
}

Comment by Oleksandr Byelkin [ 2015-09-09 ]

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.

Comment by Oleksandr Byelkin [ 2015-09-15 ]

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.

Comment by Sergei Petrunia [ 2015-09-18 ]

Ok to push

Generated at Thu Feb 08 07:23:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.