1set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off'; 2set optimizer_trace_max_mem_size=1048576; 3SET end_markers_in_json=on; 4SET optimizer_trace="enabled=on,one_line=off"; 5# 6# BUG#12430646 - SEL_ARG::LEFT AND RIGHT POINTERS INCORRECTLY 7# USED. CRASHES OPTIMIZER TRACING 8# 9CREATE TABLE t1 ( 10a INT, 11b CHAR(2), 12c INT, 13d INT, 14KEY (c), 15KEY (d,a,b(2)), 16KEY (b(1)) 17); 18INSERT INTO t1 VALUES (NULL, 'a', 1, 2), (NULL, 'a', 1, 2), 19(1, 'a', 1, 2), (1, 'a', 1, 2); 20CREATE TABLE t2 ( 21a INT, 22c INT, 23e INT, 24KEY (e) 25); 26INSERT INTO t2 VALUES (1, 1, NULL), (1, 1, NULL); 27SELECT 1 28FROM t1, t2 29WHERE t1.d <> '1' AND t1.b > '1' 30AND t1.a = t2.a AND t1.c = t2.c; 311 321 331 341 351 36DROP TABLE t1, t2; 37# 38# BUG#12595210 - JSON SYNTAX ERROR ASSERT ON WHERE FIELD NOT IN SUBQUERY 39# 40CREATE TABLE t1 ( 41pk INT NOT NULL AUTO_INCREMENT, 42col_int_key INT DEFAULT NULL, 43col_varchar_key VARCHAR(1) DEFAULT NULL, 44PRIMARY KEY (pk) 45) ENGINE=InnoDB; 46CREATE TABLE t2 ( 47pk INT NOT NULL AUTO_INCREMENT, 48col_int_key INT DEFAULT NULL, 49col_varchar_key VARCHAR(1) DEFAULT NULL, 50col_varchar_nokey VARCHAR(1) DEFAULT NULL, 51PRIMARY KEY (pk) 52) ENGINE=InnoDB; 53CREATE TABLE t3 ( 54pk INT NOT NULL AUTO_INCREMENT, 55col_int_key INT DEFAULT NULL, 56col_varchar_key VARCHAR(1) DEFAULT NULL, 57col_varchar_nokey VARCHAR(1) DEFAULT NULL, 58PRIMARY KEY (pk) 59) ENGINE=InnoDB; 60CREATE TABLE t4 ( 61pk INT NOT NULL AUTO_INCREMENT, 62col_int_key INT DEFAULT NULL, 63col_varchar_key VARCHAR(1) DEFAULT NULL, 64PRIMARY KEY (pk) 65) ENGINE=InnoDB; 66CREATE VIEW view_t4 AS SELECT * FROM t4; 67CREATE TABLE where_subselect_19379 SELECT 68( 69SELECT SUM(sq1_alias1.pk) AS sq1_field1 70FROM view_t4 AS sq1_alias1 71INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = 72sq1_alias1.col_varchar_key ) 73) AS field1, 74alias1.col_varchar_nokey AS field2 75FROM (t2 AS alias1 76LEFT JOIN ( t2 AS alias2 77LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = 78alias2.col_varchar_key ) 79) ON (alias3.col_varchar_key = alias2.col_varchar_key) 80) 81WHERE ( alias2.col_varchar_key IN ( 82SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 83FROM t3 AS sq2_alias1 84WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key 85) 86); 87SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN 88(SELECT 89( 90SELECT SUM(sq1_alias1.pk) AS sq1_field1 91FROM view_t4 AS sq1_alias1 92INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = 93sq1_alias1.col_varchar_key ) 94) AS field1, 95alias1.col_varchar_nokey AS field2 96FROM (t2 AS alias1 97LEFT JOIN ( t2 AS alias2 98LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = 99alias2.col_varchar_key ) 100) ON (alias3.col_varchar_key = alias2.col_varchar_key) 101) 102WHERE ( alias2.col_varchar_key IN ( 103SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 104FROM t3 AS sq2_alias1 105WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key 106) 107)); 108field1 field2 109select * from information_schema.OPTIMIZER_TRACE; 110QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES 111SELECT * FROM where_subselect_19379 WHERE (field1, field2) NOT IN 112(SELECT 113( 114SELECT SUM(sq1_alias1.pk) AS sq1_field1 115FROM view_t4 AS sq1_alias1 116INNER JOIN t1 AS sq1_alias2 ON (sq1_alias2.col_varchar_key = 117sq1_alias1.col_varchar_key ) 118) AS field1, 119alias1.col_varchar_nokey AS field2 120FROM (t2 AS alias1 121LEFT JOIN ( t2 AS alias2 122LEFT OUTER JOIN t2 AS alias3 ON (alias3.col_varchar_nokey = 123alias2.col_varchar_key ) 124) ON (alias3.col_varchar_key = alias2.col_varchar_key) 125) 126WHERE ( alias2.col_varchar_key IN ( 127SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 128FROM t3 AS sq2_alias1 129WHERE sq2_alias1.col_varchar_nokey <= alias1.col_varchar_key 130) 131)) { 132 "steps": [ 133 { 134 "join_preparation": { 135 "select#": 1, 136 "steps": [ 137 { 138 "join_preparation": { 139 "select#": 2, 140 "steps": [ 141 { 142 "join_preparation": { 143 "select#": 3, 144 "steps": [ 145 { 146 "join_preparation": { 147 "select#": 5, 148 "steps": [ 149 { 150 "expanded_query": "/* select#5 */ select `t4`.`pk` AS `pk`,`t4`.`col_int_key` AS `col_int_key`,`t4`.`col_varchar_key` AS `col_varchar_key` from `t4`" 151 } 152 ] /* steps */ 153 } /* join_preparation */ 154 }, 155 { 156 "view": { 157 "table": "`view_t4` `sq1_alias1`", 158 "select#": 5, 159 "merged": true 160 } /* view */ 161 }, 162 { 163 "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))" 164 } 165 ] /* steps */ 166 } /* join_preparation */ 167 }, 168 { 169 "join_preparation": { 170 "select#": 4, 171 "steps": [ 172 { 173 "expanded_query": "/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`)" 174 }, 175 { 176 "transformation": { 177 "select#": 4, 178 "from": "IN (SELECT)", 179 "to": "semijoin", 180 "chosen": true 181 } /* transformation */ 182 } 183 ] /* steps */ 184 } /* join_preparation */ 185 }, 186 { 187 "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) where `alias2`.`col_varchar_key` in (/* select#4 */ select `sq2_alias1`.`col_varchar_nokey` AS `sq2_field1` from `t3` `sq2_alias1` where (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`))" 188 }, 189 { 190 "transformation": { 191 "select#": 2, 192 "from": "IN (SELECT)", 193 "to": "semijoin", 194 "chosen": false 195 } /* transformation */ 196 }, 197 { 198 "transformation": { 199 "select#": 2, 200 "from": "IN (SELECT)", 201 "to": "EXISTS (CORRELATED SELECT)", 202 "chosen": true, 203 "evaluating_constant_where_conditions": [ 204 ] /* evaluating_constant_where_conditions */, 205 "evaluating_constant_having_conditions": [ 206 ] /* evaluating_constant_having_conditions */ 207 } /* transformation */ 208 }, 209 { 210 "transformation": { 211 "select#": 4, 212 "from": "IN (SELECT)", 213 "to": "semijoin", 214 "chosen": true, 215 "evaluating_constant_semijoin_conditions": [ 216 ] /* evaluating_constant_semijoin_conditions */ 217 } /* transformation */ 218 } 219 ] /* steps */ 220 } /* join_preparation */ 221 }, 222 { 223 "expanded_query": "/* select#1 */ select `where_subselect_19379`.`field1` AS `field1`,`where_subselect_19379`.`field2` AS `field2` from `where_subselect_19379` where (not(<in_optimizer>((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),<exists>(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from (`t2` `alias1` left join (`t2` `alias2` left join `t2` `alias3` on((`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))) on((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`))) semi join (`t3` `sq2_alias1`) where (1 and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))))), true) and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`)) having (<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from ((`t4`) join `t1` `sq1_alias2` on((`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))))))" 224 }, 225 { 226 "transformations_to_nested_joins": { 227 "transformations": [ 228 "JOIN_condition_to_WHERE", 229 "parenthesis_removal" 230 ] /* transformations */, 231 "expanded_query": "/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)" 232 } /* transformations_to_nested_joins */ 233 }, 234 { 235 "transformations_to_nested_joins": { 236 "transformations": [ 237 "semijoin", 238 "outer_join_to_inner_join", 239 "JOIN_condition_to_WHERE", 240 "parenthesis_removal" 241 ] /* transformations */, 242 "expanded_query": "/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` semi join (`t3` `sq2_alias1`) join `t2` `alias2` join `t2` `alias3` where (1 and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having (<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))" 243 } /* transformations_to_nested_joins */ 244 } 245 ] /* steps */ 246 } /* join_preparation */ 247 }, 248 { 249 "join_optimization": { 250 "select#": 1, 251 "steps": [ 252 { 253 "condition_processing": { 254 "condition": "WHERE", 255 "original_condition": "(not(<in_optimizer>((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),<exists>(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` semi join (`t3` `sq2_alias1`) join `t2` `alias2` join `t2` `alias3` where (1 and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having (<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))))))", 256 "steps": [ 257 { 258 "transformation": "equality_propagation", 259 "subselect_evaluation": [ 260 ] /* subselect_evaluation */, 261 "resulting_condition": "(not(<in_optimizer>((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),<exists>(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` semi join (`t3` `sq2_alias1`) join `t2` `alias2` join `t2` `alias3` where (1 and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having (<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))))))" 262 }, 263 { 264 "transformation": "constant_propagation", 265 "subselect_evaluation": [ 266 ] /* subselect_evaluation */, 267 "resulting_condition": "(not(<in_optimizer>((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),<exists>(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` semi join (`t3` `sq2_alias1`) join `t2` `alias2` join `t2` `alias3` where (1 and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having (<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))))))" 268 }, 269 { 270 "transformation": "trivial_condition_removal", 271 "subselect_evaluation": [ 272 ] /* subselect_evaluation */, 273 "resulting_condition": "(not(<in_optimizer>((`where_subselect_19379`.`field1`,`where_subselect_19379`.`field2`),<exists>(/* select#2 */ select (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)) AS `field1`,`alias1`.`col_varchar_nokey` AS `field2` from `t2` `alias1` semi join (`t3` `sq2_alias1`) join `t2` `alias2` join `t2` `alias3` where (1 and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field1`) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(`where_subselect_19379`.`field2`) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)) having (<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))))))" 274 } 275 ] /* steps */ 276 } /* condition_processing */ 277 }, 278 { 279 "substitute_generated_columns": { 280 } /* substitute_generated_columns */ 281 }, 282 { 283 "table_dependencies": [ 284 { 285 "table": "`where_subselect_19379`", 286 "row_may_be_null": false, 287 "map_bit": 0, 288 "depends_on_map_bits": [ 289 ] /* depends_on_map_bits */ 290 } 291 ] /* table_dependencies */ 292 }, 293 { 294 "ref_optimizer_key_uses": [ 295 ] /* ref_optimizer_key_uses */ 296 }, 297 { 298 "rows_estimation": [ 299 { 300 "table": "`where_subselect_19379`", 301 "rows": 1, 302 "cost": 1, 303 "table_type": "system", 304 "empty": true 305 } 306 ] /* rows_estimation */ 307 } 308 ] /* steps */, 309 "empty_result": { 310 "cause": "no matching row in const table" 311 } /* empty_result */ 312 } /* join_optimization */ 313 }, 314 { 315 "join_optimization": { 316 "select#": 2, 317 "steps": [ 318 { 319 "condition_processing": { 320 "condition": "WHERE", 321 "original_condition": "(1 and <if>(outer_field_is_not_null, ((<cache>(NULL) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(NULL) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and (`alias2`.`col_varchar_key` = `sq2_alias1`.`col_varchar_nokey`) and (`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))", 322 "steps": [ 323 { 324 "transformation": "equality_propagation", 325 "subselect_evaluation": [ 326 ] /* subselect_evaluation */, 327 "resulting_condition": "(1 and <if>(outer_field_is_not_null, ((<cache>(NULL) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(NULL) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and multiple equal(`alias2`.`col_varchar_key`, `sq2_alias1`.`col_varchar_nokey`, `alias3`.`col_varchar_key`, `alias3`.`col_varchar_nokey`))" 328 }, 329 { 330 "transformation": "constant_propagation", 331 "subselect_evaluation": [ 332 ] /* subselect_evaluation */, 333 "resulting_condition": "(1 and <if>(outer_field_is_not_null, ((<cache>(NULL) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(NULL) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and multiple equal(`alias2`.`col_varchar_key`, `sq2_alias1`.`col_varchar_nokey`, `alias3`.`col_varchar_key`, `alias3`.`col_varchar_nokey`))" 334 }, 335 { 336 "transformation": "trivial_condition_removal", 337 "subselect_evaluation": [ 338 ] /* subselect_evaluation */, 339 "resulting_condition": "(<if>(outer_field_is_not_null, ((<cache>(NULL) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(NULL) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`sq2_alias1`.`col_varchar_nokey` <= `alias1`.`col_varchar_key`) and multiple equal(`alias2`.`col_varchar_key`, `sq2_alias1`.`col_varchar_nokey`, `alias3`.`col_varchar_key`, `alias3`.`col_varchar_nokey`))" 340 } 341 ] /* steps */ 342 } /* condition_processing */ 343 }, 344 { 345 "condition_processing": { 346 "condition": "HAVING", 347 "original_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))", 348 "steps": [ 349 { 350 "transformation": "constant_propagation", 351 "subselect_evaluation": [ 352 ] /* subselect_evaluation */, 353 "resulting_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))" 354 }, 355 { 356 "transformation": "trivial_condition_removal", 357 "subselect_evaluation": [ 358 ] /* subselect_evaluation */, 359 "resulting_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`alias1`.`col_varchar_nokey`), true))" 360 } 361 ] /* steps */ 362 } /* condition_processing */ 363 }, 364 { 365 "substitute_generated_columns": { 366 } /* substitute_generated_columns */ 367 }, 368 { 369 "table_dependencies": [ 370 { 371 "table": "`t2` `alias1`", 372 "row_may_be_null": false, 373 "map_bit": 0, 374 "depends_on_map_bits": [ 375 ] /* depends_on_map_bits */ 376 }, 377 { 378 "table": "`t2` `alias2`", 379 "row_may_be_null": true, 380 "map_bit": 1, 381 "depends_on_map_bits": [ 382 ] /* depends_on_map_bits */ 383 }, 384 { 385 "table": "`t2` `alias3`", 386 "row_may_be_null": true, 387 "map_bit": 2, 388 "depends_on_map_bits": [ 389 ] /* depends_on_map_bits */ 390 }, 391 { 392 "table": "`t3` `sq2_alias1`", 393 "row_may_be_null": false, 394 "map_bit": 3, 395 "depends_on_map_bits": [ 396 ] /* depends_on_map_bits */ 397 } 398 ] /* table_dependencies */ 399 }, 400 { 401 "ref_optimizer_key_uses": [ 402 ] /* ref_optimizer_key_uses */ 403 }, 404 { 405 "pulled_out_semijoin_tables": [ 406 ] /* pulled_out_semijoin_tables */ 407 }, 408 { 409 "rows_estimation": [ 410 { 411 "table": "`t2` `alias1`", 412 "table_scan": { 413 "rows": 1, 414 "cost": 1 415 } /* table_scan */ 416 }, 417 { 418 "table": "`t2` `alias2`", 419 "table_scan": { 420 "rows": 1, 421 "cost": 1 422 } /* table_scan */ 423 }, 424 { 425 "table": "`t2` `alias3`", 426 "table_scan": { 427 "rows": 1, 428 "cost": 1 429 } /* table_scan */ 430 }, 431 { 432 "table": "`t3` `sq2_alias1`", 433 "table_scan": { 434 "rows": 1, 435 "cost": 1 436 } /* table_scan */ 437 } 438 ] /* rows_estimation */ 439 }, 440 { 441 "execution_plan_for_potential_materialization": { 442 "steps": [ 443 ] /* steps */ 444 } /* execution_plan_for_potential_materialization */ 445 }, 446 { 447 "considered_execution_plans": [ 448 { 449 "plan_prefix": [ 450 ] /* plan_prefix */, 451 "table": "`t2` `alias1`", 452 "best_access_path": { 453 "considered_access_paths": [ 454 { 455 "rows_to_scan": 1, 456 "access_type": "scan", 457 "resulting_rows": 1, 458 "cost": 1.2, 459 "chosen": true 460 } 461 ] /* considered_access_paths */ 462 } /* best_access_path */, 463 "condition_filtering_pct": 100, 464 "rows_for_plan": 1, 465 "cost_for_plan": 1.2, 466 "semijoin_strategy_choice": [ 467 ] /* semijoin_strategy_choice */, 468 "rest_of_plan": [ 469 { 470 "plan_prefix": [ 471 "`t2` `alias1`" 472 ] /* plan_prefix */, 473 "table": "`t2` `alias2`", 474 "best_access_path": { 475 "considered_access_paths": [ 476 { 477 "rows_to_scan": 1, 478 "access_type": "scan", 479 "using_join_cache": true, 480 "buffers_needed": 1, 481 "resulting_rows": 1, 482 "cost": 1.2, 483 "chosen": true 484 } 485 ] /* considered_access_paths */ 486 } /* best_access_path */, 487 "condition_filtering_pct": 100, 488 "rows_for_plan": 1, 489 "cost_for_plan": 2.4, 490 "semijoin_strategy_choice": [ 491 ] /* semijoin_strategy_choice */, 492 "rest_of_plan": [ 493 { 494 "plan_prefix": [ 495 "`t2` `alias1`", 496 "`t2` `alias2`" 497 ] /* plan_prefix */, 498 "table": "`t2` `alias3`", 499 "best_access_path": { 500 "considered_access_paths": [ 501 { 502 "rows_to_scan": 1, 503 "access_type": "scan", 504 "using_join_cache": true, 505 "buffers_needed": 1, 506 "resulting_rows": 1, 507 "cost": 1.2, 508 "chosen": true 509 } 510 ] /* considered_access_paths */ 511 } /* best_access_path */, 512 "condition_filtering_pct": 100, 513 "rows_for_plan": 1, 514 "cost_for_plan": 3.6001, 515 "semijoin_strategy_choice": [ 516 ] /* semijoin_strategy_choice */, 517 "rest_of_plan": [ 518 { 519 "plan_prefix": [ 520 "`t2` `alias1`", 521 "`t2` `alias2`", 522 "`t2` `alias3`" 523 ] /* plan_prefix */, 524 "table": "`t3` `sq2_alias1`", 525 "best_access_path": { 526 "considered_access_paths": [ 527 { 528 "rows_to_scan": 1, 529 "access_type": "scan", 530 "using_join_cache": true, 531 "buffers_needed": 1, 532 "resulting_rows": 1, 533 "cost": 1.2001, 534 "chosen": true 535 } 536 ] /* considered_access_paths */ 537 } /* best_access_path */, 538 "condition_filtering_pct": 100, 539 "rows_for_plan": 1, 540 "cost_for_plan": 4.8001, 541 "semijoin_strategy_choice": [ 542 { 543 "strategy": "FirstMatch", 544 "recalculate_access_paths_and_cost": { 545 "tables": [ 546 { 547 "table": "`t3` `sq2_alias1`", 548 "best_access_path": { 549 "considered_access_paths": [ 550 { 551 "rows_to_scan": 1, 552 "access_type": "scan", 553 "using_join_cache": true, 554 "buffers_needed": 1, 555 "resulting_rows": 1, 556 "cost": 1.2001, 557 "chosen": true 558 } 559 ] /* considered_access_paths */ 560 } /* best_access_path */ 561 } 562 ] /* tables */ 563 } /* recalculate_access_paths_and_cost */, 564 "cost": 4.8001, 565 "rows": 1, 566 "chosen": true 567 }, 568 { 569 "strategy": "DuplicatesWeedout", 570 "cost": 7.2001, 571 "rows": 1, 572 "duplicate_tables_left": false, 573 "chosen": false 574 } 575 ] /* semijoin_strategy_choice */, 576 "chosen": true 577 } 578 ] /* rest_of_plan */ 579 }, 580 { 581 "plan_prefix": [ 582 "`t2` `alias1`", 583 "`t2` `alias2`" 584 ] /* plan_prefix */, 585 "table": "`t3` `sq2_alias1`", 586 "best_access_path": { 587 "considered_access_paths": [ 588 { 589 "rows_to_scan": 1, 590 "access_type": "scan", 591 "using_join_cache": true, 592 "buffers_needed": 1, 593 "resulting_rows": 1, 594 "cost": 1.2, 595 "chosen": true 596 } 597 ] /* considered_access_paths */ 598 } /* best_access_path */, 599 "condition_filtering_pct": 100, 600 "rows_for_plan": 1, 601 "cost_for_plan": 3.6001, 602 "semijoin_strategy_choice": [ 603 { 604 "strategy": "FirstMatch", 605 "recalculate_access_paths_and_cost": { 606 "tables": [ 607 { 608 "table": "`t3` `sq2_alias1`", 609 "best_access_path": { 610 "considered_access_paths": [ 611 { 612 "rows_to_scan": 1, 613 "access_type": "scan", 614 "using_join_cache": true, 615 "buffers_needed": 1, 616 "resulting_rows": 1, 617 "cost": 1.2, 618 "chosen": true 619 } 620 ] /* considered_access_paths */ 621 } /* best_access_path */ 622 } 623 ] /* tables */ 624 } /* recalculate_access_paths_and_cost */, 625 "cost": 3.6001, 626 "rows": 1, 627 "chosen": true 628 }, 629 { 630 "strategy": "DuplicatesWeedout", 631 "cost": 6.0001, 632 "rows": 1, 633 "duplicate_tables_left": false, 634 "chosen": false 635 } 636 ] /* semijoin_strategy_choice */, 637 "pruned_by_heuristic": true 638 } 639 ] /* rest_of_plan */ 640 }, 641 { 642 "plan_prefix": [ 643 "`t2` `alias1`" 644 ] /* plan_prefix */, 645 "table": "`t2` `alias3`", 646 "best_access_path": { 647 "considered_access_paths": [ 648 { 649 "rows_to_scan": 1, 650 "access_type": "scan", 651 "using_join_cache": true, 652 "buffers_needed": 1, 653 "resulting_rows": 1, 654 "cost": 1.2, 655 "chosen": true 656 } 657 ] /* considered_access_paths */ 658 } /* best_access_path */, 659 "condition_filtering_pct": 100, 660 "rows_for_plan": 1, 661 "cost_for_plan": 2.4, 662 "semijoin_strategy_choice": [ 663 ] /* semijoin_strategy_choice */, 664 "pruned_by_heuristic": true 665 }, 666 { 667 "plan_prefix": [ 668 "`t2` `alias1`" 669 ] /* plan_prefix */, 670 "table": "`t3` `sq2_alias1`", 671 "best_access_path": { 672 "considered_access_paths": [ 673 { 674 "rows_to_scan": 1, 675 "access_type": "scan", 676 "using_join_cache": true, 677 "buffers_needed": 1, 678 "resulting_rows": 1, 679 "cost": 1.2, 680 "chosen": true 681 } 682 ] /* considered_access_paths */ 683 } /* best_access_path */, 684 "condition_filtering_pct": 100, 685 "rows_for_plan": 1, 686 "cost_for_plan": 2.4, 687 "semijoin_strategy_choice": [ 688 ] /* semijoin_strategy_choice */, 689 "pruned_by_heuristic": true 690 } 691 ] /* rest_of_plan */ 692 }, 693 { 694 "plan_prefix": [ 695 ] /* plan_prefix */, 696 "table": "`t2` `alias2`", 697 "best_access_path": { 698 "considered_access_paths": [ 699 { 700 "rows_to_scan": 1, 701 "access_type": "scan", 702 "resulting_rows": 1, 703 "cost": 1.2, 704 "chosen": true 705 } 706 ] /* considered_access_paths */ 707 } /* best_access_path */, 708 "condition_filtering_pct": 100, 709 "rows_for_plan": 1, 710 "cost_for_plan": 1.2, 711 "semijoin_strategy_choice": [ 712 ] /* semijoin_strategy_choice */, 713 "pruned_by_heuristic": true 714 }, 715 { 716 "plan_prefix": [ 717 ] /* plan_prefix */, 718 "table": "`t2` `alias3`", 719 "best_access_path": { 720 "considered_access_paths": [ 721 { 722 "rows_to_scan": 1, 723 "access_type": "scan", 724 "resulting_rows": 1, 725 "cost": 1.2, 726 "chosen": true 727 } 728 ] /* considered_access_paths */ 729 } /* best_access_path */, 730 "condition_filtering_pct": 100, 731 "rows_for_plan": 1, 732 "cost_for_plan": 1.2, 733 "semijoin_strategy_choice": [ 734 ] /* semijoin_strategy_choice */, 735 "pruned_by_heuristic": true 736 }, 737 { 738 "plan_prefix": [ 739 ] /* plan_prefix */, 740 "table": "`t3` `sq2_alias1`", 741 "best_access_path": { 742 "considered_access_paths": [ 743 { 744 "rows_to_scan": 1, 745 "access_type": "scan", 746 "resulting_rows": 1, 747 "cost": 1.2, 748 "chosen": true 749 } 750 ] /* considered_access_paths */ 751 } /* best_access_path */, 752 "condition_filtering_pct": 100, 753 "rows_for_plan": 1, 754 "cost_for_plan": 1.2, 755 "semijoin_strategy_choice": [ 756 ] /* semijoin_strategy_choice */, 757 "pruned_by_heuristic": true 758 }, 759 { 760 "final_semijoin_strategy": "FirstMatch", 761 "recalculate_access_paths_and_cost": { 762 "tables": [ 763 { 764 "table": "`t3` `sq2_alias1`", 765 "best_access_path": { 766 "considered_access_paths": [ 767 { 768 "rows_to_scan": 1, 769 "access_type": "scan", 770 "using_join_cache": true, 771 "buffers_needed": 1, 772 "resulting_rows": 1, 773 "cost": 1.2001, 774 "chosen": true 775 } 776 ] /* considered_access_paths */ 777 } /* best_access_path */ 778 } 779 ] /* tables */ 780 } /* recalculate_access_paths_and_cost */ 781 } 782 ] /* considered_execution_plans */ 783 }, 784 { 785 "transformation": { 786 "select#": 2, 787 "from": "IN (SELECT)", 788 "to": "materialization", 789 "has_nullable_expressions": true, 790 "treat_UNKNOWN_as_FALSE": false, 791 "possible": false, 792 "cause": "cannot_handle_partial_matches" 793 } /* transformation */ 794 }, 795 { 796 "transformation": { 797 "select#": 2, 798 "from": "IN (SELECT)", 799 "to": "EXISTS (CORRELATED SELECT)", 800 "put_1_in_SELECT_list": true 801 } /* transformation */ 802 }, 803 { 804 "attaching_conditions_to_tables": { 805 "original_condition": "((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`) and (`sq2_alias1`.`col_varchar_nokey` = `alias2`.`col_varchar_key`) and <if>(outer_field_is_not_null, ((<cache>(NULL) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(NULL) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true) and (`alias2`.`col_varchar_key` <= `alias1`.`col_varchar_key`))", 806 "attached_conditions_computation": [ 807 ] /* attached_conditions_computation */, 808 "attached_conditions_summary": [ 809 { 810 "table": "`t2` `alias1`", 811 "attached": "(<if>(outer_field_is_not_null, ((<cache>(NULL) = (/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`))) or isnull((/* select#3 */ select sum(`t4`.`pk`) AS `sq1_field1` from `t4` join `t1` `sq1_alias2` where (`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)))), true) and <if>(outer_field_is_not_null, ((<cache>(NULL) = `alias1`.`col_varchar_nokey`) or isnull(`alias1`.`col_varchar_nokey`)), true))" 812 }, 813 { 814 "table": "`t2` `alias2`", 815 "attached": "(`alias2`.`col_varchar_key` <= `alias1`.`col_varchar_key`)" 816 }, 817 { 818 "table": "`t2` `alias3`", 819 "attached": "((`alias3`.`col_varchar_key` = `alias2`.`col_varchar_key`) and (`alias3`.`col_varchar_nokey` = `alias2`.`col_varchar_key`))" 820 }, 821 { 822 "table": "`t3` `sq2_alias1`", 823 "attached": "(`sq2_alias1`.`col_varchar_nokey` = `alias2`.`col_varchar_key`)" 824 } 825 ] /* attached_conditions_summary */ 826 } /* attaching_conditions_to_tables */ 827 }, 828 { 829 "refine_plan": [ 830 { 831 "table": "`t2` `alias1`" 832 }, 833 { 834 "table": "`t2` `alias2`" 835 }, 836 { 837 "table": "`t2` `alias3`" 838 }, 839 { 840 "table": "`t3` `sq2_alias1`" 841 } 842 ] /* refine_plan */ 843 } 844 ] /* steps */ 845 } /* join_optimization */ 846 }, 847 { 848 "join_optimization": { 849 "select#": 3, 850 "steps": [ 851 { 852 "condition_processing": { 853 "condition": "WHERE", 854 "original_condition": "(`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)", 855 "steps": [ 856 { 857 "transformation": "equality_propagation", 858 "resulting_condition": "multiple equal(`sq1_alias2`.`col_varchar_key`, `t4`.`col_varchar_key`)" 859 }, 860 { 861 "transformation": "constant_propagation", 862 "resulting_condition": "multiple equal(`sq1_alias2`.`col_varchar_key`, `t4`.`col_varchar_key`)" 863 }, 864 { 865 "transformation": "trivial_condition_removal", 866 "resulting_condition": "multiple equal(`sq1_alias2`.`col_varchar_key`, `t4`.`col_varchar_key`)" 867 } 868 ] /* steps */ 869 } /* condition_processing */ 870 }, 871 { 872 "substitute_generated_columns": { 873 } /* substitute_generated_columns */ 874 }, 875 { 876 "table_dependencies": [ 877 { 878 "table": "`t4`", 879 "row_may_be_null": false, 880 "map_bit": 0, 881 "depends_on_map_bits": [ 882 ] /* depends_on_map_bits */ 883 }, 884 { 885 "table": "`t1` `sq1_alias2`", 886 "row_may_be_null": false, 887 "map_bit": 1, 888 "depends_on_map_bits": [ 889 ] /* depends_on_map_bits */ 890 } 891 ] /* table_dependencies */ 892 }, 893 { 894 "ref_optimizer_key_uses": [ 895 ] /* ref_optimizer_key_uses */ 896 }, 897 { 898 "rows_estimation": [ 899 { 900 "table": "`t4`", 901 "table_scan": { 902 "rows": 1, 903 "cost": 1 904 } /* table_scan */ 905 }, 906 { 907 "table": "`t1` `sq1_alias2`", 908 "table_scan": { 909 "rows": 1, 910 "cost": 1 911 } /* table_scan */ 912 } 913 ] /* rows_estimation */ 914 }, 915 { 916 "considered_execution_plans": [ 917 { 918 "plan_prefix": [ 919 ] /* plan_prefix */, 920 "table": "`t4`", 921 "best_access_path": { 922 "considered_access_paths": [ 923 { 924 "rows_to_scan": 1, 925 "access_type": "scan", 926 "resulting_rows": 1, 927 "cost": 1.2, 928 "chosen": true 929 } 930 ] /* considered_access_paths */ 931 } /* best_access_path */, 932 "condition_filtering_pct": 100, 933 "rows_for_plan": 1, 934 "cost_for_plan": 1.2, 935 "rest_of_plan": [ 936 { 937 "plan_prefix": [ 938 "`t4`" 939 ] /* plan_prefix */, 940 "table": "`t1` `sq1_alias2`", 941 "best_access_path": { 942 "considered_access_paths": [ 943 { 944 "rows_to_scan": 1, 945 "access_type": "scan", 946 "using_join_cache": true, 947 "buffers_needed": 1, 948 "resulting_rows": 1, 949 "cost": 1.2, 950 "chosen": true 951 } 952 ] /* considered_access_paths */ 953 } /* best_access_path */, 954 "condition_filtering_pct": 100, 955 "rows_for_plan": 1, 956 "cost_for_plan": 2.4, 957 "chosen": true 958 } 959 ] /* rest_of_plan */ 960 }, 961 { 962 "plan_prefix": [ 963 ] /* plan_prefix */, 964 "table": "`t1` `sq1_alias2`", 965 "best_access_path": { 966 "considered_access_paths": [ 967 { 968 "rows_to_scan": 1, 969 "access_type": "scan", 970 "resulting_rows": 1, 971 "cost": 1.2, 972 "chosen": true 973 } 974 ] /* considered_access_paths */ 975 } /* best_access_path */, 976 "condition_filtering_pct": 100, 977 "rows_for_plan": 1, 978 "cost_for_plan": 1.2, 979 "pruned_by_heuristic": true 980 } 981 ] /* considered_execution_plans */ 982 }, 983 { 984 "attaching_conditions_to_tables": { 985 "original_condition": "(`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)", 986 "attached_conditions_computation": [ 987 ] /* attached_conditions_computation */, 988 "attached_conditions_summary": [ 989 { 990 "table": "`t4`", 991 "attached": null 992 }, 993 { 994 "table": "`t1` `sq1_alias2`", 995 "attached": "(`sq1_alias2`.`col_varchar_key` = `t4`.`col_varchar_key`)" 996 } 997 ] /* attached_conditions_summary */ 998 } /* attaching_conditions_to_tables */ 999 }, 1000 { 1001 "refine_plan": [ 1002 { 1003 "table": "`t4`" 1004 }, 1005 { 1006 "table": "`t1` `sq1_alias2`" 1007 } 1008 ] /* refine_plan */ 1009 } 1010 ] /* steps */ 1011 } /* join_optimization */ 1012 }, 1013 { 1014 "join_execution": { 1015 "select#": 1, 1016 "steps": [ 1017 ] /* steps */ 1018 } /* join_execution */ 1019 } 1020 ] /* steps */ 1021} 0 0 1022drop table t1,t2,t3,t4,where_subselect_19379; 1023drop view view_t4; 1024# 1025# BUG#12607524 JSON PARSE ERROR ON SELECT ... FROM ... WHERE .. IN (SUBQUERY) 1026# 1027CREATE TABLE t1 ( 1028col_int_key int(11) DEFAULT NULL, 1029col_varchar_key varchar(1) DEFAULT NULL, 1030KEY col_int_key (col_int_key), 1031KEY col_varchar_key (col_varchar_key,col_int_key) 1032) ENGINE=MyISAM; 1033INSERT INTO t1 VALUES (8,'g'); 1034CREATE TABLE t2 ( 1035col_int_key int(11) DEFAULT NULL, 1036col_varchar_key varchar(1) DEFAULT NULL, 1037KEY col_int_key (col_int_key), 1038KEY col_varchar_key (col_varchar_key,col_int_key) 1039) ENGINE=MyISAM; 1040INSERT INTO t2 VALUES (7,'x'); 1041CREATE TABLE where_subselect_19033 1042SELECT 1043( SELECT col_int_key FROM t2 ) as field1 1044FROM t1 1045; 1046SELECT * FROM where_subselect_19033; 1047field1 10487 1049SELECT field1 1050FROM where_subselect_19033 1051WHERE field1 IN 1052( SELECT 1053( SELECT col_int_key FROM t2 ) 1054FROM t1 1055) 1056; 1057field1 10587 1059SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; 1060QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES 1061SELECT field1 1062FROM where_subselect_19033 1063WHERE field1 IN 1064( SELECT 1065( SELECT col_int_key FROM t2 ) 1066FROM t1 1067) { 1068 "steps": [ 1069 { 1070 "join_preparation": { 1071 "select#": 1, 1072 "steps": [ 1073 { 1074 "join_preparation": { 1075 "select#": 2, 1076 "steps": [ 1077 { 1078 "join_preparation": { 1079 "select#": 3, 1080 "steps": [ 1081 { 1082 "expanded_query": "/* select#3 */ select `t2`.`col_int_key` from `t2`" 1083 } 1084 ] /* steps */ 1085 } /* join_preparation */ 1086 }, 1087 { 1088 "expanded_query": "/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`" 1089 }, 1090 { 1091 "transformation": { 1092 "select#": 2, 1093 "from": "IN (SELECT)", 1094 "to": "semijoin", 1095 "chosen": true 1096 } /* transformation */ 1097 } 1098 ] /* steps */ 1099 } /* join_preparation */ 1100 }, 1101 { 1102 "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` where `where_subselect_19033`.`field1` in (/* select#2 */ select (/* select#3 */ select `t2`.`col_int_key` from `t2`) from `t1`)" 1103 }, 1104 { 1105 "transformation": { 1106 "select#": 2, 1107 "from": "IN (SELECT)", 1108 "to": "semijoin", 1109 "chosen": true, 1110 "evaluating_constant_semijoin_conditions": [ 1111 ] /* evaluating_constant_semijoin_conditions */ 1112 } /* transformation */ 1113 }, 1114 { 1115 "transformations_to_nested_joins": { 1116 "transformations": [ 1117 "semijoin" 1118 ] /* transformations */, 1119 "expanded_query": "/* select#1 */ select `where_subselect_19033`.`field1` AS `field1` from `where_subselect_19033` semi join (`t1`) where (1 and (`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`)))" 1120 } /* transformations_to_nested_joins */ 1121 } 1122 ] /* steps */ 1123 } /* join_preparation */ 1124 }, 1125 { 1126 "join_optimization": { 1127 "select#": 1, 1128 "steps": [ 1129 { 1130 "condition_processing": { 1131 "condition": "WHERE", 1132 "original_condition": "(1 and (`where_subselect_19033`.`field1` = (/* select#3 */ select `t2`.`col_int_key` from `t2`)))", 1133 "steps": [ 1134 { 1135 "transformation": "equality_propagation", 1136 "subselect_evaluation": [ 1137 ] /* subselect_evaluation */, 1138 "resulting_condition": "(1 and multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`))" 1139 }, 1140 { 1141 "transformation": "constant_propagation", 1142 "resulting_condition": "(1 and multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`))" 1143 }, 1144 { 1145 "transformation": "trivial_condition_removal", 1146 "resulting_condition": "multiple equal((/* select#3 */ select `t2`.`col_int_key` from `t2`), `where_subselect_19033`.`field1`)" 1147 } 1148 ] /* steps */ 1149 } /* condition_processing */ 1150 }, 1151 { 1152 "substitute_generated_columns": { 1153 } /* substitute_generated_columns */ 1154 }, 1155 { 1156 "table_dependencies": [ 1157 { 1158 "table": "`where_subselect_19033`", 1159 "row_may_be_null": false, 1160 "map_bit": 0, 1161 "depends_on_map_bits": [ 1162 ] /* depends_on_map_bits */ 1163 }, 1164 { 1165 "table": "`t1`", 1166 "row_may_be_null": false, 1167 "map_bit": 1, 1168 "depends_on_map_bits": [ 1169 ] /* depends_on_map_bits */ 1170 } 1171 ] /* table_dependencies */ 1172 }, 1173 { 1174 "ref_optimizer_key_uses": [ 1175 ] /* ref_optimizer_key_uses */ 1176 }, 1177 { 1178 "pulled_out_semijoin_tables": [ 1179 ] /* pulled_out_semijoin_tables */ 1180 }, 1181 { 1182 "subselect_execution": { 1183 "select#": 3, 1184 "steps": [ 1185 { 1186 "join_optimization": { 1187 "select#": 3, 1188 "steps": [ 1189 { 1190 "table_dependencies": [ 1191 { 1192 "table": "`t2`", 1193 "row_may_be_null": false, 1194 "map_bit": 0, 1195 "depends_on_map_bits": [ 1196 ] /* depends_on_map_bits */ 1197 } 1198 ] /* table_dependencies */ 1199 }, 1200 { 1201 "rows_estimation": [ 1202 { 1203 "table": "`t2`", 1204 "rows": 1, 1205 "cost": 1, 1206 "table_type": "system", 1207 "empty": false 1208 } 1209 ] /* rows_estimation */ 1210 }, 1211 { 1212 "attaching_conditions_to_tables": { 1213 "original_condition": null, 1214 "attached_conditions_computation": [ 1215 ] /* attached_conditions_computation */, 1216 "attached_conditions_summary": [ 1217 ] /* attached_conditions_summary */ 1218 } /* attaching_conditions_to_tables */ 1219 }, 1220 { 1221 "refine_plan": [ 1222 ] /* refine_plan */ 1223 } 1224 ] /* steps */ 1225 } /* join_optimization */ 1226 }, 1227 { 1228 "join_execution": { 1229 "select#": 3, 1230 "steps": [ 1231 ] /* steps */ 1232 } /* join_execution */ 1233 } 1234 ] /* steps */ 1235 } /* subselect_execution */ 1236 }, 1237 { 1238 "rows_estimation": [ 1239 { 1240 "table": "`where_subselect_19033`", 1241 "rows": 1, 1242 "cost": 1, 1243 "table_type": "system", 1244 "empty": false 1245 }, 1246 { 1247 "table": "`t1`", 1248 "table_scan": { 1249 "rows": 1, 1250 "cost": 2 1251 } /* table_scan */ 1252 } 1253 ] /* rows_estimation */ 1254 }, 1255 { 1256 "execution_plan_for_potential_materialization": { 1257 "steps": [ 1258 { 1259 "considered_execution_plans": [ 1260 { 1261 "plan_prefix": [ 1262 ] /* plan_prefix */, 1263 "table": "`t1`", 1264 "best_access_path": { 1265 "considered_access_paths": [ 1266 { 1267 "rows_to_scan": 1, 1268 "access_type": "scan", 1269 "resulting_rows": 1, 1270 "cost": 2.2049, 1271 "chosen": true 1272 } 1273 ] /* considered_access_paths */ 1274 } /* best_access_path */, 1275 "condition_filtering_pct": 100, 1276 "rows_for_plan": 1, 1277 "cost_for_plan": 2.2049, 1278 "chosen": true 1279 } 1280 ] /* considered_execution_plans */ 1281 } 1282 ] /* steps */ 1283 } /* execution_plan_for_potential_materialization */ 1284 }, 1285 { 1286 "considered_execution_plans": [ 1287 { 1288 "plan_prefix": [ 1289 "`where_subselect_19033`" 1290 ] /* plan_prefix */, 1291 "table": "`t1`", 1292 "best_access_path": { 1293 "considered_access_paths": [ 1294 { 1295 "rows_to_scan": 1, 1296 "access_type": "scan", 1297 "resulting_rows": 1, 1298 "cost": 2.2049, 1299 "chosen": true 1300 } 1301 ] /* considered_access_paths */ 1302 } /* best_access_path */, 1303 "condition_filtering_pct": 100, 1304 "rows_for_plan": 1, 1305 "cost_for_plan": 2.2049, 1306 "semijoin_strategy_choice": [ 1307 { 1308 "strategy": "FirstMatch", 1309 "recalculate_access_paths_and_cost": { 1310 "tables": [ 1311 ] /* tables */ 1312 } /* recalculate_access_paths_and_cost */, 1313 "cost": 2.2049, 1314 "rows": 1, 1315 "chosen": true 1316 }, 1317 { 1318 "strategy": "MaterializeLookup", 1319 "cost": 4.6049, 1320 "rows": 1, 1321 "duplicate_tables_left": false, 1322 "chosen": false 1323 }, 1324 { 1325 "strategy": "DuplicatesWeedout", 1326 "cost": 4.6049, 1327 "rows": 1, 1328 "duplicate_tables_left": false, 1329 "chosen": false 1330 } 1331 ] /* semijoin_strategy_choice */, 1332 "chosen": true 1333 }, 1334 { 1335 "final_semijoin_strategy": "FirstMatch", 1336 "recalculate_access_paths_and_cost": { 1337 "tables": [ 1338 ] /* tables */ 1339 } /* recalculate_access_paths_and_cost */ 1340 } 1341 ] /* considered_execution_plans */ 1342 }, 1343 { 1344 "condition_on_constant_tables": "1", 1345 "condition_value": true 1346 }, 1347 { 1348 "attaching_conditions_to_tables": { 1349 "original_condition": "1", 1350 "attached_conditions_computation": [ 1351 ] /* attached_conditions_computation */, 1352 "attached_conditions_summary": [ 1353 { 1354 "table": "`t1`", 1355 "attached": null 1356 } 1357 ] /* attached_conditions_summary */ 1358 } /* attaching_conditions_to_tables */ 1359 }, 1360 { 1361 "refine_plan": [ 1362 { 1363 "table": "`t1`" 1364 } 1365 ] /* refine_plan */ 1366 } 1367 ] /* steps */ 1368 } /* join_optimization */ 1369 }, 1370 { 1371 "join_execution": { 1372 "select#": 1, 1373 "steps": [ 1374 ] /* steps */ 1375 } /* join_execution */ 1376 } 1377 ] /* steps */ 1378} 0 0 1379DROP TABLE where_subselect_19033,t1,t2; 1380 1381# BUG#12612201 - SEGFAULT IN 1382# SUBSELECT_UNIQUESUBQUERY_ENGINE::PRINT WITH OPTIMIZER TRACE 1383 1384CREATE TABLE t1 ( 1385col_int_key int(11) DEFAULT NULL, 1386col_varchar_key varchar(1) DEFAULT NULL, 1387col_varchar_nokey varchar(1) DEFAULT NULL 1388); 1389CREATE TABLE t2 ( 1390pk int(11) NOT NULL AUTO_INCREMENT, 1391col_int_key int(11) DEFAULT NULL, 1392col_varchar_key varchar(1) DEFAULT NULL, 1393col_varchar_nokey varchar(1) DEFAULT NULL, 1394PRIMARY KEY (pk) 1395); 1396INSERT INTO t2 VALUES (1,4,'v','v'),(20,5,'r','r'); 1397CREATE TABLE t3 ( 1398col_int_key int(11) DEFAULT NULL, 1399col_varchar_key varchar(1) DEFAULT NULL, 1400col_varchar_nokey varchar(1) DEFAULT NULL 1401); 1402INSERT INTO t3 VALUES (NULL,'j','j'),(8,'c','c'); 1403CREATE TABLE where_updatedelete_20769 select count( alias2 . col_varchar_key ) as field1 1404from ( 1405(select sq1_alias1 . * 1406from ( t3 as sq1_alias1 1407straight_join t1 as sq1_alias2 1408on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) 1409) 1410where sq1_alias1 . col_int_key in ( 1411select c_sq1_alias1 . pk as c_sq1_field1 1412from t2 as c_sq1_alias1 1413) 1414) as alias1 1415left outer join t1 as alias2 1416on (alias2 . col_varchar_key = alias1 . col_varchar_key ) 1417) 1418where ( alias2 . col_varchar_key in ( 1419select sq2_alias1 . col_varchar_nokey as sq2_field1 1420from t2 as sq2_alias1 1421where sq2_alias1 . col_int_key in ( 1422select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 1423from t3 as c_sq2_alias1 1424) 1425) ) 1426or alias1 . col_int_key = 2 1427and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey 1428order by alias1 . col_varchar_key , field1 1429; 1430UPDATE where_updatedelete_20769 SET field1 = ( select count( alias2 . col_varchar_key ) as field1 1431from ( 1432(select sq1_alias1 . * 1433from ( t3 as sq1_alias1 1434straight_join t1 as sq1_alias2 1435on (sq1_alias2 . col_varchar_key = sq1_alias1 . col_varchar_key) 1436) 1437where sq1_alias1 . col_int_key in ( 1438select c_sq1_alias1 . pk as c_sq1_field1 1439from t2 as c_sq1_alias1 1440) 1441) as alias1 1442left outer join t1 as alias2 1443on (alias2 . col_varchar_key = alias1 . col_varchar_key ) 1444) 1445where ( alias2 . col_varchar_key in ( 1446select sq2_alias1 . col_varchar_nokey as sq2_field1 1447from t2 as sq2_alias1 1448where sq2_alias1 . col_int_key in ( 1449select distinct c_sq2_alias1 . col_int_key as c_sq2_field1 1450from t3 as c_sq2_alias1 1451) 1452) ) 1453or alias1 . col_int_key = 2 1454and alias2 . col_varchar_nokey <= alias1 . col_varchar_nokey 1455order by alias1 . col_varchar_key , field1 1456 ); 1457DROP TABLE where_updatedelete_20769; 1458DROP TABLE t1,t2,t3; 1459 1460# BUG#12710761 - INVALID JSON TRACE ON SUBQUERY IN IN-CLAUSE 1461 1462CREATE TABLE t1 (col_int_key int, KEY col_int_key (col_int_key)); 1463INSERT INTO t1 VALUES (0),(8),(1),(8); 1464CREATE TABLE where_subselect_20070 1465SELECT table2 .col_int_key AS field1, 1466( SELECT COUNT( col_int_key ) 1467FROM t1 1468) 1469FROM t1 AS table1 1470JOIN t1 AS table2 1471ON table2 .col_int_key = table1 .col_int_key; 1472SELECT * 1473FROM where_subselect_20070 1474WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( 1475SELECT table2 .col_int_key AS field1, 1476( SELECT COUNT( col_int_key ) 1477FROM t1 1478) 1479FROM t1 AS table1 1480JOIN t1 AS table2 1481ON table2 .col_int_key = table1 .col_int_key 1482); 1483field1 ( SELECT COUNT( col_int_key ) 1484FROM t1 1485) 14860 4 14871 4 14888 4 14898 4 14908 4 14918 4 1492select * from information_schema.optimizer_trace; 1493QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES 1494SELECT * 1495FROM where_subselect_20070 1496WHERE (field1, ( SELECT COUNT( col_int_key ) FROM t1 )) IN ( 1497SELECT table2 .col_int_key AS field1, 1498( SELECT COUNT( col_int_key ) 1499FROM t1 1500) 1501FROM t1 AS table1 1502JOIN t1 AS table2 1503ON table2 .col_int_key = table1 .col_int_key 1504) { 1505 "steps": [ 1506 { 1507 "join_preparation": { 1508 "select#": 1, 1509 "steps": [ 1510 { 1511 "join_preparation": { 1512 "select#": 3, 1513 "steps": [ 1514 { 1515 "join_preparation": { 1516 "select#": 4, 1517 "steps": [ 1518 { 1519 "expanded_query": "/* select#4 */ select count(`t1`.`col_int_key`) from `t1`" 1520 } 1521 ] /* steps */ 1522 } /* join_preparation */ 1523 }, 1524 { 1525 "expanded_query": "/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`)))" 1526 }, 1527 { 1528 "join_preparation": { 1529 "select#": 2, 1530 "steps": [ 1531 { 1532 "expanded_query": "/* select#2 */ select count(`t1`.`col_int_key`) from `t1`" 1533 } 1534 ] /* steps */ 1535 } /* join_preparation */ 1536 }, 1537 { 1538 "transformation": { 1539 "select#": 3, 1540 "from": "IN (SELECT)", 1541 "to": "semijoin", 1542 "chosen": true 1543 } /* transformation */ 1544 } 1545 ] /* steps */ 1546 } /* join_preparation */ 1547 }, 1548 { 1549 "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` where (`where_subselect_20070`.`field1`,(/* select#2 */ select count(`t1`.`col_int_key`) from `t1`)) in (/* select#3 */ select `table2`.`col_int_key` AS `field1`,(/* select#4 */ select count(`t1`.`col_int_key`) from `t1`) from (`t1` `table1` join `t1` `table2` on((`table2`.`col_int_key` = `table1`.`col_int_key`))))" 1550 }, 1551 { 1552 "transformation": { 1553 "select#": 3, 1554 "from": "IN (SELECT)", 1555 "to": "semijoin", 1556 "chosen": true, 1557 "evaluating_constant_semijoin_conditions": [ 1558 ] /* evaluating_constant_semijoin_conditions */ 1559 } /* transformation */ 1560 }, 1561 { 1562 "transformations_to_nested_joins": { 1563 "transformations": [ 1564 "semijoin", 1565 "JOIN_condition_to_WHERE", 1566 "parenthesis_removal" 1567 ] /* transformations */, 1568 "expanded_query": "/* select#1 */ select `where_subselect_20070`.`field1` AS `field1`,`where_subselect_20070`.`( SELECT COUNT( col_int_key )\nFROM t1\n)` AS `( SELECT COUNT( col_int_key )\nFROM t1\n)` from `where_subselect_20070` semi join (`t1` `table1` join `t1` `table2`) where (1 and (`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))" 1569 } /* transformations_to_nested_joins */ 1570 } 1571 ] /* steps */ 1572 } /* join_preparation */ 1573 }, 1574 { 1575 "join_optimization": { 1576 "select#": 1, 1577 "steps": [ 1578 { 1579 "condition_processing": { 1580 "condition": "WHERE", 1581 "original_condition": "(1 and (`where_subselect_20070`.`field1` = `table2`.`col_int_key`) and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", 1582 "steps": [ 1583 { 1584 "transformation": "equality_propagation", 1585 "subselect_evaluation": [ 1586 ] /* subselect_evaluation */, 1587 "resulting_condition": "(1 and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`))" 1588 }, 1589 { 1590 "transformation": "constant_propagation", 1591 "subselect_evaluation": [ 1592 ] /* subselect_evaluation */, 1593 "resulting_condition": "(1 and ((/* select#2 */ select count(`t1`.`col_int_key`) from `t1`) = (/* select#4 */ select count(`t1`.`col_int_key`) from `t1`)) and multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`))" 1594 }, 1595 { 1596 "transformation": "trivial_condition_removal", 1597 "subselect_evaluation": [ 1598 { 1599 "subselect_execution": { 1600 "select#": 2, 1601 "steps": [ 1602 { 1603 "join_optimization": { 1604 "select#": 2, 1605 "steps": [ 1606 { 1607 "table_dependencies": [ 1608 { 1609 "table": "`t1`", 1610 "row_may_be_null": false, 1611 "map_bit": 0, 1612 "depends_on_map_bits": [ 1613 ] /* depends_on_map_bits */ 1614 } 1615 ] /* table_dependencies */ 1616 }, 1617 { 1618 "rows_estimation": [ 1619 { 1620 "table": "`t1`", 1621 "table_scan": { 1622 "rows": 4, 1623 "cost": 2 1624 } /* table_scan */ 1625 } 1626 ] /* rows_estimation */ 1627 }, 1628 { 1629 "considered_execution_plans": [ 1630 { 1631 "plan_prefix": [ 1632 ] /* plan_prefix */, 1633 "table": "`t1`", 1634 "best_access_path": { 1635 "considered_access_paths": [ 1636 { 1637 "rows_to_scan": 4, 1638 "access_type": "scan", 1639 "resulting_rows": 4, 1640 "cost": 2.8068, 1641 "chosen": true 1642 } 1643 ] /* considered_access_paths */ 1644 } /* best_access_path */, 1645 "condition_filtering_pct": 100, 1646 "rows_for_plan": 4, 1647 "cost_for_plan": 2.8068, 1648 "chosen": true 1649 } 1650 ] /* considered_execution_plans */ 1651 }, 1652 { 1653 "attaching_conditions_to_tables": { 1654 "original_condition": null, 1655 "attached_conditions_computation": [ 1656 ] /* attached_conditions_computation */, 1657 "attached_conditions_summary": [ 1658 { 1659 "table": "`t1`", 1660 "attached": null 1661 } 1662 ] /* attached_conditions_summary */ 1663 } /* attaching_conditions_to_tables */ 1664 }, 1665 { 1666 "refine_plan": [ 1667 { 1668 "table": "`t1`" 1669 } 1670 ] /* refine_plan */ 1671 } 1672 ] /* steps */ 1673 } /* join_optimization */ 1674 }, 1675 { 1676 "join_execution": { 1677 "select#": 2, 1678 "steps": [ 1679 ] /* steps */ 1680 } /* join_execution */ 1681 } 1682 ] /* steps */ 1683 } /* subselect_execution */ 1684 }, 1685 { 1686 "subselect_execution": { 1687 "select#": 4, 1688 "steps": [ 1689 { 1690 "join_optimization": { 1691 "select#": 4, 1692 "steps": [ 1693 { 1694 "table_dependencies": [ 1695 { 1696 "table": "`t1`", 1697 "row_may_be_null": false, 1698 "map_bit": 0, 1699 "depends_on_map_bits": [ 1700 ] /* depends_on_map_bits */ 1701 } 1702 ] /* table_dependencies */ 1703 }, 1704 { 1705 "rows_estimation": [ 1706 { 1707 "table": "`t1`", 1708 "table_scan": { 1709 "rows": 4, 1710 "cost": 2 1711 } /* table_scan */ 1712 } 1713 ] /* rows_estimation */ 1714 }, 1715 { 1716 "considered_execution_plans": [ 1717 { 1718 "plan_prefix": [ 1719 ] /* plan_prefix */, 1720 "table": "`t1`", 1721 "best_access_path": { 1722 "considered_access_paths": [ 1723 { 1724 "rows_to_scan": 4, 1725 "access_type": "scan", 1726 "resulting_rows": 4, 1727 "cost": 2.8068, 1728 "chosen": true 1729 } 1730 ] /* considered_access_paths */ 1731 } /* best_access_path */, 1732 "condition_filtering_pct": 100, 1733 "rows_for_plan": 4, 1734 "cost_for_plan": 2.8068, 1735 "chosen": true 1736 } 1737 ] /* considered_execution_plans */ 1738 }, 1739 { 1740 "attaching_conditions_to_tables": { 1741 "original_condition": null, 1742 "attached_conditions_computation": [ 1743 ] /* attached_conditions_computation */, 1744 "attached_conditions_summary": [ 1745 { 1746 "table": "`t1`", 1747 "attached": null 1748 } 1749 ] /* attached_conditions_summary */ 1750 } /* attaching_conditions_to_tables */ 1751 }, 1752 { 1753 "refine_plan": [ 1754 { 1755 "table": "`t1`" 1756 } 1757 ] /* refine_plan */ 1758 } 1759 ] /* steps */ 1760 } /* join_optimization */ 1761 }, 1762 { 1763 "join_execution": { 1764 "select#": 4, 1765 "steps": [ 1766 ] /* steps */ 1767 } /* join_execution */ 1768 } 1769 ] /* steps */ 1770 } /* subselect_execution */ 1771 } 1772 ] /* subselect_evaluation */, 1773 "resulting_condition": "multiple equal(`where_subselect_20070`.`field1`, `table2`.`col_int_key`, `table1`.`col_int_key`)" 1774 } 1775 ] /* steps */ 1776 } /* condition_processing */ 1777 }, 1778 { 1779 "substitute_generated_columns": { 1780 } /* substitute_generated_columns */ 1781 }, 1782 { 1783 "table_dependencies": [ 1784 { 1785 "table": "`where_subselect_20070`", 1786 "row_may_be_null": false, 1787 "map_bit": 0, 1788 "depends_on_map_bits": [ 1789 ] /* depends_on_map_bits */ 1790 }, 1791 { 1792 "table": "`t1` `table1`", 1793 "row_may_be_null": false, 1794 "map_bit": 1, 1795 "depends_on_map_bits": [ 1796 ] /* depends_on_map_bits */ 1797 }, 1798 { 1799 "table": "`t1` `table2`", 1800 "row_may_be_null": false, 1801 "map_bit": 2, 1802 "depends_on_map_bits": [ 1803 ] /* depends_on_map_bits */ 1804 } 1805 ] /* table_dependencies */ 1806 }, 1807 { 1808 "ref_optimizer_key_uses": [ 1809 { 1810 "table": "`t1` `table1`", 1811 "field": "col_int_key", 1812 "equals": "`where_subselect_20070`.`field1`", 1813 "null_rejecting": true 1814 }, 1815 { 1816 "table": "`t1` `table1`", 1817 "field": "col_int_key", 1818 "equals": "`table2`.`col_int_key`", 1819 "null_rejecting": true 1820 }, 1821 { 1822 "table": "`t1` `table2`", 1823 "field": "col_int_key", 1824 "equals": "`where_subselect_20070`.`field1`", 1825 "null_rejecting": true 1826 }, 1827 { 1828 "table": "`t1` `table2`", 1829 "field": "col_int_key", 1830 "equals": "`table1`.`col_int_key`", 1831 "null_rejecting": true 1832 } 1833 ] /* ref_optimizer_key_uses */ 1834 }, 1835 { 1836 "pulled_out_semijoin_tables": [ 1837 ] /* pulled_out_semijoin_tables */ 1838 }, 1839 { 1840 "rows_estimation": [ 1841 { 1842 "table": "`where_subselect_20070`", 1843 "table_scan": { 1844 "rows": 6, 1845 "cost": 2 1846 } /* table_scan */ 1847 }, 1848 { 1849 "table": "`t1` `table1`", 1850 "table_scan": { 1851 "rows": 4, 1852 "cost": 2 1853 } /* table_scan */ 1854 }, 1855 { 1856 "table": "`t1` `table2`", 1857 "table_scan": { 1858 "rows": 4, 1859 "cost": 2 1860 } /* table_scan */ 1861 } 1862 ] /* rows_estimation */ 1863 }, 1864 { 1865 "execution_plan_for_potential_materialization": { 1866 "steps": [ 1867 { 1868 "considered_execution_plans": [ 1869 { 1870 "plan_prefix": [ 1871 ] /* plan_prefix */, 1872 "table": "`t1` `table1`", 1873 "best_access_path": { 1874 "considered_access_paths": [ 1875 { 1876 "access_type": "ref", 1877 "index": "col_int_key", 1878 "usable": false, 1879 "chosen": false 1880 }, 1881 { 1882 "rows_to_scan": 4, 1883 "access_type": "scan", 1884 "resulting_rows": 4, 1885 "cost": 2.8068, 1886 "chosen": true 1887 } 1888 ] /* considered_access_paths */ 1889 } /* best_access_path */, 1890 "condition_filtering_pct": 100, 1891 "rows_for_plan": 4, 1892 "cost_for_plan": 2.8068, 1893 "rest_of_plan": [ 1894 { 1895 "plan_prefix": [ 1896 "`t1` `table1`" 1897 ] /* plan_prefix */, 1898 "table": "`t1` `table2`", 1899 "best_access_path": { 1900 "considered_access_paths": [ 1901 { 1902 "access_type": "ref", 1903 "index": "col_int_key", 1904 "rows": 2, 1905 "cost": 5.693, 1906 "chosen": true 1907 }, 1908 { 1909 "rows_to_scan": 4, 1910 "access_type": "scan", 1911 "using_join_cache": true, 1912 "buffers_needed": 1, 1913 "resulting_rows": 4, 1914 "cost": 5.207, 1915 "chosen": true 1916 } 1917 ] /* considered_access_paths */ 1918 } /* best_access_path */, 1919 "condition_filtering_pct": 25, 1920 "rows_for_plan": 4, 1921 "cost_for_plan": 8.0138, 1922 "chosen": true 1923 } 1924 ] /* rest_of_plan */ 1925 }, 1926 { 1927 "plan_prefix": [ 1928 ] /* plan_prefix */, 1929 "table": "`t1` `table2`", 1930 "best_access_path": { 1931 "considered_access_paths": [ 1932 { 1933 "access_type": "ref", 1934 "index": "col_int_key", 1935 "usable": false, 1936 "chosen": false 1937 }, 1938 { 1939 "rows_to_scan": 4, 1940 "access_type": "scan", 1941 "resulting_rows": 4, 1942 "cost": 2.8068, 1943 "chosen": true 1944 } 1945 ] /* considered_access_paths */ 1946 } /* best_access_path */, 1947 "condition_filtering_pct": 100, 1948 "rows_for_plan": 4, 1949 "cost_for_plan": 2.8068, 1950 "rest_of_plan": [ 1951 { 1952 "plan_prefix": [ 1953 "`t1` `table2`" 1954 ] /* plan_prefix */, 1955 "table": "`t1` `table1`", 1956 "best_access_path": { 1957 "considered_access_paths": [ 1958 { 1959 "access_type": "ref", 1960 "index": "col_int_key", 1961 "rows": 2, 1962 "cost": 5.693, 1963 "chosen": true 1964 }, 1965 { 1966 "rows_to_scan": 4, 1967 "access_type": "scan", 1968 "using_join_cache": true, 1969 "buffers_needed": 1, 1970 "resulting_rows": 4, 1971 "cost": 5.207, 1972 "chosen": true 1973 } 1974 ] /* considered_access_paths */ 1975 } /* best_access_path */, 1976 "condition_filtering_pct": 25, 1977 "rows_for_plan": 4, 1978 "cost_for_plan": 8.0138, 1979 "pruned_by_cost": true 1980 } 1981 ] /* rest_of_plan */ 1982 } 1983 ] /* considered_execution_plans */ 1984 } 1985 ] /* steps */ 1986 } /* execution_plan_for_potential_materialization */ 1987 }, 1988 { 1989 "considered_execution_plans": [ 1990 { 1991 "plan_prefix": [ 1992 ] /* plan_prefix */, 1993 "table": "`where_subselect_20070`", 1994 "best_access_path": { 1995 "considered_access_paths": [ 1996 { 1997 "rows_to_scan": 6, 1998 "access_type": "scan", 1999 "resulting_rows": 6, 2000 "cost": 3.219, 2001 "chosen": true 2002 } 2003 ] /* considered_access_paths */ 2004 } /* best_access_path */, 2005 "condition_filtering_pct": 100, 2006 "rows_for_plan": 6, 2007 "cost_for_plan": 3.219, 2008 "semijoin_strategy_choice": [ 2009 ] /* semijoin_strategy_choice */, 2010 "rest_of_plan": [ 2011 { 2012 "plan_prefix": [ 2013 "`where_subselect_20070`" 2014 ] /* plan_prefix */, 2015 "table": "`t1` `table1`", 2016 "best_access_path": { 2017 "considered_access_paths": [ 2018 { 2019 "access_type": "ref", 2020 "index": "col_int_key", 2021 "rows": 2, 2022 "cost": 8.5395, 2023 "chosen": true 2024 }, 2025 { 2026 "rows_to_scan": 4, 2027 "access_type": "scan", 2028 "using_join_cache": true, 2029 "buffers_needed": 1, 2030 "resulting_rows": 4, 2031 "cost": 6.8074, 2032 "chosen": true 2033 } 2034 ] /* considered_access_paths */ 2035 } /* best_access_path */, 2036 "condition_filtering_pct": 25, 2037 "rows_for_plan": 6, 2038 "cost_for_plan": 10.026, 2039 "semijoin_strategy_choice": [ 2040 ] /* semijoin_strategy_choice */, 2041 "rest_of_plan": [ 2042 { 2043 "plan_prefix": [ 2044 "`where_subselect_20070`", 2045 "`t1` `table1`" 2046 ] /* plan_prefix */, 2047 "table": "`t1` `table2`", 2048 "best_access_path": { 2049 "considered_access_paths": [ 2050 { 2051 "access_type": "ref", 2052 "index": "col_int_key", 2053 "rows": 2, 2054 "cost": 8.5395, 2055 "chosen": true 2056 }, 2057 { 2058 "rows_to_scan": 4, 2059 "access_type": "scan", 2060 "using_join_cache": true, 2061 "buffers_needed": 1, 2062 "resulting_rows": 4, 2063 "cost": 6.8077, 2064 "chosen": true 2065 } 2066 ] /* considered_access_paths */ 2067 } /* best_access_path */, 2068 "condition_filtering_pct": 25, 2069 "rows_for_plan": 6, 2070 "cost_for_plan": 16.834, 2071 "semijoin_strategy_choice": [ 2072 { 2073 "strategy": "FirstMatch", 2074 "recalculate_access_paths_and_cost": { 2075 "tables": [ 2076 { 2077 "table": "`t1` `table1`", 2078 "best_access_path": { 2079 "considered_access_paths": [ 2080 { 2081 "access_type": "ref", 2082 "index": "col_int_key", 2083 "rows": 2, 2084 "cost": 8.5395, 2085 "chosen": true 2086 }, 2087 { 2088 "rows_to_scan": 4, 2089 "access_type": "scan", 2090 "resulting_rows": 4, 2091 "cost": 16.841, 2092 "chosen": false 2093 } 2094 ] /* considered_access_paths */ 2095 } /* best_access_path */ 2096 }, 2097 { 2098 "table": "`t1` `table2`", 2099 "best_access_path": { 2100 "considered_access_paths": [ 2101 { 2102 "access_type": "ref", 2103 "index": "col_int_key", 2104 "rows": 2, 2105 "cost": 17.079, 2106 "chosen": true 2107 }, 2108 { 2109 "rows_to_scan": 4, 2110 "access_type": "scan", 2111 "resulting_rows": 4, 2112 "cost": 33.682, 2113 "chosen": false 2114 } 2115 ] /* considered_access_paths */ 2116 } /* best_access_path */ 2117 } 2118 ] /* tables */ 2119 } /* recalculate_access_paths_and_cost */, 2120 "cost": 28.838, 2121 "rows": 6, 2122 "chosen": true 2123 }, 2124 { 2125 "strategy": "MaterializeLookup", 2126 "cost": 15.233, 2127 "rows": 6, 2128 "duplicate_tables_left": false, 2129 "chosen": true 2130 }, 2131 { 2132 "strategy": "DuplicatesWeedout", 2133 "cost": 21.234, 2134 "rows": 6, 2135 "duplicate_tables_left": false, 2136 "chosen": false 2137 } 2138 ] /* semijoin_strategy_choice */, 2139 "chosen": true 2140 } 2141 ] /* rest_of_plan */ 2142 }, 2143 { 2144 "plan_prefix": [ 2145 "`where_subselect_20070`" 2146 ] /* plan_prefix */, 2147 "table": "`t1` `table2`", 2148 "best_access_path": { 2149 "considered_access_paths": [ 2150 { 2151 "access_type": "ref", 2152 "index": "col_int_key", 2153 "rows": 2, 2154 "cost": 8.5395, 2155 "chosen": true 2156 }, 2157 { 2158 "rows_to_scan": 4, 2159 "access_type": "scan", 2160 "using_join_cache": true, 2161 "buffers_needed": 1, 2162 "resulting_rows": 4, 2163 "cost": 6.8074, 2164 "chosen": true 2165 } 2166 ] /* considered_access_paths */ 2167 } /* best_access_path */, 2168 "condition_filtering_pct": 25, 2169 "rows_for_plan": 6, 2170 "cost_for_plan": 10.026, 2171 "semijoin_strategy_choice": [ 2172 ] /* semijoin_strategy_choice */, 2173 "rest_of_plan": [ 2174 { 2175 "plan_prefix": [ 2176 "`where_subselect_20070`", 2177 "`t1` `table2`" 2178 ] /* plan_prefix */, 2179 "table": "`t1` `table1`", 2180 "best_access_path": { 2181 "considered_access_paths": [ 2182 { 2183 "access_type": "ref", 2184 "index": "col_int_key", 2185 "rows": 2, 2186 "cost": 8.5395, 2187 "chosen": true 2188 }, 2189 { 2190 "rows_to_scan": 4, 2191 "access_type": "scan", 2192 "using_join_cache": true, 2193 "buffers_needed": 1, 2194 "resulting_rows": 4, 2195 "cost": 6.8077, 2196 "chosen": true 2197 } 2198 ] /* considered_access_paths */ 2199 } /* best_access_path */, 2200 "condition_filtering_pct": 25, 2201 "rows_for_plan": 6, 2202 "cost_for_plan": 16.834, 2203 "semijoin_strategy_choice": [ 2204 { 2205 "strategy": "FirstMatch", 2206 "recalculate_access_paths_and_cost": { 2207 "tables": [ 2208 { 2209 "table": "`t1` `table2`", 2210 "best_access_path": { 2211 "considered_access_paths": [ 2212 { 2213 "access_type": "ref", 2214 "index": "col_int_key", 2215 "rows": 2, 2216 "cost": 8.5395, 2217 "chosen": true 2218 }, 2219 { 2220 "rows_to_scan": 4, 2221 "access_type": "scan", 2222 "resulting_rows": 4, 2223 "cost": 16.841, 2224 "chosen": false 2225 } 2226 ] /* considered_access_paths */ 2227 } /* best_access_path */ 2228 }, 2229 { 2230 "table": "`t1` `table1`", 2231 "best_access_path": { 2232 "considered_access_paths": [ 2233 { 2234 "access_type": "ref", 2235 "index": "col_int_key", 2236 "rows": 2, 2237 "cost": 17.079, 2238 "chosen": true 2239 }, 2240 { 2241 "rows_to_scan": 4, 2242 "access_type": "scan", 2243 "resulting_rows": 4, 2244 "cost": 33.682, 2245 "chosen": false 2246 } 2247 ] /* considered_access_paths */ 2248 } /* best_access_path */ 2249 } 2250 ] /* tables */ 2251 } /* recalculate_access_paths_and_cost */, 2252 "cost": 28.838, 2253 "rows": 6, 2254 "chosen": true 2255 }, 2256 { 2257 "strategy": "MaterializeLookup", 2258 "cost": 15.233, 2259 "rows": 6, 2260 "duplicate_tables_left": false, 2261 "chosen": true 2262 }, 2263 { 2264 "strategy": "DuplicatesWeedout", 2265 "cost": 21.234, 2266 "rows": 6, 2267 "duplicate_tables_left": false, 2268 "chosen": false 2269 } 2270 ] /* semijoin_strategy_choice */, 2271 "pruned_by_cost": true 2272 } 2273 ] /* rest_of_plan */ 2274 } 2275 ] /* rest_of_plan */ 2276 }, 2277 { 2278 "plan_prefix": [ 2279 ] /* plan_prefix */, 2280 "table": "`t1` `table1`", 2281 "best_access_path": { 2282 "considered_access_paths": [ 2283 { 2284 "access_type": "ref", 2285 "index": "col_int_key", 2286 "usable": false, 2287 "chosen": false 2288 }, 2289 { 2290 "rows_to_scan": 4, 2291 "access_type": "scan", 2292 "resulting_rows": 4, 2293 "cost": 2.8068, 2294 "chosen": true 2295 } 2296 ] /* considered_access_paths */ 2297 } /* best_access_path */, 2298 "condition_filtering_pct": 100, 2299 "rows_for_plan": 4, 2300 "cost_for_plan": 2.8068, 2301 "semijoin_strategy_choice": [ 2302 ] /* semijoin_strategy_choice */, 2303 "rest_of_plan": [ 2304 { 2305 "plan_prefix": [ 2306 "`t1` `table1`" 2307 ] /* plan_prefix */, 2308 "table": "`where_subselect_20070`", 2309 "best_access_path": { 2310 "considered_access_paths": [ 2311 { 2312 "rows_to_scan": 6, 2313 "access_type": "scan", 2314 "using_join_cache": true, 2315 "buffers_needed": 1, 2316 "resulting_rows": 6, 2317 "cost": 6.8192, 2318 "chosen": true 2319 } 2320 ] /* considered_access_paths */ 2321 } /* best_access_path */, 2322 "condition_filtering_pct": 16.667, 2323 "rows_for_plan": 4, 2324 "cost_for_plan": 9.626, 2325 "semijoin_strategy_choice": [ 2326 ] /* semijoin_strategy_choice */, 2327 "rest_of_plan": [ 2328 { 2329 "plan_prefix": [ 2330 "`t1` `table1`", 2331 "`where_subselect_20070`" 2332 ] /* plan_prefix */, 2333 "table": "`t1` `table2`", 2334 "best_access_path": { 2335 "considered_access_paths": [ 2336 { 2337 "access_type": "ref", 2338 "index": "col_int_key", 2339 "rows": 2, 2340 "cost": 5.693, 2341 "chosen": true 2342 }, 2343 { 2344 "rows_to_scan": 4, 2345 "access_type": "scan", 2346 "using_join_cache": true, 2347 "buffers_needed": 1, 2348 "resulting_rows": 4, 2349 "cost": 5.2074, 2350 "chosen": true 2351 } 2352 ] /* considered_access_paths */ 2353 } /* best_access_path */, 2354 "condition_filtering_pct": 25, 2355 "rows_for_plan": 4, 2356 "cost_for_plan": 14.833, 2357 "semijoin_strategy_choice": [ 2358 { 2359 "strategy": "DuplicatesWeedout", 2360 "cost": 17.833, 2361 "rows": 1, 2362 "duplicate_tables_left": true, 2363 "chosen": true 2364 } 2365 ] /* semijoin_strategy_choice */, 2366 "pruned_by_cost": true 2367 } 2368 ] /* rest_of_plan */ 2369 }, 2370 { 2371 "plan_prefix": [ 2372 "`t1` `table1`" 2373 ] /* plan_prefix */, 2374 "table": "`t1` `table2`", 2375 "best_access_path": { 2376 "considered_access_paths": [ 2377 { 2378 "access_type": "ref", 2379 "index": "col_int_key", 2380 "rows": 2, 2381 "cost": 5.693, 2382 "chosen": true 2383 }, 2384 { 2385 "rows_to_scan": 4, 2386 "access_type": "scan", 2387 "using_join_cache": true, 2388 "buffers_needed": 1, 2389 "resulting_rows": 4, 2390 "cost": 5.207, 2391 "chosen": true 2392 } 2393 ] /* considered_access_paths */ 2394 } /* best_access_path */, 2395 "condition_filtering_pct": 25, 2396 "rows_for_plan": 4, 2397 "cost_for_plan": 8.0138, 2398 "semijoin_strategy_choice": [ 2399 { 2400 "strategy": "MaterializeScan", 2401 "choice": "deferred" 2402 } 2403 ] /* semijoin_strategy_choice */, 2404 "rest_of_plan": [ 2405 { 2406 "plan_prefix": [ 2407 "`t1` `table1`", 2408 "`t1` `table2`" 2409 ] /* plan_prefix */, 2410 "table": "`where_subselect_20070`", 2411 "best_access_path": { 2412 "considered_access_paths": [ 2413 { 2414 "rows_to_scan": 6, 2415 "access_type": "scan", 2416 "using_join_cache": true, 2417 "buffers_needed": 1, 2418 "resulting_rows": 6, 2419 "cost": 6.8194, 2420 "chosen": true 2421 } 2422 ] /* considered_access_paths */ 2423 } /* best_access_path */, 2424 "condition_filtering_pct": 16.667, 2425 "rows_for_plan": 4, 2426 "cost_for_plan": 14.833, 2427 "semijoin_strategy_choice": [ 2428 { 2429 "strategy": "LooseScan", 2430 "recalculate_access_paths_and_cost": { 2431 "tables": [ 2432 { 2433 "table": "`t1` `table1`", 2434 "best_access_path": { 2435 "considered_access_paths": [ 2436 { 2437 "access_type": "ref", 2438 "index": "col_int_key", 2439 "usable": false, 2440 "chosen": false 2441 }, 2442 { 2443 "rows_to_scan": 4, 2444 "access_type": "scan", 2445 "resulting_rows": 4, 2446 "cost": 2.8068, 2447 "chosen": true 2448 } 2449 ] /* considered_access_paths */ 2450 } /* best_access_path */, 2451 "unknown_key_1": { 2452 "searching_loose_scan_index": { 2453 "indexes": [ 2454 { 2455 "index": "col_int_key", 2456 "index_handles_needed_semijoin_equalities": false 2457 } 2458 ] /* indexes */ 2459 } /* searching_loose_scan_index */ 2460 } 2461 } 2462 ] /* tables */ 2463 } /* recalculate_access_paths_and_cost */, 2464 "chosen": false 2465 }, 2466 { 2467 "strategy": "MaterializeScan", 2468 "recalculate_access_paths_and_cost": { 2469 "tables": [ 2470 { 2471 "table": "`where_subselect_20070`", 2472 "best_access_path": { 2473 "considered_access_paths": [ 2474 { 2475 "rows_to_scan": 6, 2476 "access_type": "scan", 2477 "using_join_cache": true, 2478 "buffers_needed": 1, 2479 "resulting_rows": 6, 2480 "cost": 6.8194, 2481 "chosen": true 2482 } 2483 ] /* considered_access_paths */ 2484 } /* best_access_path */ 2485 } 2486 ] /* tables */ 2487 } /* recalculate_access_paths_and_cost */, 2488 "cost": 18.433, 2489 "rows": 1, 2490 "duplicate_tables_left": true, 2491 "chosen": true 2492 }, 2493 { 2494 "strategy": "DuplicatesWeedout", 2495 "cost": 17.833, 2496 "rows": 1, 2497 "duplicate_tables_left": false, 2498 "chosen": true 2499 } 2500 ] /* semijoin_strategy_choice */, 2501 "pruned_by_cost": true 2502 } 2503 ] /* rest_of_plan */ 2504 } 2505 ] /* rest_of_plan */ 2506 }, 2507 { 2508 "plan_prefix": [ 2509 ] /* plan_prefix */, 2510 "table": "`t1` `table2`", 2511 "best_access_path": { 2512 "considered_access_paths": [ 2513 { 2514 "access_type": "ref", 2515 "index": "col_int_key", 2516 "usable": false, 2517 "chosen": false 2518 }, 2519 { 2520 "rows_to_scan": 4, 2521 "access_type": "scan", 2522 "resulting_rows": 4, 2523 "cost": 2.8068, 2524 "chosen": true 2525 } 2526 ] /* considered_access_paths */ 2527 } /* best_access_path */, 2528 "condition_filtering_pct": 100, 2529 "rows_for_plan": 4, 2530 "cost_for_plan": 2.8068, 2531 "semijoin_strategy_choice": [ 2532 ] /* semijoin_strategy_choice */, 2533 "rest_of_plan": [ 2534 { 2535 "plan_prefix": [ 2536 "`t1` `table2`" 2537 ] /* plan_prefix */, 2538 "table": "`where_subselect_20070`", 2539 "best_access_path": { 2540 "considered_access_paths": [ 2541 { 2542 "rows_to_scan": 6, 2543 "access_type": "scan", 2544 "using_join_cache": true, 2545 "buffers_needed": 1, 2546 "resulting_rows": 6, 2547 "cost": 6.8192, 2548 "chosen": true 2549 } 2550 ] /* considered_access_paths */ 2551 } /* best_access_path */, 2552 "condition_filtering_pct": 16.667, 2553 "rows_for_plan": 4, 2554 "cost_for_plan": 9.626, 2555 "semijoin_strategy_choice": [ 2556 ] /* semijoin_strategy_choice */, 2557 "rest_of_plan": [ 2558 { 2559 "plan_prefix": [ 2560 "`t1` `table2`", 2561 "`where_subselect_20070`" 2562 ] /* plan_prefix */, 2563 "table": "`t1` `table1`", 2564 "best_access_path": { 2565 "considered_access_paths": [ 2566 { 2567 "access_type": "ref", 2568 "index": "col_int_key", 2569 "rows": 2, 2570 "cost": 5.693, 2571 "chosen": true 2572 }, 2573 { 2574 "rows_to_scan": 4, 2575 "access_type": "scan", 2576 "using_join_cache": true, 2577 "buffers_needed": 1, 2578 "resulting_rows": 4, 2579 "cost": 5.2074, 2580 "chosen": true 2581 } 2582 ] /* considered_access_paths */ 2583 } /* best_access_path */, 2584 "condition_filtering_pct": 25, 2585 "rows_for_plan": 4, 2586 "cost_for_plan": 14.833, 2587 "semijoin_strategy_choice": [ 2588 { 2589 "strategy": "DuplicatesWeedout", 2590 "cost": 17.833, 2591 "rows": 1, 2592 "duplicate_tables_left": true, 2593 "chosen": true 2594 } 2595 ] /* semijoin_strategy_choice */, 2596 "pruned_by_cost": true 2597 } 2598 ] /* rest_of_plan */ 2599 }, 2600 { 2601 "plan_prefix": [ 2602 "`t1` `table2`" 2603 ] /* plan_prefix */, 2604 "table": "`t1` `table1`", 2605 "best_access_path": { 2606 "considered_access_paths": [ 2607 { 2608 "access_type": "ref", 2609 "index": "col_int_key", 2610 "rows": 2, 2611 "cost": 5.693, 2612 "chosen": true 2613 }, 2614 { 2615 "rows_to_scan": 4, 2616 "access_type": "scan", 2617 "using_join_cache": true, 2618 "buffers_needed": 1, 2619 "resulting_rows": 4, 2620 "cost": 5.207, 2621 "chosen": true 2622 } 2623 ] /* considered_access_paths */ 2624 } /* best_access_path */, 2625 "condition_filtering_pct": 25, 2626 "rows_for_plan": 4, 2627 "cost_for_plan": 8.0138, 2628 "semijoin_strategy_choice": [ 2629 { 2630 "strategy": "MaterializeScan", 2631 "choice": "deferred" 2632 } 2633 ] /* semijoin_strategy_choice */, 2634 "rest_of_plan": [ 2635 { 2636 "plan_prefix": [ 2637 "`t1` `table2`", 2638 "`t1` `table1`" 2639 ] /* plan_prefix */, 2640 "table": "`where_subselect_20070`", 2641 "best_access_path": { 2642 "considered_access_paths": [ 2643 { 2644 "rows_to_scan": 6, 2645 "access_type": "scan", 2646 "using_join_cache": true, 2647 "buffers_needed": 1, 2648 "resulting_rows": 6, 2649 "cost": 6.8194, 2650 "chosen": true 2651 } 2652 ] /* considered_access_paths */ 2653 } /* best_access_path */, 2654 "condition_filtering_pct": 16.667, 2655 "rows_for_plan": 4, 2656 "cost_for_plan": 14.833, 2657 "semijoin_strategy_choice": [ 2658 { 2659 "strategy": "LooseScan", 2660 "recalculate_access_paths_and_cost": { 2661 "tables": [ 2662 { 2663 "table": "`t1` `table2`", 2664 "best_access_path": { 2665 "considered_access_paths": [ 2666 { 2667 "access_type": "ref", 2668 "index": "col_int_key", 2669 "usable": false, 2670 "chosen": false 2671 }, 2672 { 2673 "rows_to_scan": 4, 2674 "access_type": "scan", 2675 "resulting_rows": 4, 2676 "cost": 2.8068, 2677 "chosen": true 2678 } 2679 ] /* considered_access_paths */ 2680 } /* best_access_path */, 2681 "unknown_key_2": { 2682 "searching_loose_scan_index": { 2683 "indexes": [ 2684 { 2685 "index": "col_int_key", 2686 "covering_scan": { 2687 "cost": 1.0698, 2688 "chosen": true 2689 } /* covering_scan */ 2690 } 2691 ] /* indexes */ 2692 } /* searching_loose_scan_index */ 2693 } 2694 }, 2695 { 2696 "table": "`t1` `table1`", 2697 "best_access_path": { 2698 "considered_access_paths": [ 2699 { 2700 "access_type": "ref", 2701 "index": "col_int_key", 2702 "rows": 2, 2703 "cost": 5.693, 2704 "chosen": true 2705 }, 2706 { 2707 "rows_to_scan": 4, 2708 "access_type": "scan", 2709 "resulting_rows": 4, 2710 "cost": 11.227, 2711 "chosen": false 2712 } 2713 ] /* considered_access_paths */ 2714 } /* best_access_path */ 2715 }, 2716 { 2717 "table": "`where_subselect_20070`", 2718 "best_access_path": { 2719 "considered_access_paths": [ 2720 { 2721 "rows_to_scan": 6, 2722 "access_type": "scan", 2723 "using_join_cache": true, 2724 "buffers_needed": 1, 2725 "resulting_rows": 6, 2726 "cost": 11.62, 2727 "chosen": true 2728 } 2729 ] /* considered_access_paths */ 2730 } /* best_access_path */ 2731 } 2732 ] /* tables */ 2733 } /* recalculate_access_paths_and_cost */, 2734 "cost": 19.182, 2735 "rows": 1, 2736 "chosen": true 2737 }, 2738 { 2739 "strategy": "MaterializeScan", 2740 "recalculate_access_paths_and_cost": { 2741 "tables": [ 2742 { 2743 "table": "`where_subselect_20070`", 2744 "best_access_path": { 2745 "considered_access_paths": [ 2746 { 2747 "rows_to_scan": 6, 2748 "access_type": "scan", 2749 "using_join_cache": true, 2750 "buffers_needed": 1, 2751 "resulting_rows": 6, 2752 "cost": 6.8194, 2753 "chosen": true 2754 } 2755 ] /* considered_access_paths */ 2756 } /* best_access_path */ 2757 } 2758 ] /* tables */ 2759 } /* recalculate_access_paths_and_cost */, 2760 "cost": 18.433, 2761 "rows": 1, 2762 "duplicate_tables_left": false, 2763 "chosen": true 2764 }, 2765 { 2766 "strategy": "DuplicatesWeedout", 2767 "cost": 17.833, 2768 "rows": 1, 2769 "duplicate_tables_left": false, 2770 "chosen": true 2771 } 2772 ] /* semijoin_strategy_choice */, 2773 "pruned_by_cost": true 2774 } 2775 ] /* rest_of_plan */ 2776 } 2777 ] /* rest_of_plan */ 2778 }, 2779 { 2780 "final_semijoin_strategy": "MaterializeLookup" 2781 } 2782 ] /* considered_execution_plans */ 2783 }, 2784 { 2785 "creating_tmp_table": { 2786 "tmp_table_info": { 2787 "row_length": 13, 2788 "key_length": 14, 2789 "unique_constraint": false, 2790 "location": "memory (heap)", 2791 "row_limit_estimate": 80659 2792 } /* tmp_table_info */ 2793 } /* creating_tmp_table */ 2794 }, 2795 { 2796 "subselect_execution": { 2797 "select#": 2, 2798 "steps": [ 2799 ] /* steps */ 2800 } /* subselect_execution */ 2801 }, 2802 { 2803 "attaching_conditions_to_tables": { 2804 "original_condition": "((`<subquery3>`.`field1` = `where_subselect_20070`.`field1`) and (`table2`.`col_int_key` = `table1`.`col_int_key`))", 2805 "attached_conditions_computation": [ 2806 { 2807 "table": "`t1` `table2`", 2808 "rechecking_index_usage": { 2809 "recheck_reason": "not_first_table", 2810 "range_analysis": { 2811 "table_scan": { 2812 "rows": 4, 2813 "cost": 4.9068 2814 } /* table_scan */, 2815 "potential_range_indexes": [ 2816 { 2817 "index": "col_int_key", 2818 "usable": true, 2819 "key_parts": [ 2820 "col_int_key" 2821 ] /* key_parts */ 2822 } 2823 ] /* potential_range_indexes */, 2824 "best_covering_index_scan": { 2825 "index": "col_int_key", 2826 "cost": 1.8698, 2827 "chosen": true 2828 } /* best_covering_index_scan */, 2829 "setup_range_conditions": [ 2830 ] /* setup_range_conditions */, 2831 "group_index_range": { 2832 "chosen": false, 2833 "cause": "not_single_table" 2834 } /* group_index_range */, 2835 "analyzing_range_alternatives": { 2836 "range_scan_alternatives": [ 2837 { 2838 "index": "col_int_key", 2839 "chosen": false, 2840 "cause": "depends_on_unread_values" 2841 } 2842 ] /* range_scan_alternatives */, 2843 "analyzing_roworder_intersect": { 2844 "usable": false, 2845 "cause": "too_few_roworder_scans" 2846 } /* analyzing_roworder_intersect */ 2847 } /* analyzing_range_alternatives */ 2848 } /* range_analysis */ 2849 } /* rechecking_index_usage */ 2850 } 2851 ] /* attached_conditions_computation */, 2852 "attached_conditions_summary": [ 2853 { 2854 "table": "`where_subselect_20070`", 2855 "attached": "(`where_subselect_20070`.`field1` is not null)" 2856 }, 2857 { 2858 "table": "``.`<subquery3>`", 2859 "attached": null 2860 }, 2861 { 2862 "table": "`t1` `table1`", 2863 "attached": null 2864 }, 2865 { 2866 "table": "`t1` `table2`", 2867 "attached": "(`table2`.`col_int_key` = `table1`.`col_int_key`)" 2868 } 2869 ] /* attached_conditions_summary */ 2870 } /* attaching_conditions_to_tables */ 2871 }, 2872 { 2873 "refine_plan": [ 2874 { 2875 "table": "`where_subselect_20070`" 2876 }, 2877 { 2878 "table": "``.`<subquery3>`" 2879 }, 2880 { 2881 "table": "`t1` `table1`" 2882 }, 2883 { 2884 "table": "`t1` `table2`" 2885 } 2886 ] /* refine_plan */ 2887 } 2888 ] /* steps */ 2889 } /* join_optimization */ 2890 }, 2891 { 2892 "join_execution": { 2893 "select#": 1, 2894 "steps": [ 2895 { 2896 "subselect_execution": { 2897 "select#": 4, 2898 "steps": [ 2899 ] /* steps */ 2900 } /* subselect_execution */ 2901 }, 2902 { 2903 "subselect_execution": { 2904 "select#": 4, 2905 "steps": [ 2906 ] /* steps */ 2907 } /* subselect_execution */ 2908 }, 2909 { 2910 "subselect_execution": { 2911 "select#": 4, 2912 "steps": [ 2913 ] /* steps */ 2914 } /* subselect_execution */ 2915 }, 2916 { 2917 "subselect_execution": { 2918 "select#": 4, 2919 "steps": [ 2920 ] /* steps */ 2921 } /* subselect_execution */ 2922 }, 2923 { 2924 "subselect_execution": { 2925 "select#": 4, 2926 "steps": [ 2927 ] /* steps */ 2928 } /* subselect_execution */ 2929 }, 2930 { 2931 "subselect_execution": { 2932 "select#": 4, 2933 "steps": [ 2934 ] /* steps */ 2935 } /* subselect_execution */ 2936 }, 2937 { 2938 "subselect_execution": { 2939 "select#": 4, 2940 "steps": [ 2941 ] /* steps */ 2942 } /* subselect_execution */ 2943 }, 2944 { 2945 "subselect_execution": { 2946 "select#": 4, 2947 "steps": [ 2948 ] /* steps */ 2949 } /* subselect_execution */ 2950 }, 2951 { 2952 "subselect_execution": { 2953 "select#": 4, 2954 "steps": [ 2955 ] /* steps */ 2956 } /* subselect_execution */ 2957 }, 2958 { 2959 "subselect_execution": { 2960 "select#": 4, 2961 "steps": [ 2962 ] /* steps */ 2963 } /* subselect_execution */ 2964 }, 2965 { 2966 "subselect_execution": { 2967 "select#": 4, 2968 "steps": [ 2969 ] /* steps */ 2970 } /* subselect_execution */ 2971 }, 2972 { 2973 "subselect_execution": { 2974 "select#": 4, 2975 "steps": [ 2976 ] /* steps */ 2977 } /* subselect_execution */ 2978 } 2979 ] /* steps */ 2980 } /* join_execution */ 2981 } 2982 ] /* steps */ 2983} 0 0 2984DROP TABLE where_subselect_20070,t1; 2985# 2986# Bug#13430443 - ASSERTION `NEW_TYPE[0] != 'U'' FAILED. WHEN 2987# OPTIMIZER_TRACE IS ENABLED 2988# 2989CREATE TABLE t1 2990(a INT,b INT,c INT, KEY(a),KEY (a,c)) ENGINE=INNODB; 2991SELECT 1 FROM t1 WHERE 1 LIKE 2992(SELECT a FROM t1 WHERE a = 1 ORDER BY c); 29931 2994SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; 2995QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES 2996SELECT 1 FROM t1 WHERE 1 LIKE 2997(SELECT a FROM t1 WHERE a = 1 ORDER BY c) { 2998 "steps": [ 2999 { 3000 "join_preparation": { 3001 "select#": 1, 3002 "steps": [ 3003 { 3004 "join_preparation": { 3005 "select#": 2, 3006 "steps": [ 3007 { 3008 "expanded_query": "/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1) order by `t1`.`c`" 3009 } 3010 ] /* steps */ 3011 } /* join_preparation */ 3012 }, 3013 { 3014 "expanded_query": "/* select#1 */ select 1 AS `1` from `t1` where (1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1) order by `t1`.`c`))" 3015 } 3016 ] /* steps */ 3017 } /* join_preparation */ 3018 }, 3019 { 3020 "join_optimization": { 3021 "select#": 1, 3022 "steps": [ 3023 { 3024 "condition_processing": { 3025 "condition": "WHERE", 3026 "original_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1) order by `t1`.`c`))", 3027 "steps": [ 3028 { 3029 "transformation": "equality_propagation", 3030 "subselect_evaluation": [ 3031 ] /* subselect_evaluation */, 3032 "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1) order by `t1`.`c`))" 3033 }, 3034 { 3035 "transformation": "constant_propagation", 3036 "subselect_evaluation": [ 3037 ] /* subselect_evaluation */, 3038 "resulting_condition": "(1 like (/* select#2 */ select `t1`.`a` from `t1` where (`t1`.`a` = 1) order by `t1`.`c`))" 3039 }, 3040 { 3041 "transformation": "trivial_condition_removal", 3042 "subselect_evaluation": [ 3043 { 3044 "subselect_execution": { 3045 "select#": 2, 3046 "steps": [ 3047 { 3048 "join_optimization": { 3049 "select#": 2, 3050 "steps": [ 3051 { 3052 "condition_processing": { 3053 "condition": "WHERE", 3054 "original_condition": "(`t1`.`a` = 1)", 3055 "steps": [ 3056 { 3057 "transformation": "equality_propagation", 3058 "resulting_condition": "multiple equal(1, `t1`.`a`)" 3059 }, 3060 { 3061 "transformation": "constant_propagation", 3062 "resulting_condition": "multiple equal(1, `t1`.`a`)" 3063 }, 3064 { 3065 "transformation": "trivial_condition_removal", 3066 "resulting_condition": "multiple equal(1, `t1`.`a`)" 3067 } 3068 ] /* steps */ 3069 } /* condition_processing */ 3070 }, 3071 { 3072 "substitute_generated_columns": { 3073 } /* substitute_generated_columns */ 3074 }, 3075 { 3076 "table_dependencies": [ 3077 { 3078 "table": "`t1`", 3079 "row_may_be_null": false, 3080 "map_bit": 0, 3081 "depends_on_map_bits": [ 3082 ] /* depends_on_map_bits */ 3083 } 3084 ] /* table_dependencies */ 3085 }, 3086 { 3087 "ref_optimizer_key_uses": [ 3088 { 3089 "table": "`t1`", 3090 "field": "a", 3091 "equals": "1", 3092 "null_rejecting": false 3093 }, 3094 { 3095 "table": "`t1`", 3096 "field": "a", 3097 "equals": "1", 3098 "null_rejecting": false 3099 } 3100 ] /* ref_optimizer_key_uses */ 3101 }, 3102 { 3103 "rows_estimation": [ 3104 { 3105 "table": "`t1`", 3106 "range_analysis": { 3107 "table_scan": { 3108 "rows": 1, 3109 "cost": 3.3 3110 } /* table_scan */, 3111 "potential_range_indexes": [ 3112 { 3113 "index": "a", 3114 "usable": true, 3115 "key_parts": [ 3116 "a" 3117 ] /* key_parts */ 3118 }, 3119 { 3120 "index": "a_2", 3121 "usable": true, 3122 "key_parts": [ 3123 "a", 3124 "c" 3125 ] /* key_parts */ 3126 } 3127 ] /* potential_range_indexes */, 3128 "best_covering_index_scan": { 3129 "index": "a_2", 3130 "cost": 1.2, 3131 "chosen": true 3132 } /* best_covering_index_scan */, 3133 "setup_range_conditions": [ 3134 ] /* setup_range_conditions */, 3135 "group_index_range": { 3136 "chosen": false, 3137 "cause": "not_group_by_or_distinct" 3138 } /* group_index_range */, 3139 "analyzing_range_alternatives": { 3140 "range_scan_alternatives": [ 3141 { 3142 "index": "a", 3143 "ranges": [ 3144 "1 <= a <= 1" 3145 ] /* ranges */, 3146 "index_dives_for_eq_ranges": true, 3147 "rowid_ordered": true, 3148 "using_mrr": true, 3149 "index_only": false, 3150 "rows": 1, 3151 "cost": 2.2, 3152 "chosen": false, 3153 "cause": "cost" 3154 }, 3155 { 3156 "index": "a_2", 3157 "ranges": [ 3158 "1 <= a <= 1" 3159 ] /* ranges */, 3160 "index_dives_for_eq_ranges": true, 3161 "rowid_ordered": false, 3162 "using_mrr": false, 3163 "index_only": true, 3164 "rows": 1, 3165 "cost": 1.21, 3166 "chosen": false, 3167 "cause": "cost" 3168 } 3169 ] /* range_scan_alternatives */, 3170 "analyzing_roworder_intersect": { 3171 "usable": false, 3172 "cause": "too_few_roworder_scans" 3173 } /* analyzing_roworder_intersect */ 3174 } /* analyzing_range_alternatives */ 3175 } /* range_analysis */ 3176 } 3177 ] /* rows_estimation */ 3178 }, 3179 { 3180 "considered_execution_plans": [ 3181 { 3182 "plan_prefix": [ 3183 ] /* plan_prefix */, 3184 "table": "`t1`", 3185 "best_access_path": { 3186 "considered_access_paths": [ 3187 { 3188 "access_type": "ref", 3189 "index": "a", 3190 "rows": 1, 3191 "cost": 1.2, 3192 "chosen": true 3193 }, 3194 { 3195 "access_type": "ref", 3196 "index": "a_2", 3197 "rows": 1, 3198 "cost": 1.2, 3199 "chosen": false 3200 }, 3201 { 3202 "access_type": "scan", 3203 "chosen": false, 3204 "cause": "covering_index_better_than_full_scan" 3205 } 3206 ] /* considered_access_paths */ 3207 } /* best_access_path */, 3208 "condition_filtering_pct": 100, 3209 "rows_for_plan": 1, 3210 "cost_for_plan": 1.2, 3211 "chosen": true 3212 } 3213 ] /* considered_execution_plans */ 3214 }, 3215 { 3216 "attaching_conditions_to_tables": { 3217 "original_condition": "(`t1`.`a` = 1)", 3218 "attached_conditions_computation": [ 3219 ] /* attached_conditions_computation */, 3220 "attached_conditions_summary": [ 3221 { 3222 "table": "`t1`", 3223 "attached": null 3224 } 3225 ] /* attached_conditions_summary */ 3226 } /* attaching_conditions_to_tables */ 3227 }, 3228 { 3229 "clause_processing": { 3230 "clause": "ORDER BY", 3231 "original_clause": "`t1`.`c`", 3232 "items": [ 3233 { 3234 "item": "`t1`.`c`" 3235 } 3236 ] /* items */, 3237 "resulting_clause_is_simple": true, 3238 "resulting_clause": "`t1`.`c`" 3239 } /* clause_processing */ 3240 }, 3241 { 3242 "added_back_ref_condition": "((`t1`.`a` <=> 1))" 3243 }, 3244 { 3245 "reconsidering_access_paths_for_index_ordering": { 3246 "clause": "ORDER BY", 3247 "steps": [ 3248 ] /* steps */, 3249 "index_order_summary": { 3250 "table": "`t1`", 3251 "index_provides_order": true, 3252 "order_direction": "asc", 3253 "index": "a_2", 3254 "plan_changed": true, 3255 "access_type": "ref" 3256 } /* index_order_summary */ 3257 } /* reconsidering_access_paths_for_index_ordering */ 3258 }, 3259 { 3260 "refine_plan": [ 3261 { 3262 "table": "`t1`" 3263 } 3264 ] /* refine_plan */ 3265 } 3266 ] /* steps */ 3267 } /* join_optimization */ 3268 }, 3269 { 3270 "join_execution": { 3271 "select#": 2, 3272 "steps": [ 3273 ] /* steps */ 3274 } /* join_execution */ 3275 } 3276 ] /* steps */ 3277 } /* subselect_execution */ 3278 } 3279 ] /* subselect_evaluation */, 3280 "resulting_condition": null 3281 } 3282 ] /* steps */ 3283 } /* condition_processing */ 3284 } 3285 ] /* steps */, 3286 "empty_result": { 3287 "cause": "Impossible WHERE" 3288 } /* empty_result */ 3289 } /* join_optimization */ 3290 }, 3291 { 3292 "join_execution": { 3293 "select#": 1, 3294 "steps": [ 3295 ] /* steps */ 3296 } /* join_execution */ 3297 } 3298 ] /* steps */ 3299} 0 0 3300DROP TABLE t1; 3301# 3302# Bug #18346750 OPTIMIZER_TRACE & DBUG_PRINT CRASH IN ST_SELECT_LEX::PRINT 3303# 3304CREATE TABLE t1 (a INT, PRIMARY KEY (a)) 3305PARTITION BY KEY (a) PARTITIONS 2; 3306Warnings: 3307Warning 1287 The partition engine, used by table 'test.t1', is deprecated and will be removed in a future release. Please use native partitioning instead. 3308INSERT INTO t1 VALUES (1),(2); 3309Warnings: 3310Warning 1287 The partition engine, used by table 'test.t1', is deprecated and will be removed in a future release. Please use native partitioning instead. 3311SELECT 1 FROM t1 ,t1 w 3312WHERE t1.a <=> (SELECT 22 FROM t1 GROUP BY (SELECT 1 FROM t1)); 3313ERROR 21000: Subquery returns more than 1 row 3314SELECT TRACE LIKE "%select had some error%" FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; 3315TRACE LIKE "%select had some error%" 33160 3317DROP TABLE t1; 3318# 3319# Bug#18791851 CRASH IN ST_SELECT_LEX::PRINT WITH OPTIMIZER_TRACE ON SUBQUERY 3320# 3321CREATE TABLE t1 ( 3322pk INT NOT NULL, 3323col_int_nokey INT, 3324col_int_key INT, 3325col_time_key time, 3326col_varchar_key VARCHAR(1), 3327col_varchar_nokey VARCHAR(1), 3328PRIMARY KEY (pk), 3329KEY col_varchar_key (col_varchar_key,col_int_key) 3330); 3331CREATE TABLE t2 ( 3332pk INT NOT NULL, 3333col_int_nokey INT, 3334col_int_key INT, 3335col_varchar_key VARCHAR(1), 3336col_varchar_nokey VARCHAR(1), 3337PRIMARY KEY (pk), 3338KEY col_varchar_key (col_varchar_key,col_int_key) 3339); 3340CREATE TABLE t3 ( 3341pk INT NOT NULL, 3342col_int_nokey INT, 3343col_int_key INT, 3344col_varchar_key VARCHAR(1), 3345col_varchar_nokey VARCHAR(1), 3346PRIMARY KEY (pk), 3347KEY col_varchar_key (col_varchar_key,col_int_key) 3348); 3349CREATE TABLE t4 ( 3350pk INT NOT NULL, 3351col_int_nokey INT, 3352col_int_key INT, 3353col_time_key time, 3354col_varchar_key VARCHAR(1), 3355col_varchar_nokey VARCHAR(1), 3356PRIMARY KEY (pk), 3357KEY col_varchar_key (col_varchar_key,col_int_key) 3358); 3359SELECT alias1.col_int_nokey AS field1, 3360alias2.col_varchar_key AS field2, 3361alias1.col_time_key AS field3, 3362MIN( alias1.col_int_nokey ) AS field4 3363FROM ( 3364( 3365SELECT SQ1_alias1.* 3366FROM ( t1 AS SQ1_alias1, t2 AS SQ1_alias2 ) 3367) AS alias1, 3368t4 AS alias2 3369) 3370WHERE 3371EXISTS ( 3372SELECT DISTINCT SQ2_alias2.col_varchar_nokey AS SQ2_field1 3373FROM t2 AS SQ2_alias1 3374INNER JOIN (t4 AS SQ2_alias2 3375INNER JOIN t3 AS SQ2_alias3 3376ON SQ2_alias3.pk = SQ2_alias2.pk) 3377ON SQ2_alias3.col_varchar_key = SQ2_alias2.col_varchar_nokey 3378) 3379AND alias1.col_int_key = alias2.pk 3380HAVING alias1.col_int_nokey IN ( SELECT 2 FROM DUAL ) ; 3381field1 field2 field3 field4 3382DROP TABLE t1,t2,t3,t4; 3383CREATE TABLE t1(a INT); 3384SET @a:=(SELECT ROW(1, 2)= 3385ROW((SELECT 1 FROM t1 LEFT JOIN t1 t2 ON 1 3386HAVING 3 IN (SELECT 2 FROM DUAL)), 33871)); 3388DROP TABLE t1; 3389# 3390# Bug #18945693 CRASH IN PRINT_TABLE_ARRAY AT SQL/SQL_LEX.CC ON 2ND EXEC OF PREPARED STATEMENT 3391# 3392CREATE TABLE t1 ( 3393pk INT NOT NULL, 3394col_int_nokey INT, 3395col_int_key INT, 3396col_varchar_key VARCHAR(1), 3397col_varchar_nokey VARCHAR(1) 3398); 3399INSERT INTO t1 VALUES (13,7,3,'y','y'),(14,0,4,'c','c'); 3400CREATE TABLE t2 ( 3401pk INT NOT NULL, 3402col_int_nokey INT, 3403col_int_key INT, 3404col_varchar_key VARCHAR(1), 3405col_varchar_nokey VARCHAR(1) 3406); 3407INSERT INTO t2 VALUES (20,9,8,'e','e'); 3408CREATE TABLE t3 ( 3409pk INT NOT NULL, 3410col_int_nokey INT, 3411col_int_key INT, 3412col_varchar_key VARCHAR(1), 3413col_varchar_nokey VARCHAR(1) 3414); 3415INSERT INTO t3 VALUES (1,1,7,'k','k'); 3416PREPARE prep_stmt FROM " 3417SELECT 3418 alias1.col_varchar_nokey AS field1, 3419 MAX(alias1.pk) AS field2 3420FROM t3 AS alias1 3421GROUP BY field1 3422HAVING 3423 1 > ( 3424 SELECT MAX(SQ4_alias1.col_varchar_nokey) 3425 FROM t1 AS SQ4_alias1 3426 RIGHT OUTER JOIN 3427 ( 3428 t2 AS SQ4_alias2 3429 JOIN t1 AS SQ4_alias3 3430 ON SQ4_alias3.col_int_key = SQ4_alias2.col_int_nokey 3431 ) 3432 ON SQ4_alias3.pk = SQ4_alias2.col_int_nokey 3433 ) 3434"; 3435EXECUTE prep_stmt; 3436field1 field2 3437EXECUTE prep_stmt; 3438field1 field2 3439DROP TABLE t1,t2,t3; 3440# 3441# Bug#19063289 CRASH IN PRINT_TABLE_ARRAY ON 2ND EXECUTION OF PS WITH SUBQUERY AND VIEW 3442# 3443CREATE TABLE B ( 3444pk INTEGER, 3445col_int_key INTEGER, 3446col_varchar_nokey VARCHAR(1) 3447); 3448CREATE TABLE C ( 3449col_int_nokey INTEGER, 3450col_int_key INTEGER, 3451col_varchar_key VARCHAR(1), 3452col_varchar_nokey VARCHAR(1) 3453) ; 3454CREATE TABLE CC ( 3455pk INTEGER, 3456col_int_key INTEGER 3457) ENGINE=MYISAM; 3458INSERT INTO CC VALUES (1, 0),(2, 7); 3459PREPARE stmt FROM " 3460SELECT 3461alias1.col_int_key AS field1 , 3462COUNT(alias1.pk) AS field2 3463FROM 3464CC AS alias1 3465GROUP BY field1 3466HAVING 3467alias1.col_int_key > 3468 ( 3469 SELECT 3470 MAX( SQ2_alias2.col_int_key ) AS SQ2_field1 3471 FROM 3472 C AS SQ2_alias1 LEFT JOIN 3473 ( B AS SQ2_alias2 INNER JOIN C AS SQ2_alias3 3474 ON 1) 3475 ON 1 3476 ) 3477OR field2 < 2 3478"; 3479EXECUTE stmt; 3480field1 field2 34810 1 34827 1 3483EXECUTE stmt; 3484field1 field2 34850 1 34867 1 3487DROP TABLE B,C,CC; 3488# 3489# Bug #23259872: OPTIMIZER CHOOSES TO USE NON PRIMARY 3490# INDEX, EVEN THOUGH COST IS HIGHER 3491# 3492CREATE TABLE t1 ( 3493a TINYTEXT NOT NULL, 3494b TINYINT(3) UNSIGNED NOT NULL, 3495PRIMARY KEY (a(32),b), 3496KEY b_idx(b) 3497) ENGINE=INNODB; 3498INSERT INTO t1 VALUES ('a',1),('a',2),('a',3),('b',1),('c',1),('c',4),('e',2); 3499ANALYZE TABLE t1; 3500Table Op Msg_type Msg_text 3501test.t1 analyze status OK 3502SET @optimizer_switch_saved=@@session.optimizer_switch; 3503SET @@session.optimizer_switch=default; 3504SELECT COUNT(*) FROM t1; 3505COUNT(*) 35067 3507EXPLAIN SELECT * FROM t1 WHERE a IN ('a', 'b') AND b = 2; 3508id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35091 SIMPLE t1 NULL range PRIMARY,b_idx b_idx 35 NULL 2 100.00 Using index condition; Using where 3510Warnings: 3511Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` in ('a','b'))) 3512SELECT TRACE into @trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; 3513SELECT @trace RLIKE "rerunning_range_optimizer_for_single_index"; 3514@trace RLIKE "rerunning_range_optimizer_for_single_index" 35151 3516SET @@session.optimizer_switch=@optimizer_switch_saved; 3517DROP TABLE t1; 3518# 3519# Bug #23227428: SQL PLAN IS NOT ACCORDING WITH OPTIMIZER_TRACE 3520# 3521CREATE TABLE t1(c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 3522c2 CHAR(12)) ENGINE=INNODB; 3523ANALYZE TABLE t1; 3524Table Op Msg_type Msg_text 3525test.t1 analyze status OK 3526EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1; 3527id select_type table partitions type possible_keys key key_len ref rows filtered Extra 35281 SIMPLE t1 NULL index NULL PRIMARY 4 NULL 1 100.00 NULL 3529Warnings: 3530Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2` from `test`.`t1` order by `test`.`t1`.`c1` desc limit 1 3531SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; 3532QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES 3533EXPLAIN SELECT c1, c2 FROM t1 ORDER BY c1 DESC LIMIT 1 { 3534 "steps": [ 3535 { 3536 "join_preparation": { 3537 "select#": 1, 3538 "steps": [ 3539 { 3540 "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t1`.`c2` AS `c2` from `t1` order by `t1`.`c1` desc limit 1" 3541 } 3542 ] /* steps */ 3543 } /* join_preparation */ 3544 }, 3545 { 3546 "join_optimization": { 3547 "select#": 1, 3548 "steps": [ 3549 { 3550 "substitute_generated_columns": { 3551 } /* substitute_generated_columns */ 3552 }, 3553 { 3554 "table_dependencies": [ 3555 { 3556 "table": "`t1`", 3557 "row_may_be_null": false, 3558 "map_bit": 0, 3559 "depends_on_map_bits": [ 3560 ] /* depends_on_map_bits */ 3561 } 3562 ] /* table_dependencies */ 3563 }, 3564 { 3565 "rows_estimation": [ 3566 { 3567 "table": "`t1`", 3568 "table_scan": { 3569 "rows": 1000, 3570 "cost": 1 3571 } /* table_scan */ 3572 } 3573 ] /* rows_estimation */ 3574 }, 3575 { 3576 "considered_execution_plans": [ 3577 { 3578 "plan_prefix": [ 3579 ] /* plan_prefix */, 3580 "table": "`t1`", 3581 "best_access_path": { 3582 "considered_access_paths": [ 3583 { 3584 "rows_to_scan": 1000, 3585 "access_type": "scan", 3586 "resulting_rows": 1000, 3587 "cost": 201, 3588 "chosen": true 3589 } 3590 ] /* considered_access_paths */ 3591 } /* best_access_path */, 3592 "condition_filtering_pct": 100, 3593 "rows_for_plan": 1000, 3594 "cost_for_plan": 201, 3595 "chosen": true 3596 } 3597 ] /* considered_execution_plans */ 3598 }, 3599 { 3600 "attaching_conditions_to_tables": { 3601 "original_condition": null, 3602 "attached_conditions_computation": [ 3603 ] /* attached_conditions_computation */, 3604 "attached_conditions_summary": [ 3605 { 3606 "table": "`t1`", 3607 "attached": null 3608 } 3609 ] /* attached_conditions_summary */ 3610 } /* attaching_conditions_to_tables */ 3611 }, 3612 { 3613 "clause_processing": { 3614 "clause": "ORDER BY", 3615 "original_clause": "`t1`.`c1` desc", 3616 "items": [ 3617 { 3618 "item": "`t1`.`c1`" 3619 } 3620 ] /* items */, 3621 "resulting_clause_is_simple": true, 3622 "resulting_clause": "`t1`.`c1` desc" 3623 } /* clause_processing */ 3624 }, 3625 { 3626 "reconsidering_access_paths_for_index_ordering": { 3627 "clause": "ORDER BY", 3628 "steps": [ 3629 ] /* steps */, 3630 "index_order_summary": { 3631 "table": "`t1`", 3632 "index_provides_order": true, 3633 "order_direction": "desc", 3634 "index": "PRIMARY", 3635 "plan_changed": true, 3636 "access_type": "index" 3637 } /* index_order_summary */ 3638 } /* reconsidering_access_paths_for_index_ordering */ 3639 }, 3640 { 3641 "refine_plan": [ 3642 { 3643 "table": "`t1`" 3644 } 3645 ] /* refine_plan */ 3646 } 3647 ] /* steps */ 3648 } /* join_optimization */ 3649 }, 3650 { 3651 "join_explain": { 3652 "select#": 1, 3653 "steps": [ 3654 ] /* steps */ 3655 } /* join_explain */ 3656 } 3657 ] /* steps */ 3658} 0 0 3659DROP TABLE t1; 3660