[MDEV-7856] EXPLAIN FORMAT=JSON should show partitions Created: 2015-03-27  Updated: 2015-04-09  Resolved: 2015-04-09

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

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


 Description   

EXPLAIN FORMAT=JSON (and ANALYZE FORMAT=JSON too) do not show used partitions.

create table ten(a int);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t10 (
  a int not null
) partition by key(a);
insert into t10 select a from ten;
explain partitions select * from t10 where a in (2,3,4);

EXPLAIN PARTITIONS shows:

MariaDB [j2]> explain partitions select * from t10 where a in (2,3,4);
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
| id   | select_type | table | partitions | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | t10   | p0         | ALL  | NULL          | NULL | NULL    | NULL |   10 | Using where |
+------+-------------+-------+------------+------+---------------+------+---------+------+------+-------------+

EXPLAIN FORMAT=JSON doesn't show partitions:

MariaDB [j2]> explain format=json select * from t10 where a in (2,3,4)\G
*************************** 1. row ***************************
EXPLAIN: {
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "t10",
      "access_type": "ALL",
      "rows": 10,
      "filtered": 100,
      "attached_condition": "(t10.a in (2,3,4))"
    }
  }
}

For comparison, MySQL 5.6 shows:

MySQL [test]> explain format=json select * from t10 where a in (2,3,4)\G
*************************** 1. row ***************************
EXPLAIN: {
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "t10",
      "partitions": [
        "p0"
      ],
      "access_type": "ALL",
      "rows": 10,
      "filtered": 100,
      "attached_condition": "(`test`.`t10`.`a` in (2,3,4))"
    }
  }
}



 Comments   
Comment by Sergei Petrunia [ 2015-03-27 ]

This should be fixed in the same way as it is solved for "possible_keys". The idea of that solution is that we save enough data so that we don't rely on table being when we're printing the JSON output.

Comment by Oleksandr Byelkin [ 2015-04-08 ]

revision-id: c081073446c943f043d4bd6fa7d8e7785dd1d74f
parent(s): 0df8c0aa5ed1a6d3869783a30cbe71521cffa4e4
committer: Oleksandr Byelkin
branch nick: server
timestamp: 2015-04-08 10:13:36 +0200
message:

MDEV-7856: EXPLAIN FORMAT=JSON should show partitions

Comment by Sergei Petrunia [ 2015-04-08 ]

Review feedback provided over email. This needs fixes.

Comment by Oleksandr Byelkin [ 2015-04-09 ]

revision-id: 86a2a1f8675bcfa09a974dc63aed8f68866c07a8
parent(s): 0df8c0aa5ed1a6d3869783a30cbe71521cffa4e4
committer: Oleksandr Byelkin
branch nick: server
timestamp: 2015-04-09 11:15:01 +0200
message:

MDEV-7856: EXPLAIN FORMAT=JSON should show partitions

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