From 0f5365fc2105180b323fd37cebf6e51d1ff2f2a4 Mon Sep 17 00:00:00 2001 From: xiongjiwei Date: Wed, 14 Sep 2022 10:39:21 +0800 Subject: [PATCH] use format = 'brief' Signed-off-by: xiongjiwei --- .../explain_generate_column_substitute.result | 92 +++++++++++++++---- .../t/explain_generate_column_substitute.test | 32 ++++++- 2 files changed, 99 insertions(+), 25 deletions(-) diff --git a/cmd/explaintest/r/explain_generate_column_substitute.result b/cmd/explaintest/r/explain_generate_column_substitute.result index f8cee4f74831b..161b92c800e55 100644 --- a/cmd/explaintest/r/explain_generate_column_substitute.result +++ b/cmd/explaintest/r/explain_generate_column_substitute.result @@ -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; diff --git a/cmd/explaintest/t/explain_generate_column_substitute.test b/cmd/explaintest/t/explain_generate_column_substitute.test index a1d92ce82c455..527e404c9d17b 100644 --- a/cmd/explaintest/t/explain_generate_column_substitute.test +++ b/cmd/explaintest/t/explain_generate_column_substitute.test @@ -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; +