Skip to content

Commit

Permalink
use format = 'brief'
Browse files Browse the repository at this point in the history
Signed-off-by: xiongjiwei <[email protected]>
  • Loading branch information
xiongjiwei committed Sep 14, 2022
1 parent 14078df commit 0f5365f
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 25 deletions.
92 changes: 72 additions & 20 deletions cmd/explaintest/r/explain_generate_column_substitute.result
Original file line number Diff line number Diff line change
Expand Up @@ -645,32 +645,84 @@ drop table t2;
set @@tidb_enable_unsafe_substitute=1;
CREATE TABLE person (id INT PRIMARY KEY,address_info JSON,city VARCHAR(2) AS (JSON_UNQUOTE(address_info->"$.city")),KEY (city));
INSERT INTO `person` (`id`, `address_info`) VALUES('1','{\"city\": \"Beijing\"}');
desc SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id estRows task access object operator info
Projection_4 8000.00 root test.person.id
└─TableReader_7 8000.00 root data:Selection_6
└─Selection_6 8000.00 cop[tikv] eq(json_unquote(cast(json_extract(test.person.address_info, "$.city"), var_string(16777216))), "Beijing")
└─TableFullScan_5 10000.00 cop[tikv] table:person keep order:false, stats:pseudo
desc SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id estRows task access object operator info
Projection_4 10.00 root test.person.id
└─IndexReader_6 10.00 root index:IndexRangeScan_5
└─IndexRangeScan_5 10.00 cop[tikv] table:person, index:city(city) range:["Beijing","Beijing"], keep order:false, stats:pseudo
SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id
1
desc format = 'brief' SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id estRows task access object operator info
Projection 8000.00 root test.person.id
└─TableReader 8000.00 root data:Selection
└─Selection 8000.00 cop[tikv] eq(json_unquote(cast(json_extract(test.person.address_info, "$.city"), var_string(16777216))), "Beijing")
└─TableFullScan 10000.00 cop[tikv] table:person keep order:false, stats:pseudo
SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id
desc format = 'brief' SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id estRows task access object operator info
Projection 10.00 root test.person.id
└─IndexReader 10.00 root index:IndexRangeScan
└─IndexRangeScan 10.00 cop[tikv] table:person, index:city(city) range:["Beijing","Beijing"], keep order:false, stats:pseudo
drop table person;
create table t(a char(5), b char(6) as (concat(a, a)), index bx(b));
insert into t(a) values ('aaaaa');
select * from t;
a b
aaaaa aaaaaa
desc select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
a b
aaaaa aaaaaa
desc format = 'brief' select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
id estRows task access object operator info
TableReader_7 8000.00 root data:Selection_6
└─Selection_6 8000.00 cop[tikv] eq(concat(test.t.a, test.t.a), "aaaaaaaaaa")
└─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
desc select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
TableReader 8000.00 root data:Selection
└─Selection 8000.00 cop[tikv] eq(concat(test.t.a, test.t.a), "aaaaaaaaaa")
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
a b
desc format = 'brief' select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
id estRows task access object operator info
IndexLookUp_7 10.00 root
├─IndexRangeScan_5(Build) 10.00 cop[tikv] table:t, index:bx(b) range:["aaaaaaaaaa","aaaaaaaaaa"], keep order:false, stats:pseudo
└─TableRowIDScan_6(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo
set @@tidb_enable_unsafe_substitute=0;
IndexLookUp 10.00 root
├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:bx(b) range:["aaaaaaaaaa","aaaaaaaaaa"], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo
drop table t;
CREATE TABLE person (id INT PRIMARY KEY,address_info JSON,city VARCHAR(64) AS (JSON_UNQUOTE(address_info->"$.city")),KEY (city));
INSERT INTO `person` (`id`, `address_info`) VALUES('1','{\"city\": \"Beijing\"}');
SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id
1
desc format = 'brief' SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id estRows task access object operator info
Projection 8000.00 root test.person.id
└─TableReader 8000.00 root data:Selection
└─Selection 8000.00 cop[tikv] eq(json_unquote(cast(json_extract(test.person.address_info, "$.city"), var_string(16777216))), "Beijing")
└─TableFullScan 10000.00 cop[tikv] table:person keep order:false, stats:pseudo
SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id
1
desc format = 'brief' SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
id estRows task access object operator info
Projection 10.00 root test.person.id
└─IndexReader 10.00 root index:IndexRangeScan
└─IndexRangeScan 10.00 cop[tikv] table:person, index:city(city) range:["Beijing","Beijing"], keep order:false, stats:pseudo
drop table person;
create table t(a char(5), b char(10) as (concat(a, a)), index bx(b));
insert into t(a) values ('aaaaa');
select * from t;
a b
aaaaa aaaaaaaaaa
select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
a b
aaaaa aaaaaaaaaa
desc format = 'brief' select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
id estRows task access object operator info
TableReader 8000.00 root data:Selection
└─Selection 8000.00 cop[tikv] eq(concat(test.t.a, test.t.a), "aaaaaaaaaa")
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
a b
aaaaa aaaaaaaaaa
desc format = 'brief' select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
id estRows task access object operator info
IndexLookUp 10.00 root
├─IndexRangeScan(Build) 10.00 cop[tikv] table:t, index:bx(b) range:["aaaaaaaaaa","aaaaaaaaaa"], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 10.00 cop[tikv] table:t keep order:false, stats:pseudo
drop table t;
set @@tidb_enable_unsafe_substitute=0;
32 changes: 27 additions & 5 deletions cmd/explaintest/t/explain_generate_column_substitute.test
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,36 @@ drop table t2;
set @@tidb_enable_unsafe_substitute=1;
CREATE TABLE person (id INT PRIMARY KEY,address_info JSON,city VARCHAR(2) AS (JSON_UNQUOTE(address_info->"$.city")),KEY (city));
INSERT INTO `person` (`id`, `address_info`) VALUES('1','{\"city\": \"Beijing\"}');
desc SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
desc SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
desc format = 'brief' SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
desc format = 'brief' SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
drop table person;

create table t(a char(5), b char(6) as (concat(a, a)), index bx(b));
insert into t(a) values ('aaaaa');
select * from t;
desc select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
desc select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
set @@tidb_enable_unsafe_substitute=0;
select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
desc format = 'brief' select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
desc format = 'brief' select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
drop table t;

CREATE TABLE person (id INT PRIMARY KEY,address_info JSON,city VARCHAR(64) AS (JSON_UNQUOTE(address_info->"$.city")),KEY (city));
INSERT INTO `person` (`id`, `address_info`) VALUES('1','{\"city\": \"Beijing\"}');
SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
desc format = 'brief' SELECT id FROM person ignore index(`city`) WHERE address_info->>"$.city" = 'Beijing';
SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
desc format = 'brief' SELECT id FROM person force index(`city`) WHERE address_info->>"$.city" = 'Beijing';
drop table person;

create table t(a char(5), b char(10) as (concat(a, a)), index bx(b));
insert into t(a) values ('aaaaa');
select * from t;
select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
desc format = 'brief' select * from t ignore index(bx) where concat(a, a) = 'aaaaaaaaaa';
select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
desc format = 'brief' select * from t force index(bx) where concat(a, a) = 'aaaaaaaaaa';
drop table t;
set @@tidb_enable_unsafe_substitute=0;

0 comments on commit 0f5365f

Please sign in to comment.