github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/dbs/cmd/benchdb/explaintest/r/generated_columns.result (about) 1 set @@milevadb_partition_prune_mode='dynamic-only'; 2 DROP TABLE IF EXISTS person; 3 CREATE TABLE person ( 4 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 5 name VARCHAR(255) NOT NULL, 6 address_info JSON, 7 city VARCHAR(64) AS (JSON_UNQUOTE(JSON_EXTRACT(address_info, '$.city'))) STORED, 8 KEY (city) 9 ); 10 EXPLAIN SELECT name, id FROM person WHERE city = 'Beijing'; 11 id estRows task access object operator info 12 Projection_4 10.00 root test.person.name, test.person.id 13 └─IndexLookUp_10 10.00 root 14 ├─IndexRangeScan_8(Build) 10.00 cop[einsteindb] causet:person, index:city(city) range:["Beijing","Beijing"], keep order:false, stats:pseudo 15 └─TableRowIDScan_9(Probe) 10.00 cop[einsteindb] causet:person keep order:false, stats:pseudo 16 DROP TABLE IF EXISTS `sgc`; 17 CREATE TABLE `sgc` ( 18 `j1` JSON DEFAULT NULL, 19 `j2` JSON DEFAULT NULL, 20 `a` int(11) GENERATED ALWAYS AS (JSON_EXTRACT(`j1`, "$.a")) STORED, 21 `b` int(2) GENERATED ALWAYS AS (JSON_CONTAINS(j2, '1')) STORED, 22 KEY `idx_a` (`a`), 23 KEY `idx_b` (`b`), 24 KEY `idx_a_b` (`a`,`b`) 25 ); 26 EXPLAIN SELECT a FROM sgc where a < 3; 27 id estRows task access object operator info 28 IndexReader_6 3323.33 root index:IndexRangeScan_5 29 └─IndexRangeScan_5 3323.33 cop[einsteindb] causet:sgc, index:idx_a(a) range:[-inf,3), keep order:false, stats:pseudo 30 EXPLAIN SELECT a, b FROM sgc where a < 3; 31 id estRows task access object operator info 32 IndexReader_6 3323.33 root index:IndexRangeScan_5 33 └─IndexRangeScan_5 3323.33 cop[einsteindb] causet:sgc, index:idx_a_b(a, b) range:[-inf,3), keep order:false, stats:pseudo 34 EXPLAIN SELECT a, b from sgc where b < 3; 35 id estRows task access object operator info 36 IndexReader_13 3323.33 root index:Selection_12 37 └─Selection_12 3323.33 cop[einsteindb] lt(test.sgc.b, 3) 38 └─IndexFullScan_11 10000.00 cop[einsteindb] causet:sgc, index:idx_a_b(a, b) keep order:false, stats:pseudo 39 EXPLAIN SELECT a, b from sgc where a < 3 and b < 3; 40 id estRows task access object operator info 41 IndexReader_11 1104.45 root index:Selection_10 42 └─Selection_10 1104.45 cop[einsteindb] lt(test.sgc.b, 3) 43 └─IndexRangeScan_9 3323.33 cop[einsteindb] causet:sgc, index:idx_a_b(a, b) range:[-inf,3), keep order:false, stats:pseudo 44 DROP TABLE IF EXISTS sgc1, 45 sgc2; 46 CREATE TABLE `sgc1` ( 47 `j1` JSON, 48 `j2` JSON, 49 `a` INT AS (JSON_EXTRACT(j1, "$.a")) STORED, 50 `b` VARCHAR(20) AS (JSON_KEYS(j2)) STORED, 51 KEY `idx_a` (`a`), 52 KEY `idx_b` (`b`), 53 KEY `idx_a_b` (`a`, `b`) 54 ); 55 CREATE TABLE `sgc2` ( 56 `j1` JSON, 57 `j2` JSON, 58 `a` INT AS (JSON_EXTRACT(j1, "$.a")) STORED, 59 `b` VARCHAR(20) AS (JSON_KEYS(j2)) STORED, 60 KEY `idx_a` (`a`), 61 KEY `idx_b` (`b`), 62 KEY `idx_a_b` (`a`, `b`) 63 ); 64 INSERT INTO sgc1(j1, j2) 65 VALUES ('{"a": 1}', '{"1": "1"}'), 66 ('{"a": 1}', '{"1": "1"}'), 67 ('{"a": 1}', '{"1": "1"}'), 68 ('{"a": 1}', '{"1": "1"}'), 69 ('{"a": 1}', '{"1": "1"}'); 70 INSERT INTO sgc2(j1, j2) 71 VALUES ('{"a": 1}', '{"1": "1"}'); 72 ANALYZE TABLE sgc1, sgc2; 73 EXPLAIN SELECT /*+ MilevaDB_INLJ(sgc1, sgc2) */ * from sgc1 join sgc2 on sgc1.a=sgc2.a; 74 id estRows task access object operator info 75 IndexJoin_26 5.00 root inner join, inner:IndexLookUp_25, outer key:test.sgc2.a, inner key:test.sgc1.a 76 ├─TableReader_47(Build) 1.00 root data:Selection_46 77 │ └─Selection_46 1.00 cop[einsteindb] not(isnull(test.sgc2.a)) 78 │ └─TableFullScan_45 1.00 cop[einsteindb] causet:sgc2 keep order:false 79 └─IndexLookUp_25(Probe) 5.00 root 80 ├─Selection_24(Build) 5.00 cop[einsteindb] not(isnull(test.sgc1.a)) 81 │ └─IndexRangeScan_22 5.00 cop[einsteindb] causet:sgc1, index:idx_a(a) range: decided by [eq(test.sgc1.a, test.sgc2.a)], keep order:false 82 └─TableRowIDScan_23(Probe) 5.00 cop[einsteindb] causet:sgc1 keep order:false 83 EXPLAIN SELECT * from sgc1 join sgc2 on sgc1.a=sgc2.a; 84 id estRows task access object operator info 85 Projection_6 5.00 root test.sgc1.j1, test.sgc1.j2, test.sgc1.a, test.sgc1.b, test.sgc2.j1, test.sgc2.j2, test.sgc2.a, test.sgc2.b 86 └─HashJoin_38 5.00 root inner join, equal:[eq(test.sgc2.a, test.sgc1.a)] 87 ├─TableReader_57(Build) 1.00 root data:Selection_56 88 │ └─Selection_56 1.00 cop[einsteindb] not(isnull(test.sgc2.a)) 89 │ └─TableFullScan_55 1.00 cop[einsteindb] causet:sgc2 keep order:false 90 └─TableReader_66(Probe) 5.00 root data:Selection_65 91 └─Selection_65 5.00 cop[einsteindb] not(isnull(test.sgc1.a)) 92 └─TableFullScan_64 5.00 cop[einsteindb] causet:sgc1 keep order:false 93 DROP TABLE IF EXISTS sgc3; 94 CREATE TABLE sgc3 ( 95 j JSON, 96 a INT AS (JSON_EXTRACT(j, "$.a")) STORED 97 ) 98 PARTITION BY RANGE (a) ( 99 PARTITION p0 VALUES LESS THAN (1), 100 PARTITION p1 VALUES LESS THAN (2), 101 PARTITION p2 VALUES LESS THAN (3), 102 PARTITION p3 VALUES LESS THAN (4), 103 PARTITION p4 VALUES LESS THAN (5), 104 PARTITION p5 VALUES LESS THAN (6), 105 PARTITION max VALUES LESS THAN MAXVALUE); 106 EXPLAIN SELECT * FROM sgc3 WHERE a <= 1; 107 id estRows task access object operator info 108 TableReader_7 3323.33 root partition:p0,p1 data:Selection_6 109 └─Selection_6 3323.33 cop[einsteindb] le(test.sgc3.a, 1) 110 └─TableFullScan_5 10000.00 cop[einsteindb] causet:sgc3 keep order:false, stats:pseudo 111 EXPLAIN SELECT * FROM sgc3 WHERE a < 7; 112 id estRows task access object operator info 113 TableReader_7 3323.33 root partition:all data:Selection_6 114 └─Selection_6 3323.33 cop[einsteindb] lt(test.sgc3.a, 7) 115 └─TableFullScan_5 10000.00 cop[einsteindb] causet:sgc3 keep order:false, stats:pseudo 116 DROP TABLE IF EXISTS t1; 117 CREATE TABLE t1(a INT, b INT AS (a+1) VIRTUAL, c INT AS (b+1) VIRTUAL, d INT AS (c+1) VIRTUAL, KEY(b), INDEX IDX(c, d)); 118 INSERT INTO t1 (a) VALUES (0); 119 EXPLAIN SELECT b FROM t1 WHERE b=1; 120 id estRows task access object operator info 121 IndexReader_6 10.00 root index:IndexRangeScan_5 122 └─IndexRangeScan_5 10.00 cop[einsteindb] causet:t1, index:b(b) range:[1,1], keep order:false, stats:pseudo 123 EXPLAIN SELECT b, c, d FROM t1 WHERE b=1; 124 id estRows task access object operator info 125 Projection_4 10.00 root test.t1.b, test.t1.c, test.t1.d 126 └─IndexLookUp_10 10.00 root 127 ├─IndexRangeScan_8(Build) 10.00 cop[einsteindb] causet:t1, index:b(b) range:[1,1], keep order:false, stats:pseudo 128 └─TableRowIDScan_9(Probe) 10.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 129 EXPLAIN SELECT * FROM t1 WHERE b=1; 130 id estRows task access object operator info 131 IndexLookUp_10 10.00 root 132 ├─IndexRangeScan_8(Build) 10.00 cop[einsteindb] causet:t1, index:b(b) range:[1,1], keep order:false, stats:pseudo 133 └─TableRowIDScan_9(Probe) 10.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 134 EXPLAIN SELECT c FROM t1 WHERE c=2 AND d=3; 135 id estRows task access object operator info 136 Projection_4 0.10 root test.t1.c 137 └─IndexReader_6 0.10 root index:IndexRangeScan_5 138 └─IndexRangeScan_5 0.10 cop[einsteindb] causet:t1, index:IDX(c, d) range:[2 3,2 3], keep order:false, stats:pseudo 139 DROP TABLE IF EXISTS person; 140 CREATE TABLE person ( 141 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 142 name VARCHAR(255) NOT NULL, 143 address_info JSON, 144 city_no INT AS (JSON_EXTRACT(address_info, '$.city_no')) VIRTUAL, 145 KEY(city_no)); 146 INSERT INTO person (name, address_info) VALUES ("John", CAST('{"city_no": 1}' AS JSON)); 147 EXPLAIN SELECT name FROM person where city_no=1; 148 id estRows task access object operator info 149 Projection_4 10.00 root test.person.name 150 └─IndexLookUp_10 10.00 root 151 ├─IndexRangeScan_8(Build) 10.00 cop[einsteindb] causet:person, index:city_no(city_no) range:[1,1], keep order:false, stats:pseudo 152 └─TableRowIDScan_9(Probe) 10.00 cop[einsteindb] causet:person keep order:false, stats:pseudo 153 DROP TABLE IF EXISTS t1; 154 CREATE TABLE t1 (a INT, 155 b INT GENERATED ALWAYS AS (-a) VIRTUAL, 156 c INT GENERATED ALWAYS AS (-a) STORED, 157 index (c)); 158 INSERT INTO t1 (a) VALUES (2), (1), (1), (3), (NULL); 159 EXPLAIN SELECT sum(a) FROM t1 GROUP BY b; 160 id estRows task access object operator info 161 HashAgg_5 8000.00 root group by:DeferredCauset#7, funcs:sum(DeferredCauset#6)->DeferredCauset#5 162 └─Projection_12 10000.00 root cast(test.t1.a, decimal(65,0) BINARY)->DeferredCauset#6, test.t1.b 163 └─TableReader_9 10000.00 root data:TableFullScan_8 164 └─TableFullScan_8 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 165 EXPLAIN SELECT sum(a) FROM t1 GROUP BY c; 166 id estRows task access object operator info 167 HashAgg_11 8000.00 root group by:test.t1.c, funcs:sum(DeferredCauset#6)->DeferredCauset#5 168 └─TableReader_12 8000.00 root data:HashAgg_5 169 └─HashAgg_5 8000.00 cop[einsteindb] group by:test.t1.c, funcs:sum(test.t1.a)->DeferredCauset#6 170 └─TableFullScan_10 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 171 EXPLAIN SELECT sum(b) FROM t1 GROUP BY a; 172 id estRows task access object operator info 173 HashAgg_5 8000.00 root group by:DeferredCauset#7, funcs:sum(DeferredCauset#6)->DeferredCauset#5 174 └─Projection_12 10000.00 root cast(test.t1.b, decimal(65,0) BINARY)->DeferredCauset#6, test.t1.a 175 └─TableReader_9 10000.00 root data:TableFullScan_8 176 └─TableFullScan_8 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 177 EXPLAIN SELECT sum(b) FROM t1 GROUP BY c; 178 id estRows task access object operator info 179 HashAgg_5 8000.00 root group by:DeferredCauset#9, funcs:sum(DeferredCauset#8)->DeferredCauset#5 180 └─Projection_18 10000.00 root cast(test.t1.b, decimal(65,0) BINARY)->DeferredCauset#8, test.t1.c 181 └─TableReader_11 10000.00 root data:TableFullScan_10 182 └─TableFullScan_10 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 183 EXPLAIN SELECT sum(c) FROM t1 GROUP BY a; 184 id estRows task access object operator info 185 HashAgg_9 8000.00 root group by:test.t1.a, funcs:sum(DeferredCauset#6)->DeferredCauset#5 186 └─TableReader_10 8000.00 root data:HashAgg_5 187 └─HashAgg_5 8000.00 cop[einsteindb] group by:test.t1.a, funcs:sum(test.t1.c)->DeferredCauset#6 188 └─TableFullScan_8 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 189 EXPLAIN SELECT sum(c) FROM t1 GROUP BY b; 190 id estRows task access object operator info 191 HashAgg_5 8000.00 root group by:DeferredCauset#7, funcs:sum(DeferredCauset#6)->DeferredCauset#5 192 └─Projection_12 10000.00 root cast(test.t1.c, decimal(65,0) BINARY)->DeferredCauset#6, test.t1.b 193 └─TableReader_9 10000.00 root data:TableFullScan_8 194 └─TableFullScan_8 10000.00 cop[einsteindb] causet:t1 keep order:false, stats:pseudo 195 DROP TABLE IF EXISTS tu; 196 CREATE TABLE tu (a INT, b INT, c INT GENERATED ALWAYS AS (a + b) VIRTUAL, primary key (a), unique key uk(c)); 197 INSERT INTO tu(a, b) VALUES(1, 2); 198 EXPLAIN SELECT * FROM tu WHERE c = 1; 199 id estRows task access object operator info 200 Point_Get_5 1.00 root causet:tu, index:uk(c) 201 EXPLAIN SELECT a, c FROM tu WHERE c = 1; 202 id estRows task access object operator info 203 Projection_4 1.00 root test.tu.a, test.tu.c 204 └─Point_Get_5 1.00 root causet:tu, index:uk(c) 205 EXPLAIN SELECT * FROM tu WHERE c in(1, 2, 3); 206 id estRows task access object operator info 207 Batch_Point_Get_5 3.00 root causet:tu, index:uk(c) keep order:false, desc:false 208 EXPLAIN SELECT c, a FROM tu WHERE c in(1, 2, 3); 209 id estRows task access object operator info 210 Projection_4 3.00 root test.tu.c, test.tu.a 211 └─Batch_Point_Get_5 3.00 root causet:tu, index:uk(c) keep order:false, desc:false