Debian Codegraph @

mysql-test/suite/opt_trace/r/general_no_prot_all.result

raw
1 set optimizer_switch='semijoin=on,materialization=on,firstmatch=on,loosescan=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=off';
2 select * from information_schema.OPTIMIZER_TRACE;
3 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
4 set optimizer_trace_max_mem_size=1048576;
5 set @@session.optimizer_trace="enabled=on";
6 select * from information_schema.OPTIMIZER_TRACE;
7 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8 CREATE TABLE t5 (c int);
9 INSERT INTO t5 VALUES (NULL);
10 CREATE TABLE t6 (d int , KEY (d));
11 INSERT INTO t6 VALUES (NULL),(NULL);
12 SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 ;
13 RESULT
14 NULL
15 select * from information_schema.OPTIMIZER_TRACE;
16 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
17 SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 {
18 "steps": [
19 {
20 "join_preparation": {
21 "select#": 1,
22 "steps": [
23 {
24 "join_preparation": {
25 "select#": 2,
26 "steps": [
27 {
28 "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)"
29 }
30 ]
31 }
32 },
33 {
34 "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)) AS `RESULT` from `t5`"
35 }
36 ]
37 }
38 },
39 {
40 "join_optimization": {
41 "select#": 1,
42 "steps": [
43 {
44 "table_dependencies": [
45 {
46 "table": "`t5`",
47 "row_may_be_null": false,
48 "map_bit": 0,
49 "depends_on_map_bits": [
50 ]
51 }
52 ]
53 },
54 {
55 "rows_estimation": [
56 {
57 "table": "`t5`",
58 "rows": 1,
59 "cost": 1,
60 "table_type": "system",
61 "empty": false
62 }
63 ]
64 },
65 {
66 "attaching_conditions_to_tables": {
67 "original_condition": null,
68 "attached_conditions_computation": [
69 ],
70 "attached_conditions_summary": [
71 ]
72 }
73 },
74 {
75 "refine_plan": [
76 ]
77 }
78 ]
79 }
80 },
81 {
82 "join_optimization": {
83 "select#": 2,
84 "steps": [
85 {
86 "condition_processing": {
87 "condition": "WHERE",
88 "original_condition": "(`t6`.`d` = NULL)",
89 "steps": [
90 {
91 "transformation": "equality_propagation",
92 "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
93 },
94 {
95 "transformation": "constant_propagation",
96 "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
97 },
98 {
99 "transformation": "trivial_condition_removal",
100 "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
101 }
102 ]
103 }
104 },
105 {
106 "substitute_generated_columns": {
107 }
108 },
109 {
110 "table_dependencies": [
111 {
112 "table": "`t6`",
113 "row_may_be_null": false,
114 "map_bit": 0,
115 "depends_on_map_bits": [
116 ]
117 }
118 ]
119 },
120 {
121 "ref_optimizer_key_uses": [
122 {
123 "table": "`t6`",
124 "field": "d",
125 "equals": "NULL",
126 "null_rejecting": true
127 }
128 ]
129 },
130 {
131 "rows_estimation": [
132 {
133 "table": "`t6`",
134 "range_analysis": {
135 "table_scan": {
136 "rows": 2,
137 "cost": 2.80085
138 },
139 "potential_range_indexes": [
140 {
141 "index": "d",
142 "usable": true,
143 "key_parts": [
144 "d"
145 ]
146 }
147 ],
148 "best_covering_index_scan": {
149 "index": "d",
150 "cost": 0.455814,
151 "chosen": true
152 },
153 "setup_range_conditions": [
154 {
155 "impossible_condition": {
156 "cause": "comparison_with_null_always_false"
157 }
158 }
159 ],
160 "impossible_range": true
161 },
162 "rows": 0,
163 "cause": "impossible_where_condition"
164 }
165 ]
166 }
167 ],
168 "empty_result": {
169 "cause": "no matching row in const table"
170 }
171 }
172 },
173 {
174 "join_execution": {
175 "select#": 1,
176 "steps": [
177 {
178 "subselect_execution": {
179 "select#": 2,
180 "steps": [
181 {
182 "join_execution": {
183 "select#": 2,
184 "steps": [
185 ]
186 }
187 }
188 ]
189 }
190 }
191 ]
192 }
193 }
194 ]
195 } 0 0
196 select (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
197 from information_schema.OPTIMIZER_TRACE;
198 (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
199 53.9297
200 set optimizer_trace="one_line=on";
201 SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 ;
202 RESULT
203 NULL
204 select * from information_schema.OPTIMIZER_TRACE;
205 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
206 SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 {"steps": [{"join_preparation": {"select#": 1,"steps": [{"join_preparation": {"select#": 2,"steps": [{"expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)"}]}},{"expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = `t5`.`c`)) AS `RESULT` from `t5`"}]}},{"join_optimization": {"select#": 1,"steps": [{"table_dependencies": [{"table": "`t5`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"rows_estimation": [{"table": "`t5`","rows": 1,"cost": 1,"table_type": "system","empty": false}]},{"attaching_conditions_to_tables": {"original_condition": null,"attached_conditions_computation": [],"attached_conditions_summary": []}},{"refine_plan": []}]}},{"join_optimization": {"select#": 2,"steps": [{"condition_processing": {"condition": "WHERE","original_condition": "(`t6`.`d` = NULL)","steps": [{"transformation": "equality_propagation","resulting_condition": "multiple equal(NULL, `t6`.`d`)"},{"transformation": "constant_propagation","resulting_condition": "multiple equal(NULL, `t6`.`d`)"},{"transformation": "trivial_condition_removal","resulting_condition": "multiple equal(NULL, `t6`.`d`)"}]}},{"substitute_generated_columns": {}},{"table_dependencies": [{"table": "`t6`","row_may_be_null": false,"map_bit": 0,"depends_on_map_bits": []}]},{"ref_optimizer_key_uses": [{"table": "`t6`","field": "d","equals": "NULL","null_rejecting": true}]},{"rows_estimation": [{"table": "`t6`","range_analysis": {"table_scan": {"rows": 2,"cost": 2.80085},"potential_range_indexes": [{"index": "d","usable": true,"key_parts": ["d"]}],"best_covering_index_scan": {"index": "d","cost": 0.455814,"chosen": true},"setup_range_conditions": [{"impossible_condition": {"cause": "comparison_with_null_always_false"}}],"impossible_range": true},"rows": 0,"cause": "impossible_where_condition"}]}],"empty_result": {"cause": "no matching row in const table"}}},{"join_execution": {"select#": 1,"steps": [{"subselect_execution": {"select#": 2,"steps": [{"join_execution": {"select#": 2,"steps": []}}]}}]}}]} 0 0
207 select (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
208 from information_schema.OPTIMIZER_TRACE;
209 (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
210 5.9961
211 set end_markers_in_json=on;
212 set optimizer_trace="one_line=off";
213 EXPLAIN SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
214 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
215 1 PRIMARY t5 NULL system NULL NULL NULL NULL 1 100.00 NULL
216 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
217 Warnings:
218 Note 1276 Field or reference 'test.t5.c' of SELECT #2 was resolved in SELECT #1
219 Note 1003 /* select#1 */ select (/* select#2 */ select 1 from `test`.`t6` where (`test`.`t6`.`d` = ifnull(NULL,NULL))) AS `RESULT` from dual
220 select * from information_schema.OPTIMIZER_TRACE;
221 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
222 EXPLAIN SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 {
223 "steps": [
224 {
225 "join_preparation": {
226 "select#": 1,
227 "steps": [
228 {
229 "join_preparation": {
230 "select#": 2,
231 "steps": [
232 {
233 "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
234 }
235 ] /* steps */
236 } /* join_preparation */
237 },
238 {
239 "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
240 }
241 ] /* steps */
242 } /* join_preparation */
243 },
244 {
245 "join_optimization": {
246 "select#": 1,
247 "steps": [
248 {
249 "table_dependencies": [
250 {
251 "table": "`t5`",
252 "row_may_be_null": false,
253 "map_bit": 0,
254 "depends_on_map_bits": [
255 ] /* depends_on_map_bits */
256 }
257 ] /* table_dependencies */
258 },
259 {
260 "rows_estimation": [
261 {
262 "table": "`t5`",
263 "rows": 1,
264 "cost": 1,
265 "table_type": "system",
266 "empty": false
267 }
268 ] /* rows_estimation */
269 },
270 {
271 "attaching_conditions_to_tables": {
272 "original_condition": null,
273 "attached_conditions_computation": [
274 ] /* attached_conditions_computation */,
275 "attached_conditions_summary": [
276 ] /* attached_conditions_summary */
277 } /* attaching_conditions_to_tables */
278 },
279 {
280 "refine_plan": [
281 ] /* refine_plan */
282 }
283 ] /* steps */
284 } /* join_optimization */
285 },
286 {
287 "join_optimization": {
288 "select#": 2,
289 "steps": [
290 {
291 "condition_processing": {
292 "condition": "WHERE",
293 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
294 "steps": [
295 {
296 "transformation": "equality_propagation",
297 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
298 },
299 {
300 "transformation": "constant_propagation",
301 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
302 },
303 {
304 "transformation": "trivial_condition_removal",
305 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
306 }
307 ] /* steps */
308 } /* condition_processing */
309 },
310 {
311 "substitute_generated_columns": {
312 } /* substitute_generated_columns */
313 },
314 {
315 "table_dependencies": [
316 {
317 "table": "`t6`",
318 "row_may_be_null": false,
319 "map_bit": 0,
320 "depends_on_map_bits": [
321 ] /* depends_on_map_bits */
322 }
323 ] /* table_dependencies */
324 },
325 {
326 "ref_optimizer_key_uses": [
327 {
328 "table": "`t6`",
329 "field": "d",
330 "equals": "ifnull(NULL,NULL)",
331 "null_rejecting": true
332 }
333 ] /* ref_optimizer_key_uses */
334 },
335 {
336 "rows_estimation": [
337 {
338 "table": "`t6`",
339 "range_analysis": {
340 "table_scan": {
341 "rows": 2,
342 "cost": 2.80085
343 } /* table_scan */,
344 "potential_range_indexes": [
345 {
346 "index": "d",
347 "usable": true,
348 "key_parts": [
349 "d"
350 ] /* key_parts */
351 }
352 ] /* potential_range_indexes */,
353 "best_covering_index_scan": {
354 "index": "d",
355 "cost": 0.455814,
356 "chosen": true
357 } /* best_covering_index_scan */,
358 "setup_range_conditions": [
359 {
360 "impossible_condition": {
361 "cause": "comparison_with_null_always_false"
362 } /* impossible_condition */
363 }
364 ] /* setup_range_conditions */,
365 "impossible_range": true
366 } /* range_analysis */,
367 "rows": 0,
368 "cause": "impossible_where_condition"
369 }
370 ] /* rows_estimation */
371 }
372 ] /* steps */,
373 "empty_result": {
374 "cause": "no matching row in const table"
375 } /* empty_result */
376 } /* join_optimization */
377 },
378 {
379 "join_explain": {
380 "select#": 1,
381 "steps": [
382 {
383 "join_explain": {
384 "select#": 2,
385 "steps": [
386 ] /* steps */
387 } /* join_explain */
388 }
389 ] /* steps */
390 } /* join_explain */
391 }
392 ] /* steps */
393 } 0 0
394 SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
395 RESULT
396 NULL
397 select * from information_schema.OPTIMIZER_TRACE;
398 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
399 SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 {
400 "steps": [
401 {
402 "join_preparation": {
403 "select#": 1,
404 "steps": [
405 {
406 "join_preparation": {
407 "select#": 2,
408 "steps": [
409 {
410 "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
411 }
412 ] /* steps */
413 } /* join_preparation */
414 },
415 {
416 "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
417 }
418 ] /* steps */
419 } /* join_preparation */
420 },
421 {
422 "join_optimization": {
423 "select#": 1,
424 "steps": [
425 {
426 "table_dependencies": [
427 {
428 "table": "`t5`",
429 "row_may_be_null": false,
430 "map_bit": 0,
431 "depends_on_map_bits": [
432 ] /* depends_on_map_bits */
433 }
434 ] /* table_dependencies */
435 },
436 {
437 "rows_estimation": [
438 {
439 "table": "`t5`",
440 "rows": 1,
441 "cost": 1,
442 "table_type": "system",
443 "empty": false
444 }
445 ] /* rows_estimation */
446 },
447 {
448 "attaching_conditions_to_tables": {
449 "original_condition": null,
450 "attached_conditions_computation": [
451 ] /* attached_conditions_computation */,
452 "attached_conditions_summary": [
453 ] /* attached_conditions_summary */
454 } /* attaching_conditions_to_tables */
455 },
456 {
457 "refine_plan": [
458 ] /* refine_plan */
459 }
460 ] /* steps */
461 } /* join_optimization */
462 },
463 {
464 "join_optimization": {
465 "select#": 2,
466 "steps": [
467 {
468 "condition_processing": {
469 "condition": "WHERE",
470 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
471 "steps": [
472 {
473 "transformation": "equality_propagation",
474 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
475 },
476 {
477 "transformation": "constant_propagation",
478 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
479 },
480 {
481 "transformation": "trivial_condition_removal",
482 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
483 }
484 ] /* steps */
485 } /* condition_processing */
486 },
487 {
488 "substitute_generated_columns": {
489 } /* substitute_generated_columns */
490 },
491 {
492 "table_dependencies": [
493 {
494 "table": "`t6`",
495 "row_may_be_null": false,
496 "map_bit": 0,
497 "depends_on_map_bits": [
498 ] /* depends_on_map_bits */
499 }
500 ] /* table_dependencies */
501 },
502 {
503 "ref_optimizer_key_uses": [
504 {
505 "table": "`t6`",
506 "field": "d",
507 "equals": "ifnull(NULL,NULL)",
508 "null_rejecting": true
509 }
510 ] /* ref_optimizer_key_uses */
511 },
512 {
513 "rows_estimation": [
514 {
515 "table": "`t6`",
516 "range_analysis": {
517 "table_scan": {
518 "rows": 2,
519 "cost": 2.80085
520 } /* table_scan */,
521 "potential_range_indexes": [
522 {
523 "index": "d",
524 "usable": true,
525 "key_parts": [
526 "d"
527 ] /* key_parts */
528 }
529 ] /* potential_range_indexes */,
530 "best_covering_index_scan": {
531 "index": "d",
532 "cost": 0.455814,
533 "chosen": true
534 } /* best_covering_index_scan */,
535 "setup_range_conditions": [
536 {
537 "impossible_condition": {
538 "cause": "comparison_with_null_always_false"
539 } /* impossible_condition */
540 }
541 ] /* setup_range_conditions */,
542 "impossible_range": true
543 } /* range_analysis */,
544 "rows": 0,
545 "cause": "impossible_where_condition"
546 }
547 ] /* rows_estimation */
548 }
549 ] /* steps */,
550 "empty_result": {
551 "cause": "no matching row in const table"
552 } /* empty_result */
553 } /* join_optimization */
554 },
555 {
556 "join_execution": {
557 "select#": 1,
558 "steps": [
559 {
560 "subselect_execution": {
561 "select#": 2,
562 "steps": [
563 {
564 "join_execution": {
565 "select#": 2,
566 "steps": [
567 ] /* steps */
568 } /* join_execution */
569 }
570 ] /* steps */
571 } /* subselect_execution */
572 }
573 ] /* steps */
574 } /* join_execution */
575 }
576 ] /* steps */
577 } 0 0
578 set @@session.optimizer_trace="enabled=off";
579 SELECT /* bug if you see this*/ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
580 RESULT
581 NULL
582 select QUERY from information_schema.OPTIMIZER_TRACE;
583 QUERY
584 SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5
585 set @@session.optimizer_trace="enabled=on";
586 SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
587 RESULT
588 NULL
589 select * from information_schema.OPTIMIZER_TRACE;
590 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
591 SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 {
592 "steps": [
593 {
594 "join_preparation": {
595 "select#": 1,
596 "steps": [
597 {
598 "join_preparation": {
599 "select#": 2,
600 "steps": [
601 {
602 "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
603 }
604 ] /* steps */
605 } /* join_preparation */
606 },
607 {
608 "join_preparation": {
609 "select#": 3,
610 "steps": [
611 {
612 "expanded_query": "/* select#3 */ select 2 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
613 }
614 ] /* steps */
615 } /* join_preparation */
616 },
617 {
618 "creating_tmp_table": {
619 "tmp_table_info": {
620 "table": "<union temporary>",
621 "columns": 1,
622 "row_length": 9,
623 "key_length": 8,
624 "unique_constraint": false,
625 "makes_grouped_rows": false,
626 "cannot_insert_duplicates": true,
627 "location": "TempTable"
628 } /* tmp_table_info */
629 } /* creating_tmp_table */
630 },
631 {
632 "join_preparation": {
633 "select#": 4,
634 "steps": [
635 {
636 "expanded_query": "/* select#4 */ select `1` from dual"
637 }
638 ] /* steps */
639 } /* join_preparation */
640 },
641 {
642 "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL)) union /* select#3 */ select 2 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
643 }
644 ] /* steps */
645 } /* join_preparation */
646 },
647 {
648 "join_optimization": {
649 "select#": 1,
650 "steps": [
651 {
652 "table_dependencies": [
653 {
654 "table": "`t5`",
655 "row_may_be_null": false,
656 "map_bit": 0,
657 "depends_on_map_bits": [
658 ] /* depends_on_map_bits */
659 }
660 ] /* table_dependencies */
661 },
662 {
663 "rows_estimation": [
664 {
665 "table": "`t5`",
666 "rows": 1,
667 "cost": 1,
668 "table_type": "system",
669 "empty": false
670 }
671 ] /* rows_estimation */
672 },
673 {
674 "attaching_conditions_to_tables": {
675 "original_condition": null,
676 "attached_conditions_computation": [
677 ] /* attached_conditions_computation */,
678 "attached_conditions_summary": [
679 ] /* attached_conditions_summary */
680 } /* attaching_conditions_to_tables */
681 },
682 {
683 "refine_plan": [
684 ] /* refine_plan */
685 }
686 ] /* steps */
687 } /* join_optimization */
688 },
689 {
690 "join_optimization": {
691 "select#": 2,
692 "steps": [
693 {
694 "condition_processing": {
695 "condition": "WHERE",
696 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
697 "steps": [
698 {
699 "transformation": "equality_propagation",
700 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
701 },
702 {
703 "transformation": "constant_propagation",
704 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
705 },
706 {
707 "transformation": "trivial_condition_removal",
708 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
709 }
710 ] /* steps */
711 } /* condition_processing */
712 },
713 {
714 "substitute_generated_columns": {
715 } /* substitute_generated_columns */
716 },
717 {
718 "table_dependencies": [
719 {
720 "table": "`t6`",
721 "row_may_be_null": false,
722 "map_bit": 0,
723 "depends_on_map_bits": [
724 ] /* depends_on_map_bits */
725 }
726 ] /* table_dependencies */
727 },
728 {
729 "ref_optimizer_key_uses": [
730 {
731 "table": "`t6`",
732 "field": "d",
733 "equals": "ifnull(NULL,NULL)",
734 "null_rejecting": true
735 }
736 ] /* ref_optimizer_key_uses */
737 },
738 {
739 "rows_estimation": [
740 {
741 "table": "`t6`",
742 "range_analysis": {
743 "table_scan": {
744 "rows": 2,
745 "cost": 2.80085
746 } /* table_scan */,
747 "potential_range_indexes": [
748 {
749 "index": "d",
750 "usable": true,
751 "key_parts": [
752 "d"
753 ] /* key_parts */
754 }
755 ] /* potential_range_indexes */,
756 "best_covering_index_scan": {
757 "index": "d",
758 "cost": 0.455814,
759 "chosen": true
760 } /* best_covering_index_scan */,
761 "setup_range_conditions": [
762 {
763 "impossible_condition": {
764 "cause": "comparison_with_null_always_false"
765 } /* impossible_condition */
766 }
767 ] /* setup_range_conditions */,
768 "impossible_range": true
769 } /* range_analysis */,
770 "rows": 0,
771 "cause": "impossible_where_condition"
772 }
773 ] /* rows_estimation */
774 }
775 ] /* steps */,
776 "empty_result": {
777 "cause": "no matching row in const table"
778 } /* empty_result */
779 } /* join_optimization */
780 },
781 {
782 "join_optimization": {
783 "select#": 3,
784 "steps": [
785 {
786 "condition_processing": {
787 "condition": "WHERE",
788 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
789 "steps": [
790 {
791 "transformation": "equality_propagation",
792 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
793 },
794 {
795 "transformation": "constant_propagation",
796 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
797 },
798 {
799 "transformation": "trivial_condition_removal",
800 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
801 }
802 ] /* steps */
803 } /* condition_processing */
804 },
805 {
806 "substitute_generated_columns": {
807 } /* substitute_generated_columns */
808 },
809 {
810 "table_dependencies": [
811 {
812 "table": "`t6`",
813 "row_may_be_null": false,
814 "map_bit": 0,
815 "depends_on_map_bits": [
816 ] /* depends_on_map_bits */
817 }
818 ] /* table_dependencies */
819 },
820 {
821 "ref_optimizer_key_uses": [
822 {
823 "table": "`t6`",
824 "field": "d",
825 "equals": "ifnull(NULL,NULL)",
826 "null_rejecting": true
827 }
828 ] /* ref_optimizer_key_uses */
829 },
830 {
831 "rows_estimation": [
832 {
833 "table": "`t6`",
834 "range_analysis": {
835 "table_scan": {
836 "rows": 2,
837 "cost": 2.80085
838 } /* table_scan */,
839 "potential_range_indexes": [
840 {
841 "index": "d",
842 "usable": true,
843 "key_parts": [
844 "d"
845 ] /* key_parts */
846 }
847 ] /* potential_range_indexes */,
848 "best_covering_index_scan": {
849 "index": "d",
850 "cost": 0.455814,
851 "chosen": true
852 } /* best_covering_index_scan */,
853 "setup_range_conditions": [
854 {
855 "impossible_condition": {
856 "cause": "comparison_with_null_always_false"
857 } /* impossible_condition */
858 }
859 ] /* setup_range_conditions */,
860 "impossible_range": true
861 } /* range_analysis */,
862 "rows": 0,
863 "cause": "impossible_where_condition"
864 }
865 ] /* rows_estimation */
866 }
867 ] /* steps */,
868 "empty_result": {
869 "cause": "no matching row in const table"
870 } /* empty_result */
871 } /* join_optimization */
872 },
873 {
874 "join_optimization": {
875 "select#": 4,
876 "steps": [
877 {
878 "table_dependencies": [
879 {
880 "table": "``",
881 "row_may_be_null": false,
882 "map_bit": 0,
883 "depends_on_map_bits": [
884 ] /* depends_on_map_bits */
885 }
886 ] /* table_dependencies */
887 },
888 {
889 "rows_estimation": [
890 {
891 "table": "``",
892 "table_scan": {
893 "rows": 0,
894 "cost": 2.5
895 } /* table_scan */
896 }
897 ] /* rows_estimation */
898 },
899 {
900 "considered_execution_plans": [
901 {
902 "plan_prefix": [
903 ] /* plan_prefix */,
904 "table": "``",
905 "best_access_path": {
906 "considered_access_paths": [
907 {
908 "rows_to_scan": 0,
909 "access_type": "scan",
910 "resulting_rows": 0,
911 "cost": 2.5,
912 "chosen": true
913 }
914 ] /* considered_access_paths */
915 } /* best_access_path */,
916 "condition_filtering_pct": 100,
917 "rows_for_plan": 0,
918 "cost_for_plan": 2.5,
919 "chosen": true
920 }
921 ] /* considered_execution_plans */
922 },
923 {
924 "attaching_conditions_to_tables": {
925 "original_condition": null,
926 "attached_conditions_computation": [
927 ] /* attached_conditions_computation */,
928 "attached_conditions_summary": [
929 {
930 "table": "``",
931 "attached": null
932 }
933 ] /* attached_conditions_summary */
934 } /* attaching_conditions_to_tables */
935 },
936 {
937 "finalizing_table_conditions": [
938 ] /* finalizing_table_conditions */
939 },
940 {
941 "refine_plan": [
942 {
943 "table": "``"
944 }
945 ] /* refine_plan */
946 }
947 ] /* steps */
948 } /* join_optimization */
949 },
950 {
951 "join_execution": {
952 "select#": 1,
953 "steps": [
954 {
955 "subselect_execution": {
956 "select#": 2,
957 "steps": [
958 {
959 "join_execution": {
960 "steps": [
961 {
962 "materialize": {
963 "select#": 2,
964 "steps": [
965 ] /* steps */
966 } /* materialize */
967 },
968 {
969 "materialize": {
970 "select#": 3,
971 "steps": [
972 ] /* steps */
973 } /* materialize */
974 }
975 ] /* steps */
976 } /* join_execution */
977 }
978 ] /* steps */
979 } /* subselect_execution */
980 }
981 ] /* steps */
982 } /* join_execution */
983 }
984 ] /* steps */
985 } 0 0
986 SELECT * FROM t5 WHERE 5 IN (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null));
987 c
988 select * from information_schema.OPTIMIZER_TRACE;
989 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
990 SELECT * FROM t5 WHERE 5 IN (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) {
991 "steps": [
992 {
993 "join_preparation": {
994 "select#": 1,
995 "steps": [
996 {
997 "join_preparation": {
998 "select#": 2,
999 "steps": [
1000 {
1001 "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
1002 },
1003 {
1004 "transformation": {
1005 "select#": 2,
1006 "from": "IN (SELECT)",
1007 "to": "EXISTS (CORRELATED SELECT)",
1008 "chosen": true,
1009 "evaluating_constant_where_conditions": [
1010 ] /* evaluating_constant_where_conditions */
1011 } /* transformation */
1012 }
1013 ] /* steps */
1014 } /* join_preparation */
1015 },
1016 {
1017 "join_preparation": {
1018 "select#": 3,
1019 "steps": [
1020 {
1021 "expanded_query": "/* select#3 */ select 2 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
1022 },
1023 {
1024 "transformation": {
1025 "select#": 3,
1026 "from": "IN (SELECT)",
1027 "to": "EXISTS (CORRELATED SELECT)",
1028 "chosen": true,
1029 "evaluating_constant_where_conditions": [
1030 ] /* evaluating_constant_where_conditions */
1031 } /* transformation */
1032 }
1033 ] /* steps */
1034 } /* join_preparation */
1035 },
1036 {
1037 "creating_tmp_table": {
1038 "tmp_table_info": {
1039 "table": "<union temporary>",
1040 "columns": 1,
1041 "row_length": 9,
1042 "key_length": 8,
1043 "unique_constraint": false,
1044 "makes_grouped_rows": false,
1045 "cannot_insert_duplicates": true,
1046 "location": "TempTable"
1047 } /* tmp_table_info */
1048 } /* creating_tmp_table */
1049 },
1050 {
1051 "join_preparation": {
1052 "select#": 4,
1053 "steps": [
1054 {
1055 "expanded_query": "/* select#4 */ select `1` from dual"
1056 }
1057 ] /* steps */
1058 } /* join_preparation */
1059 },
1060 {
1061 "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` where <in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1062 }
1063 ] /* steps */
1064 } /* join_preparation */
1065 },
1066 {
1067 "join_optimization": {
1068 "select#": 1,
1069 "steps": [
1070 {
1071 "condition_processing": {
1072 "condition": "WHERE",
1073 "original_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))",
1074 "steps": [
1075 {
1076 "transformation": "equality_propagation",
1077 "subselect_evaluation": [
1078 ] /* subselect_evaluation */,
1079 "resulting_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1080 },
1081 {
1082 "transformation": "constant_propagation",
1083 "subselect_evaluation": [
1084 ] /* subselect_evaluation */,
1085 "resulting_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1086 },
1087 {
1088 "transformation": "trivial_condition_removal",
1089 "subselect_evaluation": [
1090 ] /* subselect_evaluation */,
1091 "resulting_condition": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 1)) union /* select#3 */ select 2 from `t6` where ((`t6`.`d` = ifnull(`t5`.`c`,NULL)) and (<cache>(5) = 2))))"
1092 }
1093 ] /* steps */
1094 } /* condition_processing */
1095 },
1096 {
1097 "substitute_generated_columns": {
1098 } /* substitute_generated_columns */
1099 },
1100 {
1101 "table_dependencies": [
1102 {
1103 "table": "`t5`",
1104 "row_may_be_null": false,
1105 "map_bit": 0,
1106 "depends_on_map_bits": [
1107 ] /* depends_on_map_bits */
1108 }
1109 ] /* table_dependencies */
1110 },
1111 {
1112 "ref_optimizer_key_uses": [
1113 ] /* ref_optimizer_key_uses */
1114 },
1115 {
1116 "rows_estimation": [
1117 {
1118 "table": "`t5`",
1119 "rows": 1,
1120 "cost": 1,
1121 "table_type": "system",
1122 "empty": false
1123 }
1124 ] /* rows_estimation */
1125 },
1126 {
1127 "subselect_execution": {
1128 "select#": 2,
1129 "steps": [
1130 {
1131 "join_optimization": {
1132 "select#": 2,
1133 "steps": [
1134 {
1135 "condition_processing": {
1136 "condition": "WHERE",
1137 "original_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 1))",
1138 "steps": [
1139 {
1140 "transformation": "equality_propagation",
1141 "resulting_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 1))"
1142 },
1143 {
1144 "transformation": "constant_propagation",
1145 "resulting_condition": "((`t6`.`d` = NULL) and (<cache>(5) = 1))"
1146 },
1147 {
1148 "transformation": "trivial_condition_removal",
1149 "resulting_condition": null
1150 }
1151 ] /* steps */
1152 } /* condition_processing */
1153 }
1154 ] /* steps */,
1155 "empty_result": {
1156 "cause": "Impossible WHERE"
1157 } /* empty_result */
1158 } /* join_optimization */
1159 },
1160 {
1161 "join_optimization": {
1162 "select#": 3,
1163 "steps": [
1164 {
1165 "condition_processing": {
1166 "condition": "WHERE",
1167 "original_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 2))",
1168 "steps": [
1169 {
1170 "transformation": "equality_propagation",
1171 "resulting_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 2))"
1172 },
1173 {
1174 "transformation": "constant_propagation",
1175 "resulting_condition": "((`t6`.`d` = NULL) and (<cache>(5) = 2))"
1176 },
1177 {
1178 "transformation": "trivial_condition_removal",
1179 "resulting_condition": null
1180 }
1181 ] /* steps */
1182 } /* condition_processing */
1183 }
1184 ] /* steps */,
1185 "empty_result": {
1186 "cause": "Impossible WHERE"
1187 } /* empty_result */
1188 } /* join_optimization */
1189 },
1190 {
1191 "join_optimization": {
1192 "select#": 4,
1193 "steps": [
1194 {
1195 "table_dependencies": [
1196 {
1197 "table": "``",
1198 "row_may_be_null": false,
1199 "map_bit": 0,
1200 "depends_on_map_bits": [
1201 ] /* depends_on_map_bits */
1202 }
1203 ] /* table_dependencies */
1204 },
1205 {
1206 "rows_estimation": [
1207 {
1208 "table": "``",
1209 "table_scan": {
1210 "rows": 0,
1211 "cost": 2.5
1212 } /* table_scan */
1213 }
1214 ] /* rows_estimation */
1215 },
1216 {
1217 "considered_execution_plans": [
1218 {
1219 "plan_prefix": [
1220 ] /* plan_prefix */,
1221 "table": "``",
1222 "best_access_path": {
1223 "considered_access_paths": [
1224 {
1225 "rows_to_scan": 0,
1226 "access_type": "scan",
1227 "resulting_rows": 0,
1228 "cost": 2.5,
1229 "chosen": true
1230 }
1231 ] /* considered_access_paths */
1232 } /* best_access_path */,
1233 "condition_filtering_pct": 100,
1234 "rows_for_plan": 0,
1235 "cost_for_plan": 2.5,
1236 "chosen": true
1237 }
1238 ] /* considered_execution_plans */
1239 },
1240 {
1241 "attaching_conditions_to_tables": {
1242 "original_condition": null,
1243 "attached_conditions_computation": [
1244 ] /* attached_conditions_computation */,
1245 "attached_conditions_summary": [
1246 {
1247 "table": "``",
1248 "attached": null
1249 }
1250 ] /* attached_conditions_summary */
1251 } /* attaching_conditions_to_tables */
1252 },
1253 {
1254 "finalizing_table_conditions": [
1255 ] /* finalizing_table_conditions */
1256 },
1257 {
1258 "refine_plan": [
1259 {
1260 "table": "``"
1261 }
1262 ] /* refine_plan */
1263 }
1264 ] /* steps */
1265 } /* join_optimization */
1266 },
1267 {
1268 "join_execution": {
1269 "steps": [
1270 {
1271 "materialize": {
1272 "select#": 2,
1273 "steps": [
1274 ] /* steps */
1275 } /* materialize */
1276 },
1277 {
1278 "materialize": {
1279 "select#": 3,
1280 "steps": [
1281 ] /* steps */
1282 } /* materialize */
1283 }
1284 ] /* steps */
1285 } /* join_execution */
1286 }
1287 ] /* steps */
1288 } /* subselect_execution */
1289 },
1290 {
1291 "condition_on_constant_tables": "<in_optimizer>(5,<exists>(/* select#2 */ select 1 from `t6` where false union /* select#3 */ select 2 from `t6` where false))",
1292 "condition_value": false
1293 }
1294 ] /* steps */,
1295 "empty_result": {
1296 "cause": "Impossible WHERE noticed after reading const tables"
1297 } /* empty_result */
1298 } /* join_optimization */
1299 },
1300 {
1301 "join_execution": {
1302 "select#": 1,
1303 "steps": [
1304 ] /* steps */
1305 } /* join_execution */
1306 }
1307 ] /* steps */
1308 } 0 0
1309 select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
1310 (@query:=QUERY)+NULL (@trace:=TRACE)+NULL
1311 NULL NULL
1312 select length(@trace);
1313 length(@trace)
1314 12964
1315 set @max_mem_size=13307;
1316 set optimizer_trace_max_mem_size=@max_mem_size;
1317 select length(@query)+length(@trace) > @@optimizer_trace_max_mem_size;
1318 length(@query)+length(@trace) > @@optimizer_trace_max_mem_size
1319 0
1320 SELECT * FROM t5 WHERE 5 IN (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null));
1321 c
1322 select (@missing_bytes:=missing_bytes_beyond_max_mem_size) from information_schema.OPTIMIZER_TRACE;
1323 (@missing_bytes:=missing_bytes_beyond_max_mem_size)
1324 0
1325 Warnings:
1326 Warning 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
1327 select (@query2:=QUERY)+NULL,(@trace2:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
1328 (@query2:=QUERY)+NULL (@trace2:=TRACE)+NULL
1329 NULL NULL
1330 select length(@trace2),
1331 (length(@trace2) + @missing_bytes) = length(@trace),
1332 @query2 = @query;
1333 length(@trace2) (length(@trace2) + @missing_bytes) = length(@trace) @query2 = @query
1334 12964 1 1
1335 select length(@query2) + length(@trace2)
1336 between (@@optimizer_trace_max_mem_size-200) and (@@optimizer_trace_max_mem_size+200);
1337 length(@query2) + length(@trace2)
1338 between (@@optimizer_trace_max_mem_size-200) and (@@optimizer_trace_max_mem_size+200)
1339 0
1340 select instr(@trace, @trace2) = 1;
1341 instr(@trace, @trace2) = 1
1342 1
1343 set optimizer_trace_max_mem_size=1;
1344 select 1;
1345 1
1346 1
1347 select * from information_schema.OPTIMIZER_TRACE;
1348 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1349 select 1 521 0
1350 set optimizer_trace_max_mem_size=0;
1351 select 1;
1352 1
1353 1
1354 select * from information_schema.OPTIMIZER_TRACE;
1355 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1356 529 0
1357 set optimizer_trace_max_mem_size=1048576;
1358 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null);
1359 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1360 1 SIMPLE t5 NULL system NULL NULL NULL NULL 1 100.00 NULL
1361 1 SIMPLE t6 NULL ref d d 5 const 1 100.00 Using where; Using index; FirstMatch(t5)
1362 Warnings:
1363 Note 1003 /* select#1 */ select NULL AS `c` from <constant table> semi join (`test`.`t6`) where ((`test`.`t6`.`d` is null) and (<cache>((NULL + 1)) = (`test`.`t6`.`d` + 1)))
1364 select * from information_schema.OPTIMIZER_TRACE;
1365 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1366 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null) {
1367 "steps": [
1368 {
1369 "join_preparation": {
1370 "select#": 1,
1371 "steps": [
1372 {
1373 "join_preparation": {
1374 "select#": 2,
1375 "steps": [
1376 {
1377 "expanded_query": "/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null)"
1378 }
1379 ] /* steps */
1380 } /* join_preparation */
1381 },
1382 {
1383 "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` where (`t5`.`c` + 1) in (/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null))"
1384 },
1385 {
1386 "transformation": {
1387 "select#": 2,
1388 "from": "IN (SELECT)",
1389 "to": "semijoin",
1390 "chosen": true,
1391 "transformation_to_semi_join": {
1392 "subquery_predicate": "(`t5`.`c` + 1) in (/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null))",
1393 "embedded in": "WHERE",
1394 "evaluating_constant_semijoin_conditions": [
1395 ] /* evaluating_constant_semijoin_conditions */,
1396 "semi-join condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))",
1397 "decorrelated_predicates": [
1398 {
1399 "outer": "(`t5`.`c` + 1)",
1400 "inner": "(`t6`.`d` + 1)"
1401 }
1402 ] /* decorrelated_predicates */
1403 } /* transformation_to_semi_join */
1404 } /* transformation */
1405 },
1406 {
1407 "transformations_to_nested_joins": {
1408 "transformations": [
1409 "semijoin"
1410 ] /* transformations */,
1411 "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` semi join (`t6`) where ((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1412 } /* transformations_to_nested_joins */
1413 }
1414 ] /* steps */
1415 } /* join_preparation */
1416 },
1417 {
1418 "join_optimization": {
1419 "select#": 1,
1420 "steps": [
1421 {
1422 "condition_processing": {
1423 "condition": "WHERE",
1424 "original_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))",
1425 "steps": [
1426 {
1427 "transformation": "equality_propagation",
1428 "resulting_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1429 },
1430 {
1431 "transformation": "constant_propagation",
1432 "resulting_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1433 },
1434 {
1435 "transformation": "trivial_condition_removal",
1436 "resulting_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1437 }
1438 ] /* steps */
1439 } /* condition_processing */
1440 },
1441 {
1442 "substitute_generated_columns": {
1443 } /* substitute_generated_columns */
1444 },
1445 {
1446 "table_dependencies": [
1447 {
1448 "table": "`t5`",
1449 "row_may_be_null": false,
1450 "map_bit": 0,
1451 "depends_on_map_bits": [
1452 ] /* depends_on_map_bits */
1453 },
1454 {
1455 "table": "`t6`",
1456 "row_may_be_null": false,
1457 "map_bit": 1,
1458 "depends_on_map_bits": [
1459 ] /* depends_on_map_bits */
1460 }
1461 ] /* table_dependencies */
1462 },
1463 {
1464 "ref_optimizer_key_uses": [
1465 {
1466 "table": "`t6`",
1467 "field": "d",
1468 "equals": "NULL",
1469 "null_rejecting": false
1470 }
1471 ] /* ref_optimizer_key_uses */
1472 },
1473 {
1474 "pulled_out_semijoin_tables": [
1475 ] /* pulled_out_semijoin_tables */
1476 },
1477 {
1478 "rows_estimation": [
1479 {
1480 "table": "`t5`",
1481 "rows": 1,
1482 "cost": 1,
1483 "table_type": "system",
1484 "empty": false
1485 },
1486 {
1487 "table": "`t6`",
1488 "range_analysis": {
1489 "table_scan": {
1490 "rows": 2,
1491 "cost": 2.80085
1492 } /* table_scan */,
1493 "potential_range_indexes": [
1494 {
1495 "index": "d",
1496 "usable": true,
1497 "key_parts": [
1498 "d"
1499 ] /* key_parts */
1500 }
1501 ] /* potential_range_indexes */,
1502 "best_covering_index_scan": {
1503 "index": "d",
1504 "cost": 0.455814,
1505 "chosen": true
1506 } /* best_covering_index_scan */,
1507 "setup_range_conditions": [
1508 ] /* setup_range_conditions */,
1509 "group_index_range": {
1510 "chosen": false,
1511 "cause": "not_original_query_table"
1512 } /* group_index_range */,
1513 "skip_scan_range": {
1514 "chosen": false,
1515 "cause": "not_single_table"
1516 } /* skip_scan_range */,
1517 "analyzing_range_alternatives": {
1518 "range_scan_alternatives": [
1519 {
1520 "index": "d",
1521 "ranges": [
1522 "d = NULL"
1523 ] /* ranges */,
1524 "index_dives_for_eq_ranges": true,
1525 "rowid_ordered": true,
1526 "using_mrr": false,
1527 "index_only": true,
1528 "in_memory": -1,
1529 "rows": 1,
1530 "cost": 0.36,
1531 "chosen": true
1532 }
1533 ] /* range_scan_alternatives */,
1534 "analyzing_roworder_intersect": {
1535 "usable": false,
1536 "cause": "too_few_roworder_scans"
1537 } /* analyzing_roworder_intersect */
1538 } /* analyzing_range_alternatives */,
1539 "chosen_range_access_summary": {
1540 "range_access_plan": {
1541 "type": "range_scan",
1542 "index": "d",
1543 "rows": 1,
1544 "ranges": [
1545 "d = NULL"
1546 ] /* ranges */
1547 } /* range_access_plan */,
1548 "rows_for_plan": 1,
1549 "cost_for_plan": 0.36,
1550 "chosen": true
1551 } /* chosen_range_access_summary */
1552 } /* range_analysis */
1553 }
1554 ] /* rows_estimation */
1555 },
1556 {
1557 "execution_plan_for_potential_materialization": {
1558 "steps": [
1559 {
1560 "considered_execution_plans": [
1561 {
1562 "plan_prefix": [
1563 ] /* plan_prefix */,
1564 "table": "`t6`",
1565 "best_access_path": {
1566 "considered_access_paths": [
1567 {
1568 "access_type": "ref",
1569 "index": "d",
1570 "rows": 1,
1571 "cost": 0.35,
1572 "chosen": true
1573 },
1574 {
1575 "access_type": "range",
1576 "range_details": {
1577 "used_index": "d"
1578 } /* range_details */,
1579 "chosen": false,
1580 "cause": "heuristic_index_cheaper"
1581 }
1582 ] /* considered_access_paths */
1583 } /* best_access_path */,
1584 "condition_filtering_pct": 100,
1585 "rows_for_plan": 1,
1586 "cost_for_plan": 0.35,
1587 "chosen": true
1588 }
1589 ] /* considered_execution_plans */
1590 }
1591 ] /* steps */
1592 } /* execution_plan_for_potential_materialization */
1593 },
1594 {
1595 "considered_execution_plans": [
1596 {
1597 "plan_prefix": [
1598 "`t5`"
1599 ] /* plan_prefix */,
1600 "table": "`t6`",
1601 "best_access_path": {
1602 "considered_access_paths": [
1603 {
1604 "access_type": "ref",
1605 "index": "d",
1606 "rows": 1,
1607 "cost": 0.35,
1608 "chosen": true
1609 },
1610 {
1611 "access_type": "range",
1612 "range_details": {
1613 "used_index": "d"
1614 } /* range_details */,
1615 "chosen": false,
1616 "cause": "heuristic_index_cheaper"
1617 }
1618 ] /* considered_access_paths */
1619 } /* best_access_path */,
1620 "condition_filtering_pct": 100,
1621 "rows_for_plan": 1,
1622 "cost_for_plan": 0.35,
1623 "semijoin_strategy_choice": [
1624 {
1625 "strategy": "FirstMatch",
1626 "recalculate_access_paths_and_cost": {
1627 "tables": [
1628 ] /* tables */
1629 } /* recalculate_access_paths_and_cost */,
1630 "cost": 0.35,
1631 "rows": 1,
1632 "chosen": true
1633 },
1634 {
1635 "strategy": "MaterializeLookup",
1636 "cost": 1.55,
1637 "rows": 1,
1638 "duplicate_tables_left": false,
1639 "chosen": false
1640 },
1641 {
1642 "strategy": "DuplicatesWeedout",
1643 "cost": 1.55,
1644 "rows": 1,
1645 "duplicate_tables_left": false,
1646 "chosen": false
1647 }
1648 ] /* semijoin_strategy_choice */,
1649 "chosen": true
1650 },
1651 {
1652 "final_semijoin_strategy": "FirstMatch",
1653 "recalculate_access_paths_and_cost": {
1654 "tables": [
1655 ] /* tables */
1656 } /* recalculate_access_paths_and_cost */
1657 }
1658 ] /* considered_execution_plans */
1659 },
1660 {
1661 "attaching_conditions_to_tables": {
1662 "original_condition": "((`t6`.`d` is null) and ((NULL + 1) = (`t6`.`d` + 1)))",
1663 "attached_conditions_computation": [
1664 ] /* attached_conditions_computation */,
1665 "attached_conditions_summary": [
1666 {
1667 "table": "`t6`",
1668 "attached": "((`t6`.`d` is null) and ((NULL + 1) = (`t6`.`d` + 1)))"
1669 }
1670 ] /* attached_conditions_summary */
1671 } /* attaching_conditions_to_tables */
1672 },
1673 {
1674 "finalizing_table_conditions": [
1675 {
1676 "table": "`t6`",
1677 "original_table_condition": "((`t6`.`d` is null) and ((NULL + 1) = (`t6`.`d` + 1)))",
1678 "final_table_condition ": "((`t6`.`d` is null) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1679 }
1680 ] /* finalizing_table_conditions */
1681 },
1682 {
1683 "refine_plan": [
1684 {
1685 "table": "`t6`"
1686 }
1687 ] /* refine_plan */
1688 }
1689 ] /* steps */
1690 } /* join_optimization */
1691 },
1692 {
1693 "join_explain": {
1694 "select#": 1,
1695 "steps": [
1696 ] /* steps */
1697 } /* join_explain */
1698 }
1699 ] /* steps */
1700 } 0 0
1701 set @old_opt_switch=@@optimizer_switch;
1702 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null);
1703 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1704 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1705 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty
1706 Warnings:
1707 Note 1003 /* select#1 */ select NULL AS `c` from dual where <in_optimizer>((NULL + 1),<exists>(/* select#2 */ select (`test`.`t6`.`d` + 1) from `test`.`t6` where ((`test`.`t6`.`d` is null) and (<cache>((NULL + 1)) = (`test`.`t6`.`d` + 1)))))
1708 select * from information_schema.OPTIMIZER_TRACE;
1709 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1710 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null) {
1711 "steps": [
1712 {
1713 "join_preparation": {
1714 "select#": 1,
1715 "steps": [
1716 {
1717 "join_preparation": {
1718 "select#": 2,
1719 "steps": [
1720 {
1721 "expanded_query": "/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null)"
1722 },
1723 {
1724 "transformation": {
1725 "select#": 2,
1726 "from": "IN (SELECT)",
1727 "to": "EXISTS (CORRELATED SELECT)",
1728 "chosen": true,
1729 "evaluating_constant_where_conditions": [
1730 ] /* evaluating_constant_where_conditions */
1731 } /* transformation */
1732 }
1733 ] /* steps */
1734 } /* join_preparation */
1735 },
1736 {
1737 "expanded_query": "/* select#1 */ select `t5`.`c` AS `c` from `t5` where <in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where ((`t6`.`d` is null) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1738 }
1739 ] /* steps */
1740 } /* join_preparation */
1741 },
1742 {
1743 "join_optimization": {
1744 "select#": 1,
1745 "steps": [
1746 {
1747 "condition_processing": {
1748 "condition": "WHERE",
1749 "original_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where ((`t6`.`d` is null) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))",
1750 "steps": [
1751 {
1752 "transformation": "equality_propagation",
1753 "subselect_evaluation": [
1754 ] /* subselect_evaluation */,
1755 "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where ((`t6`.`d` is null) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1756 },
1757 {
1758 "transformation": "constant_propagation",
1759 "subselect_evaluation": [
1760 ] /* subselect_evaluation */,
1761 "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where ((`t6`.`d` is null) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1762 },
1763 {
1764 "transformation": "trivial_condition_removal",
1765 "subselect_evaluation": [
1766 ] /* subselect_evaluation */,
1767 "resulting_condition": "<in_optimizer>((`t5`.`c` + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where ((`t6`.`d` is null) and (<cache>((`t5`.`c` + 1)) = (`t6`.`d` + 1)))))"
1768 }
1769 ] /* steps */
1770 } /* condition_processing */
1771 },
1772 {
1773 "substitute_generated_columns": {
1774 } /* substitute_generated_columns */
1775 },
1776 {
1777 "table_dependencies": [
1778 {
1779 "table": "`t5`",
1780 "row_may_be_null": false,
1781 "map_bit": 0,
1782 "depends_on_map_bits": [
1783 ] /* depends_on_map_bits */
1784 }
1785 ] /* table_dependencies */
1786 },
1787 {
1788 "ref_optimizer_key_uses": [
1789 ] /* ref_optimizer_key_uses */
1790 },
1791 {
1792 "rows_estimation": [
1793 {
1794 "table": "`t5`",
1795 "rows": 1,
1796 "cost": 1,
1797 "table_type": "system",
1798 "empty": false
1799 }
1800 ] /* rows_estimation */
1801 },
1802 {
1803 "condition_on_constant_tables": "<in_optimizer>((NULL + 1),<exists>(/* select#2 */ select (`t6`.`d` + 1) from `t6` where ((`t6`.`d` is null) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))))",
1804 "condition_value": false
1805 }
1806 ] /* steps */,
1807 "empty_result": {
1808 "cause": "Impossible WHERE noticed after reading const tables"
1809 } /* empty_result */
1810 } /* join_optimization */
1811 },
1812 {
1813 "join_explain": {
1814 "select#": 1,
1815 "steps": [
1816 {
1817 "join_explain": {
1818 "select#": 2,
1819 "steps": [
1820 ] /* steps */
1821 } /* join_explain */
1822 }
1823 ] /* steps */
1824 } /* join_explain */
1825 }
1826 ] /* steps */
1827 } 0 0
1828 set optimizer_switch=@old_opt_switch;
1829 CREATE TABLE t1 (s1 CHAR(5),
1830 s2 CHAR(5)) CHARSET utf8mb4;
1831 INSERT INTO t1 VALUES ('z','?'),('y','!');
1832 explain select * from t1 where s1 > any (select s2 from t1);
1833 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1834 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
1835 2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
1836 Warnings:
1837 Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <nop>((`test`.`t1`.`s1` > (/* select#2 */ select min(`test`.`t1`.`s2`) from `test`.`t1`)))
1838 select * from information_schema.OPTIMIZER_TRACE;
1839 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1840 explain select * from t1 where s1 > any (select s2 from t1) {
1841 "steps": [
1842 {
1843 "join_preparation": {
1844 "select#": 1,
1845 "steps": [
1846 {
1847 "join_preparation": {
1848 "select#": 2,
1849 "steps": [
1850 {
1851 "expanded_query": "/* select#2 */ select `t1`.`s2` from `t1`"
1852 },
1853 {
1854 "transformation": {
1855 "select#": 2,
1856 "from": "> ALL/ANY (SELECT)",
1857 "to": "SELECT(MIN)",
1858 "chosen": true
1859 } /* transformation */
1860 }
1861 ] /* steps */
1862 } /* join_preparation */
1863 },
1864 {
1865 "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1866 }
1867 ] /* steps */
1868 } /* join_preparation */
1869 },
1870 {
1871 "join_optimization": {
1872 "select#": 1,
1873 "steps": [
1874 {
1875 "condition_processing": {
1876 "condition": "WHERE",
1877 "original_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
1878 "steps": [
1879 {
1880 "transformation": "equality_propagation",
1881 "subselect_evaluation": [
1882 ] /* subselect_evaluation */,
1883 "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1884 },
1885 {
1886 "transformation": "constant_propagation",
1887 "subselect_evaluation": [
1888 ] /* subselect_evaluation */,
1889 "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1890 },
1891 {
1892 "transformation": "trivial_condition_removal",
1893 "subselect_evaluation": [
1894 ] /* subselect_evaluation */,
1895 "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1896 }
1897 ] /* steps */
1898 } /* condition_processing */
1899 },
1900 {
1901 "substitute_generated_columns": {
1902 } /* substitute_generated_columns */
1903 },
1904 {
1905 "table_dependencies": [
1906 {
1907 "table": "`t1`",
1908 "row_may_be_null": false,
1909 "map_bit": 0,
1910 "depends_on_map_bits": [
1911 ] /* depends_on_map_bits */
1912 }
1913 ] /* table_dependencies */
1914 },
1915 {
1916 "ref_optimizer_key_uses": [
1917 ] /* ref_optimizer_key_uses */
1918 },
1919 {
1920 "rows_estimation": [
1921 {
1922 "table": "`t1`",
1923 "table_scan": {
1924 "rows": 2,
1925 "cost": 0.505005
1926 } /* table_scan */
1927 }
1928 ] /* rows_estimation */
1929 },
1930 {
1931 "considered_execution_plans": [
1932 {
1933 "plan_prefix": [
1934 ] /* plan_prefix */,
1935 "table": "`t1`",
1936 "best_access_path": {
1937 "considered_access_paths": [
1938 {
1939 "rows_to_scan": 2,
1940 "filtering_effect": [
1941 ] /* filtering_effect */,
1942 "final_filtering_effect": 1,
1943 "access_type": "scan",
1944 "resulting_rows": 2,
1945 "cost": 0.705005,
1946 "chosen": true
1947 }
1948 ] /* considered_access_paths */
1949 } /* best_access_path */,
1950 "condition_filtering_pct": 50,
1951 "rows_for_plan": 1,
1952 "cost_for_plan": 0.705005,
1953 "chosen": true
1954 }
1955 ] /* considered_execution_plans */
1956 },
1957 {
1958 "attaching_conditions_to_tables": {
1959 "original_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
1960 "attached_conditions_computation": [
1961 ] /* attached_conditions_computation */,
1962 "attached_conditions_summary": [
1963 {
1964 "table": "`t1`",
1965 "attached": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1966 }
1967 ] /* attached_conditions_summary */
1968 } /* attaching_conditions_to_tables */
1969 },
1970 {
1971 "finalizing_table_conditions": [
1972 {
1973 "table": "`t1`",
1974 "original_table_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
1975 "final_table_condition ": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1976 }
1977 ] /* finalizing_table_conditions */
1978 },
1979 {
1980 "refine_plan": [
1981 {
1982 "table": "`t1`"
1983 }
1984 ] /* refine_plan */
1985 }
1986 ] /* steps */
1987 } /* join_optimization */
1988 },
1989 {
1990 "join_optimization": {
1991 "select#": 2,
1992 "steps": [
1993 {
1994 "table_dependencies": [
1995 {
1996 "table": "`t1`",
1997 "row_may_be_null": false,
1998 "map_bit": 0,
1999 "depends_on_map_bits": [
2000 ] /* depends_on_map_bits */
2001 }
2002 ] /* table_dependencies */
2003 },
2004 {
2005 "rows_estimation": [
2006 {
2007 "table": "`t1`",
2008 "table_scan": {
2009 "rows": 2,
2010 "cost": 0.505005
2011 } /* table_scan */
2012 }
2013 ] /* rows_estimation */
2014 },
2015 {
2016 "considered_execution_plans": [
2017 {
2018 "plan_prefix": [
2019 ] /* plan_prefix */,
2020 "table": "`t1`",
2021 "best_access_path": {
2022 "considered_access_paths": [
2023 {
2024 "rows_to_scan": 2,
2025 "access_type": "scan",
2026 "resulting_rows": 2,
2027 "cost": 0.705005,
2028 "chosen": true
2029 }
2030 ] /* considered_access_paths */
2031 } /* best_access_path */,
2032 "condition_filtering_pct": 100,
2033 "rows_for_plan": 2,
2034 "cost_for_plan": 0.705005,
2035 "chosen": true
2036 }
2037 ] /* considered_execution_plans */
2038 },
2039 {
2040 "attaching_conditions_to_tables": {
2041 "original_condition": null,
2042 "attached_conditions_computation": [
2043 ] /* attached_conditions_computation */,
2044 "attached_conditions_summary": [
2045 {
2046 "table": "`t1`",
2047 "attached": null
2048 }
2049 ] /* attached_conditions_summary */
2050 } /* attaching_conditions_to_tables */
2051 },
2052 {
2053 "optimizing_distinct_group_by_order_by": {
2054 } /* optimizing_distinct_group_by_order_by */
2055 },
2056 {
2057 "finalizing_table_conditions": [
2058 ] /* finalizing_table_conditions */
2059 },
2060 {
2061 "refine_plan": [
2062 {
2063 "table": "`t1`"
2064 }
2065 ] /* refine_plan */
2066 },
2067 {
2068 "considering_tmp_tables": [
2069 ] /* considering_tmp_tables */
2070 }
2071 ] /* steps */
2072 } /* join_optimization */
2073 },
2074 {
2075 "join_explain": {
2076 "select#": 1,
2077 "steps": [
2078 {
2079 "join_explain": {
2080 "select#": 2,
2081 "steps": [
2082 ] /* steps */
2083 } /* join_explain */
2084 }
2085 ] /* steps */
2086 } /* join_explain */
2087 }
2088 ] /* steps */
2089 } 0 0
2090 explain select * from t1 where s1 > any (select max(s2) from t1);
2091 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2092 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
2093 2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
2094 Warnings:
2095 Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <nop>((`test`.`t1`.`s1` > <min>(/* select#2 */ select max(`test`.`t1`.`s2`) from `test`.`t1`)))
2096 select * from information_schema.OPTIMIZER_TRACE;
2097 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2098 explain select * from t1 where s1 > any (select max(s2) from t1) {
2099 "steps": [
2100 {
2101 "join_preparation": {
2102 "select#": 1,
2103 "steps": [
2104 {
2105 "join_preparation": {
2106 "select#": 2,
2107 "steps": [
2108 {
2109 "expanded_query": "/* select#2 */ select max(`t1`.`s2`) from `t1`"
2110 },
2111 {
2112 "transformation": {
2113 "select#": 2,
2114 "from": "> ALL/ANY (SELECT)",
2115 "to": "MIN (SELECT)",
2116 "chosen": true
2117 } /* transformation */
2118 }
2119 ] /* steps */
2120 } /* join_preparation */
2121 },
2122 {
2123 "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2124 }
2125 ] /* steps */
2126 } /* join_preparation */
2127 },
2128 {
2129 "join_optimization": {
2130 "select#": 1,
2131 "steps": [
2132 {
2133 "condition_processing": {
2134 "condition": "WHERE",
2135 "original_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2136 "steps": [
2137 {
2138 "transformation": "equality_propagation",
2139 "subselect_evaluation": [
2140 ] /* subselect_evaluation */,
2141 "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2142 },
2143 {
2144 "transformation": "constant_propagation",
2145 "subselect_evaluation": [
2146 ] /* subselect_evaluation */,
2147 "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2148 },
2149 {
2150 "transformation": "trivial_condition_removal",
2151 "subselect_evaluation": [
2152 ] /* subselect_evaluation */,
2153 "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2154 }
2155 ] /* steps */
2156 } /* condition_processing */
2157 },
2158 {
2159 "substitute_generated_columns": {
2160 } /* substitute_generated_columns */
2161 },
2162 {
2163 "table_dependencies": [
2164 {
2165 "table": "`t1`",
2166 "row_may_be_null": false,
2167 "map_bit": 0,
2168 "depends_on_map_bits": [
2169 ] /* depends_on_map_bits */
2170 }
2171 ] /* table_dependencies */
2172 },
2173 {
2174 "ref_optimizer_key_uses": [
2175 ] /* ref_optimizer_key_uses */
2176 },
2177 {
2178 "rows_estimation": [
2179 {
2180 "table": "`t1`",
2181 "table_scan": {
2182 "rows": 2,
2183 "cost": 0.505005
2184 } /* table_scan */
2185 }
2186 ] /* rows_estimation */
2187 },
2188 {
2189 "considered_execution_plans": [
2190 {
2191 "plan_prefix": [
2192 ] /* plan_prefix */,
2193 "table": "`t1`",
2194 "best_access_path": {
2195 "considered_access_paths": [
2196 {
2197 "rows_to_scan": 2,
2198 "filtering_effect": [
2199 ] /* filtering_effect */,
2200 "final_filtering_effect": 1,
2201 "access_type": "scan",
2202 "resulting_rows": 2,
2203 "cost": 0.705005,
2204 "chosen": true
2205 }
2206 ] /* considered_access_paths */
2207 } /* best_access_path */,
2208 "condition_filtering_pct": 50,
2209 "rows_for_plan": 1,
2210 "cost_for_plan": 0.705005,
2211 "chosen": true
2212 }
2213 ] /* considered_execution_plans */
2214 },
2215 {
2216 "attaching_conditions_to_tables": {
2217 "original_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2218 "attached_conditions_computation": [
2219 ] /* attached_conditions_computation */,
2220 "attached_conditions_summary": [
2221 {
2222 "table": "`t1`",
2223 "attached": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2224 }
2225 ] /* attached_conditions_summary */
2226 } /* attaching_conditions_to_tables */
2227 },
2228 {
2229 "finalizing_table_conditions": [
2230 {
2231 "table": "`t1`",
2232 "original_table_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2233 "final_table_condition ": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2234 }
2235 ] /* finalizing_table_conditions */
2236 },
2237 {
2238 "refine_plan": [
2239 {
2240 "table": "`t1`"
2241 }
2242 ] /* refine_plan */
2243 }
2244 ] /* steps */
2245 } /* join_optimization */
2246 },
2247 {
2248 "join_optimization": {
2249 "select#": 2,
2250 "steps": [
2251 {
2252 "table_dependencies": [
2253 {
2254 "table": "`t1`",
2255 "row_may_be_null": false,
2256 "map_bit": 0,
2257 "depends_on_map_bits": [
2258 ] /* depends_on_map_bits */
2259 }
2260 ] /* table_dependencies */
2261 },
2262 {
2263 "rows_estimation": [
2264 {
2265 "table": "`t1`",
2266 "table_scan": {
2267 "rows": 2,
2268 "cost": 0.505005
2269 } /* table_scan */
2270 }
2271 ] /* rows_estimation */
2272 },
2273 {
2274 "considered_execution_plans": [
2275 {
2276 "plan_prefix": [
2277 ] /* plan_prefix */,
2278 "table": "`t1`",
2279 "best_access_path": {
2280 "considered_access_paths": [
2281 {
2282 "rows_to_scan": 2,
2283 "access_type": "scan",
2284 "resulting_rows": 2,
2285 "cost": 0.705005,
2286 "chosen": true
2287 }
2288 ] /* considered_access_paths */
2289 } /* best_access_path */,
2290 "condition_filtering_pct": 100,
2291 "rows_for_plan": 2,
2292 "cost_for_plan": 0.705005,
2293 "chosen": true
2294 }
2295 ] /* considered_execution_plans */
2296 },
2297 {
2298 "attaching_conditions_to_tables": {
2299 "original_condition": null,
2300 "attached_conditions_computation": [
2301 ] /* attached_conditions_computation */,
2302 "attached_conditions_summary": [
2303 {
2304 "table": "`t1`",
2305 "attached": null
2306 }
2307 ] /* attached_conditions_summary */
2308 } /* attaching_conditions_to_tables */
2309 },
2310 {
2311 "optimizing_distinct_group_by_order_by": {
2312 } /* optimizing_distinct_group_by_order_by */
2313 },
2314 {
2315 "finalizing_table_conditions": [
2316 ] /* finalizing_table_conditions */
2317 },
2318 {
2319 "refine_plan": [
2320 {
2321 "table": "`t1`"
2322 }
2323 ] /* refine_plan */
2324 },
2325 {
2326 "considering_tmp_tables": [
2327 ] /* considering_tmp_tables */
2328 }
2329 ] /* steps */
2330 } /* join_optimization */
2331 },
2332 {
2333 "join_explain": {
2334 "select#": 1,
2335 "steps": [
2336 {
2337 "join_explain": {
2338 "select#": 2,
2339 "steps": [
2340 ] /* steps */
2341 } /* join_explain */
2342 }
2343 ] /* steps */
2344 } /* join_explain */
2345 }
2346 ] /* steps */
2347 } 0 0
2348 explain select * from t1 where s1 in (select s2 from t1);
2349 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2350 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where
2351 2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
2352 Warnings:
2353 Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t1`.`s2` from `test`.`t1` where (<cache>(`test`.`t1`.`s1`) = `test`.`t1`.`s2`)))
2354 select * from information_schema.OPTIMIZER_TRACE;
2355 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2356 explain select * from t1 where s1 in (select s2 from t1) {
2357 "steps": [
2358 {
2359 "join_preparation": {
2360 "select#": 1,
2361 "steps": [
2362 {
2363 "join_preparation": {
2364 "select#": 2,
2365 "steps": [
2366 {
2367 "expanded_query": "/* select#2 */ select `t1`.`s2` from `t1`"
2368 },
2369 {
2370 "transformation": {
2371 "select#": 2,
2372 "from": "IN (SELECT)",
2373 "to": "EXISTS (CORRELATED SELECT)",
2374 "chosen": true,
2375 "evaluating_constant_where_conditions": [
2376 ] /* evaluating_constant_where_conditions */
2377 } /* transformation */
2378 }
2379 ] /* steps */
2380 } /* join_preparation */
2381 },
2382 {
2383 "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2384 }
2385 ] /* steps */
2386 } /* join_preparation */
2387 },
2388 {
2389 "join_optimization": {
2390 "select#": 1,
2391 "steps": [
2392 {
2393 "condition_processing": {
2394 "condition": "WHERE",
2395 "original_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2396 "steps": [
2397 {
2398 "transformation": "equality_propagation",
2399 "subselect_evaluation": [
2400 ] /* subselect_evaluation */,
2401 "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2402 },
2403 {
2404 "transformation": "constant_propagation",
2405 "subselect_evaluation": [
2406 ] /* subselect_evaluation */,
2407 "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2408 },
2409 {
2410 "transformation": "trivial_condition_removal",
2411 "subselect_evaluation": [
2412 ] /* subselect_evaluation */,
2413 "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2414 }
2415 ] /* steps */
2416 } /* condition_processing */
2417 },
2418 {
2419 "substitute_generated_columns": {
2420 } /* substitute_generated_columns */
2421 },
2422 {
2423 "table_dependencies": [
2424 {
2425 "table": "`t1`",
2426 "row_may_be_null": false,
2427 "map_bit": 0,
2428 "depends_on_map_bits": [
2429 ] /* depends_on_map_bits */
2430 }
2431 ] /* table_dependencies */
2432 },
2433 {
2434 "ref_optimizer_key_uses": [
2435 ] /* ref_optimizer_key_uses */
2436 },
2437 {
2438 "rows_estimation": [
2439 {
2440 "table": "`t1`",
2441 "table_scan": {
2442 "rows": 2,
2443 "cost": 0.505005
2444 } /* table_scan */
2445 }
2446 ] /* rows_estimation */
2447 },
2448 {
2449 "considered_execution_plans": [
2450 {
2451 "plan_prefix": [
2452 ] /* plan_prefix */,
2453 "table": "`t1`",
2454 "best_access_path": {
2455 "considered_access_paths": [
2456 {
2457 "rows_to_scan": 2,
2458 "filtering_effect": [
2459 ] /* filtering_effect */,
2460 "final_filtering_effect": 1,
2461 "access_type": "scan",
2462 "resulting_rows": 2,
2463 "cost": 0.705005,
2464 "chosen": true
2465 }
2466 ] /* considered_access_paths */
2467 } /* best_access_path */,
2468 "condition_filtering_pct": 100,
2469 "rows_for_plan": 2,
2470 "cost_for_plan": 0.705005,
2471 "chosen": true
2472 }
2473 ] /* considered_execution_plans */
2474 },
2475 {
2476 "attaching_conditions_to_tables": {
2477 "original_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2478 "attached_conditions_computation": [
2479 ] /* attached_conditions_computation */,
2480 "attached_conditions_summary": [
2481 {
2482 "table": "`t1`",
2483 "attached": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2484 }
2485 ] /* attached_conditions_summary */
2486 } /* attaching_conditions_to_tables */
2487 },
2488 {
2489 "finalizing_table_conditions": [
2490 {
2491 "table": "`t1`",
2492 "original_table_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2493 "final_table_condition ": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2494 }
2495 ] /* finalizing_table_conditions */
2496 },
2497 {
2498 "refine_plan": [
2499 {
2500 "table": "`t1`"
2501 }
2502 ] /* refine_plan */
2503 }
2504 ] /* steps */
2505 } /* join_optimization */
2506 },
2507 {
2508 "join_optimization": {
2509 "select#": 2,
2510 "steps": [
2511 {
2512 "condition_processing": {
2513 "condition": "WHERE",
2514 "original_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2515 "steps": [
2516 {
2517 "transformation": "equality_propagation",
2518 "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2519 },
2520 {
2521 "transformation": "constant_propagation",
2522 "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2523 },
2524 {
2525 "transformation": "trivial_condition_removal",
2526 "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2527 }
2528 ] /* steps */
2529 } /* condition_processing */
2530 },
2531 {
2532 "substitute_generated_columns": {
2533 } /* substitute_generated_columns */
2534 },
2535 {
2536 "table_dependencies": [
2537 {
2538 "table": "`t1`",
2539 "row_may_be_null": false,
2540 "map_bit": 0,
2541 "depends_on_map_bits": [
2542 ] /* depends_on_map_bits */
2543 }
2544 ] /* table_dependencies */
2545 },
2546 {
2547 "ref_optimizer_key_uses": [
2548 ] /* ref_optimizer_key_uses */
2549 },
2550 {
2551 "rows_estimation": [
2552 {
2553 "table": "`t1`",
2554 "table_scan": {
2555 "rows": 2,
2556 "cost": 0.505005
2557 } /* table_scan */
2558 }
2559 ] /* rows_estimation */
2560 },
2561 {
2562 "considered_execution_plans": [
2563 {
2564 "plan_prefix": [
2565 ] /* plan_prefix */,
2566 "table": "`t1`",
2567 "best_access_path": {
2568 "considered_access_paths": [
2569 {
2570 "rows_to_scan": 2,
2571 "filtering_effect": [
2572 ] /* filtering_effect */,
2573 "final_filtering_effect": 1,
2574 "access_type": "scan",
2575 "resulting_rows": 2,
2576 "cost": 0.705005,
2577 "chosen": true
2578 }
2579 ] /* considered_access_paths */
2580 } /* best_access_path */,
2581 "condition_filtering_pct": 50,
2582 "rows_for_plan": 1,
2583 "cost_for_plan": 0.705005,
2584 "chosen": true
2585 }
2586 ] /* considered_execution_plans */
2587 },
2588 {
2589 "attaching_conditions_to_tables": {
2590 "original_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2591 "attached_conditions_computation": [
2592 ] /* attached_conditions_computation */,
2593 "attached_conditions_summary": [
2594 {
2595 "table": "`t1`",
2596 "attached": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2597 }
2598 ] /* attached_conditions_summary */
2599 } /* attaching_conditions_to_tables */
2600 },
2601 {
2602 "finalizing_table_conditions": [
2603 {
2604 "table": "`t1`",
2605 "original_table_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2606 "final_table_condition ": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2607 }
2608 ] /* finalizing_table_conditions */
2609 },
2610 {
2611 "refine_plan": [
2612 {
2613 "table": "`t1`"
2614 }
2615 ] /* refine_plan */
2616 }
2617 ] /* steps */
2618 } /* join_optimization */
2619 },
2620 {
2621 "join_explain": {
2622 "select#": 1,
2623 "steps": [
2624 {
2625 "join_explain": {
2626 "select#": 2,
2627 "steps": [
2628 ] /* steps */
2629 } /* join_explain */
2630 }
2631 ] /* steps */
2632 } /* join_explain */
2633 }
2634 ] /* steps */
2635 } 0 0
2636 explain select * from t1 where (s1,s2) in (select s2,s1 from t1);
2637 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2638 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where
2639 2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
2640 Warnings:
2641 Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`s1`,`test`.`t1`.`s2`),<exists>(/* select#2 */ select `test`.`t1`.`s2`,`test`.`t1`.`s1` from `test`.`t1` where ((<cache>(`test`.`t1`.`s1`) = `test`.`t1`.`s2`) and (<cache>(`test`.`t1`.`s2`) = `test`.`t1`.`s1`))))
2642 select * from information_schema.OPTIMIZER_TRACE;
2643 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2644 explain select * from t1 where (s1,s2) in (select s2,s1 from t1) {
2645 "steps": [
2646 {
2647 "join_preparation": {
2648 "select#": 1,
2649 "steps": [
2650 {
2651 "join_preparation": {
2652 "select#": 2,
2653 "steps": [
2654 {
2655 "expanded_query": "/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1`"
2656 },
2657 {
2658 "transformation": {
2659 "select#": 2,
2660 "from": "IN (SELECT)",
2661 "to": "EXISTS (CORRELATED SELECT)",
2662 "chosen": true,
2663 "evaluating_constant_where_conditions": [
2664 ] /* evaluating_constant_where_conditions */
2665 } /* transformation */
2666 }
2667 ] /* steps */
2668 } /* join_preparation */
2669 },
2670 {
2671 "expanded_query": "/* select#1 */ select `t1`.`s1` AS `s1`,`t1`.`s2` AS `s2` from `t1` where <in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2672 }
2673 ] /* steps */
2674 } /* join_preparation */
2675 },
2676 {
2677 "join_optimization": {
2678 "select#": 1,
2679 "steps": [
2680 {
2681 "condition_processing": {
2682 "condition": "WHERE",
2683 "original_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))",
2684 "steps": [
2685 {
2686 "transformation": "equality_propagation",
2687 "subselect_evaluation": [
2688 ] /* subselect_evaluation */,
2689 "resulting_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2690 },
2691 {
2692 "transformation": "constant_propagation",
2693 "subselect_evaluation": [
2694 ] /* subselect_evaluation */,
2695 "resulting_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2696 },
2697 {
2698 "transformation": "trivial_condition_removal",
2699 "subselect_evaluation": [
2700 ] /* subselect_evaluation */,
2701 "resulting_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2702 }
2703 ] /* steps */
2704 } /* condition_processing */
2705 },
2706 {
2707 "substitute_generated_columns": {
2708 } /* substitute_generated_columns */
2709 },
2710 {
2711 "table_dependencies": [
2712 {
2713 "table": "`t1`",
2714 "row_may_be_null": false,
2715 "map_bit": 0,
2716 "depends_on_map_bits": [
2717 ] /* depends_on_map_bits */
2718 }
2719 ] /* table_dependencies */
2720 },
2721 {
2722 "ref_optimizer_key_uses": [
2723 ] /* ref_optimizer_key_uses */
2724 },
2725 {
2726 "rows_estimation": [
2727 {
2728 "table": "`t1`",
2729 "table_scan": {
2730 "rows": 2,
2731 "cost": 0.505005
2732 } /* table_scan */
2733 }
2734 ] /* rows_estimation */
2735 },
2736 {
2737 "considered_execution_plans": [
2738 {
2739 "plan_prefix": [
2740 ] /* plan_prefix */,
2741 "table": "`t1`",
2742 "best_access_path": {
2743 "considered_access_paths": [
2744 {
2745 "rows_to_scan": 2,
2746 "filtering_effect": [
2747 ] /* filtering_effect */,
2748 "final_filtering_effect": 1,
2749 "access_type": "scan",
2750 "resulting_rows": 2,
2751 "cost": 0.705005,
2752 "chosen": true
2753 }
2754 ] /* considered_access_paths */
2755 } /* best_access_path */,
2756 "condition_filtering_pct": 100,
2757 "rows_for_plan": 2,
2758 "cost_for_plan": 0.705005,
2759 "chosen": true
2760 }
2761 ] /* considered_execution_plans */
2762 },
2763 {
2764 "attaching_conditions_to_tables": {
2765 "original_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))",
2766 "attached_conditions_computation": [
2767 ] /* attached_conditions_computation */,
2768 "attached_conditions_summary": [
2769 {
2770 "table": "`t1`",
2771 "attached": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2772 }
2773 ] /* attached_conditions_summary */
2774 } /* attaching_conditions_to_tables */
2775 },
2776 {
2777 "finalizing_table_conditions": [
2778 {
2779 "table": "`t1`",
2780 "original_table_condition": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))",
2781 "final_table_condition ": "<in_optimizer>((`t1`.`s1`,`t1`.`s2`),<exists>(/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1` where ((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))))"
2782 }
2783 ] /* finalizing_table_conditions */
2784 },
2785 {
2786 "refine_plan": [
2787 {
2788 "table": "`t1`"
2789 }
2790 ] /* refine_plan */
2791 }
2792 ] /* steps */
2793 } /* join_optimization */
2794 },
2795 {
2796 "join_optimization": {
2797 "select#": 2,
2798 "steps": [
2799 {
2800 "condition_processing": {
2801 "condition": "WHERE",
2802 "original_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2803 "steps": [
2804 {
2805 "transformation": "equality_propagation",
2806 "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2807 },
2808 {
2809 "transformation": "constant_propagation",
2810 "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2811 },
2812 {
2813 "transformation": "trivial_condition_removal",
2814 "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2815 }
2816 ] /* steps */
2817 } /* condition_processing */
2818 },
2819 {
2820 "substitute_generated_columns": {
2821 } /* substitute_generated_columns */
2822 },
2823 {
2824 "table_dependencies": [
2825 {
2826 "table": "`t1`",
2827 "row_may_be_null": false,
2828 "map_bit": 0,
2829 "depends_on_map_bits": [
2830 ] /* depends_on_map_bits */
2831 }
2832 ] /* table_dependencies */
2833 },
2834 {
2835 "ref_optimizer_key_uses": [
2836 ] /* ref_optimizer_key_uses */
2837 },
2838 {
2839 "rows_estimation": [
2840 {
2841 "table": "`t1`",
2842 "table_scan": {
2843 "rows": 2,
2844 "cost": 0.505005
2845 } /* table_scan */
2846 }
2847 ] /* rows_estimation */
2848 },
2849 {
2850 "considered_execution_plans": [
2851 {
2852 "plan_prefix": [
2853 ] /* plan_prefix */,
2854 "table": "`t1`",
2855 "best_access_path": {
2856 "considered_access_paths": [
2857 {
2858 "rows_to_scan": 2,
2859 "filtering_effect": [
2860 ] /* filtering_effect */,
2861 "final_filtering_effect": 1,
2862 "access_type": "scan",
2863 "resulting_rows": 2,
2864 "cost": 0.705005,
2865 "chosen": true
2866 }
2867 ] /* considered_access_paths */
2868 } /* best_access_path */,
2869 "condition_filtering_pct": 50,
2870 "rows_for_plan": 1,
2871 "cost_for_plan": 0.705005,
2872 "chosen": true
2873 }
2874 ] /* considered_execution_plans */
2875 },
2876 {
2877 "attaching_conditions_to_tables": {
2878 "original_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2879 "attached_conditions_computation": [
2880 ] /* attached_conditions_computation */,
2881 "attached_conditions_summary": [
2882 {
2883 "table": "`t1`",
2884 "attached": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2885 }
2886 ] /* attached_conditions_summary */
2887 } /* attaching_conditions_to_tables */
2888 },
2889 {
2890 "finalizing_table_conditions": [
2891 {
2892 "table": "`t1`",
2893 "original_table_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2894 "final_table_condition ": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2895 }
2896 ] /* finalizing_table_conditions */
2897 },
2898 {
2899 "refine_plan": [
2900 {
2901 "table": "`t1`"
2902 }
2903 ] /* refine_plan */
2904 }
2905 ] /* steps */
2906 } /* join_optimization */
2907 },
2908 {
2909 "join_explain": {
2910 "select#": 1,
2911 "steps": [
2912 {
2913 "join_explain": {
2914 "select#": 2,
2915 "steps": [
2916 ] /* steps */
2917 } /* join_explain */
2918 }
2919 ] /* steps */
2920 } /* join_explain */
2921 }
2922 ] /* steps */
2923 } 0 0
2924 set optimizer_switch=@old_opt_switch;
2925 drop table t1;
2926 create table t1(a int);
2927 create table t2(a int);
2928 insert into t1 values(1),(2),(3);
2929 insert into t2 values(1),(2);
2930 set @@session.optimizer_prune_level=0;
2931 explain select * from t1,t2;
2932 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2933 1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
2934 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
2935 Warnings:
2936 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2`
2937 select * from information_schema.OPTIMIZER_TRACE;
2938 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2939 explain select * from t1,t2 {
2940 "steps": [
2941 {
2942 "join_preparation": {
2943 "select#": 1,
2944 "steps": [
2945 {
2946 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
2947 }
2948 ] /* steps */
2949 } /* join_preparation */
2950 },
2951 {
2952 "join_optimization": {
2953 "select#": 1,
2954 "steps": [
2955 {
2956 "table_dependencies": [
2957 {
2958 "table": "`t1`",
2959 "row_may_be_null": false,
2960 "map_bit": 0,
2961 "depends_on_map_bits": [
2962 ] /* depends_on_map_bits */
2963 },
2964 {
2965 "table": "`t2`",
2966 "row_may_be_null": false,
2967 "map_bit": 1,
2968 "depends_on_map_bits": [
2969 ] /* depends_on_map_bits */
2970 }
2971 ] /* table_dependencies */
2972 },
2973 {
2974 "rows_estimation": [
2975 {
2976 "table": "`t1`",
2977 "table_scan": {
2978 "rows": 3,
2979 "cost": 0.501282
2980 } /* table_scan */
2981 },
2982 {
2983 "table": "`t2`",
2984 "table_scan": {
2985 "rows": 2,
2986 "cost": 0.500854
2987 } /* table_scan */
2988 }
2989 ] /* rows_estimation */
2990 },
2991 {
2992 "considered_execution_plans": [
2993 {
2994 "plan_prefix": [
2995 ] /* plan_prefix */,
2996 "table": "`t2`",
2997 "best_access_path": {
2998 "considered_access_paths": [
2999 {
3000 "rows_to_scan": 2,
3001 "access_type": "scan",
3002 "resulting_rows": 2,
3003 "cost": 0.700854,
3004 "chosen": true
3005 }
3006 ] /* considered_access_paths */
3007 } /* best_access_path */,
3008 "condition_filtering_pct": 100,
3009 "rows_for_plan": 2,
3010 "cost_for_plan": 0.700854,
3011 "rest_of_plan": [
3012 {
3013 "plan_prefix": [
3014 "`t2`"
3015 ] /* plan_prefix */,
3016 "table": "`t1`",
3017 "best_access_path": {
3018 "considered_access_paths": [
3019 {
3020 "rows_to_scan": 3,
3021 "access_type": "scan",
3022 "using_join_cache": true,
3023 "buffers_needed": 1,
3024 "resulting_rows": 3,
3025 "cost": 1.1013,
3026 "chosen": true
3027 }
3028 ] /* considered_access_paths */
3029 } /* best_access_path */,
3030 "condition_filtering_pct": 100,
3031 "rows_for_plan": 6,
3032 "cost_for_plan": 1.80216,
3033 "chosen": true
3034 }
3035 ] /* rest_of_plan */
3036 },
3037 {
3038 "plan_prefix": [
3039 ] /* plan_prefix */,
3040 "table": "`t1`",
3041 "best_access_path": {
3042 "considered_access_paths": [
3043 {
3044 "rows_to_scan": 3,
3045 "access_type": "scan",
3046 "resulting_rows": 3,
3047 "cost": 0.801282,
3048 "chosen": true
3049 }
3050 ] /* considered_access_paths */
3051 } /* best_access_path */,
3052 "condition_filtering_pct": 100,
3053 "rows_for_plan": 3,
3054 "cost_for_plan": 0.801282,
3055 "rest_of_plan": [
3056 {
3057 "plan_prefix": [
3058 "`t1`"
3059 ] /* plan_prefix */,
3060 "table": "`t2`",
3061 "best_access_path": {
3062 "considered_access_paths": [
3063 {
3064 "rows_to_scan": 2,
3065 "access_type": "scan",
3066 "using_join_cache": true,
3067 "buffers_needed": 1,
3068 "resulting_rows": 2,
3069 "cost": 1.10088,
3070 "chosen": true
3071 }
3072 ] /* considered_access_paths */
3073 } /* best_access_path */,
3074 "condition_filtering_pct": 100,
3075 "rows_for_plan": 6,
3076 "cost_for_plan": 1.90216,
3077 "pruned_by_cost": true
3078 }
3079 ] /* rest_of_plan */
3080 }
3081 ] /* considered_execution_plans */
3082 },
3083 {
3084 "attaching_conditions_to_tables": {
3085 "original_condition": null,
3086 "attached_conditions_computation": [
3087 ] /* attached_conditions_computation */,
3088 "attached_conditions_summary": [
3089 {
3090 "table": "`t2`",
3091 "attached": null
3092 },
3093 {
3094 "table": "`t1`",
3095 "attached": null
3096 }
3097 ] /* attached_conditions_summary */
3098 } /* attaching_conditions_to_tables */
3099 },
3100 {
3101 "finalizing_table_conditions": [
3102 ] /* finalizing_table_conditions */
3103 },
3104 {
3105 "refine_plan": [
3106 {
3107 "table": "`t2`"
3108 },
3109 {
3110 "table": "`t1`"
3111 }
3112 ] /* refine_plan */
3113 }
3114 ] /* steps */
3115 } /* join_optimization */
3116 },
3117 {
3118 "join_explain": {
3119 "select#": 1,
3120 "steps": [
3121 ] /* steps */
3122 } /* join_explain */
3123 }
3124 ] /* steps */
3125 } 0 0
3126 select @@optimizer_trace_features;
3127 @@optimizer_trace_features
3128 greedy_search=on,range_optimizer=on,dynamic_range=on,repeated_subselect=on
3129 set @@optimizer_trace_features="greedy_search=off";
3130 explain select * from t1,t2;
3131 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
3132 1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
3133 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
3134 Warnings:
3135 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2`
3136 select * from information_schema.OPTIMIZER_TRACE;
3137 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
3138 explain select * from t1,t2 {
3139 "steps": [
3140 {
3141 "join_preparation": {
3142 "select#": 1,
3143 "steps": [
3144 {
3145 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
3146 }
3147 ] /* steps */
3148 } /* join_preparation */
3149 },
3150 {
3151 "join_optimization": {
3152 "select#": 1,
3153 "steps": [
3154 {
3155 "table_dependencies": [
3156 {
3157 "table": "`t1`",
3158 "row_may_be_null": false,
3159 "map_bit": 0,
3160 "depends_on_map_bits": [
3161 ] /* depends_on_map_bits */
3162 },
3163 {
3164 "table": "`t2`",
3165 "row_may_be_null": false,
3166 "map_bit": 1,
3167 "depends_on_map_bits": [
3168 ] /* depends_on_map_bits */
3169 }
3170 ] /* table_dependencies */
3171 },
3172 {
3173 "rows_estimation": [
3174 {
3175 "table": "`t1`",
3176 "table_scan": {
3177 "rows": 3,
3178 "cost": 0.501282
3179 } /* table_scan */
3180 },
3181 {
3182 "table": "`t2`",
3183 "table_scan": {
3184 "rows": 2,
3185 "cost": 0.500854
3186 } /* table_scan */
3187 }
3188 ] /* rows_estimation */
3189 },
3190 {
3191 "considered_execution_plans": "..."
3192 },
3193 {
3194 "attaching_conditions_to_tables": {
3195 "original_condition": null,
3196 "attached_conditions_computation": [
3197 ] /* attached_conditions_computation */,
3198 "attached_conditions_summary": [
3199 {
3200 "table": "`t2`",
3201 "attached": null
3202 },
3203 {
3204 "table": "`t1`",
3205 "attached": null
3206 }
3207 ] /* attached_conditions_summary */
3208 } /* attaching_conditions_to_tables */
3209 },
3210 {
3211 "finalizing_table_conditions": [
3212 ] /* finalizing_table_conditions */
3213 },
3214 {
3215 "refine_plan": [
3216 {
3217 "table": "`t2`"
3218 },
3219 {
3220 "table": "`t1`"
3221 }
3222 ] /* refine_plan */
3223 }
3224 ] /* steps */
3225 } /* join_optimization */
3226 },
3227 {
3228 "join_explain": {
3229 "select#": 1,
3230 "steps": [
3231 ] /* steps */
3232 } /* join_explain */
3233 }
3234 ] /* steps */
3235 } 0 0
3236 set @@optimizer_trace_features=default;
3237 set @@session.optimizer_prune_level=default;
3238 drop table t1, t2;
3239 set @prefix_len = 6;
3240 set @blob_len = 16;
3241 set @suffix_len = @blob_len - @prefix_len;
3242 create table t1_16 (a1 blob(16), a2 blob(16));
3243 create table t2_16 (b1 blob(16), b2 blob(16));
3244 create table t3_16 (c1 blob(16), c2 blob(16));
3245 insert into t1_16 values
3246 (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3247 insert into t1_16 values
3248 (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3249 insert into t1_16 values
3250 (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3251 insert into t2_16 values
3252 (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3253 insert into t2_16 values
3254 (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3255 insert into t2_16 values
3256 (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3257 insert into t3_16 values
3258 (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3259 insert into t3_16 values
3260 (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3261 insert into t3_16 values
3262 (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3263 insert into t3_16 values
3264 (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3265 explain select left(a1,7), left(a2,7)
3266 from t1_16
3267 where a1 in (select b1 from t2_16 where b1 > '0');
3268 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
3269 1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where
3270 2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where
3271 Warnings:
3272 Note 1003 /* select#1 */ select left(`test`.`t1_16`.`a1`,7) AS `left(a1,7)`,left(`test`.`t1_16`.`a2`,7) AS `left(a2,7)` from `test`.`t1_16` where <in_optimizer>(`test`.`t1_16`.`a1`,<exists>(/* select#2 */ select `test`.`t2_16`.`b1` from `test`.`t2_16` where ((`test`.`t2_16`.`b1` > '0') and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`))))
3273 select * from information_schema.OPTIMIZER_TRACE;
3274 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
3275 explain select left(a1,7), left(a2,7)
3276 from t1_16
3277 where a1 in (select b1 from t2_16 where b1 > '0') {
3278 "steps": [
3279 {
3280 "join_preparation": {
3281 "select#": 1,
3282 "steps": [
3283 {
3284 "join_preparation": {
3285 "select#": 2,
3286 "steps": [
3287 {
3288 "expanded_query": "/* select#2 */ select `t2_16`.`b1` from `t2_16` where (`t2_16`.`b1` > '0')"
3289 },
3290 {
3291 "transformation": {
3292 "select#": 2,
3293 "from": "IN (SELECT)",
3294 "to": "EXISTS (CORRELATED SELECT)",
3295 "chosen": true,
3296 "evaluating_constant_where_conditions": [
3297 ] /* evaluating_constant_where_conditions */
3298 } /* transformation */
3299 }
3300 ] /* steps */
3301 } /* join_preparation */
3302 },
3303 {
3304 "expanded_query": "/* select#1 */ select left(`t1_16`.`a1`,7) AS `left(a1,7)`,left(`t1_16`.`a2`,7) AS `left(a2,7)` from `t1_16` where <in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3305 }
3306 ] /* steps */
3307 } /* join_preparation */
3308 },
3309 {
3310 "join_optimization": {
3311 "select#": 1,
3312 "steps": [
3313 {
3314 "condition_processing": {
3315 "condition": "WHERE",
3316 "original_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))",
3317 "steps": [
3318 {
3319 "transformation": "equality_propagation",
3320 "subselect_evaluation": [
3321 ] /* subselect_evaluation */,
3322 "resulting_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3323 },
3324 {
3325 "transformation": "constant_propagation",
3326 "subselect_evaluation": [
3327 ] /* subselect_evaluation */,
3328 "resulting_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3329 },
3330 {
3331 "transformation": "trivial_condition_removal",
3332 "subselect_evaluation": [
3333 ] /* subselect_evaluation */,
3334 "resulting_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3335 }
3336 ] /* steps */
3337 } /* condition_processing */
3338 },
3339 {
3340 "substitute_generated_columns": {
3341 } /* substitute_generated_columns */
3342 },
3343 {
3344 "table_dependencies": [
3345 {
3346 "table": "`t1_16`",
3347 "row_may_be_null": false,
3348 "map_bit": 0,
3349 "depends_on_map_bits": [
3350 ] /* depends_on_map_bits */
3351 }
3352 ] /* table_dependencies */
3353 },
3354 {
3355 "ref_optimizer_key_uses": [
3356 ] /* ref_optimizer_key_uses */
3357 },
3358 {
3359 "rows_estimation": [
3360 {
3361 "table": "`t1_16`",
3362 "table_scan": {
3363 "rows": 3,
3364 "cost": 0.507324
3365 } /* table_scan */
3366 }
3367 ] /* rows_estimation */
3368 },
3369 {
3370 "considered_execution_plans": [
3371 {
3372 "plan_prefix": [
3373 ] /* plan_prefix */,
3374 "table": "`t1_16`",
3375 "best_access_path": {
3376 "considered_access_paths": [
3377 {
3378 "rows_to_scan": 3,
3379 "filtering_effect": [
3380 ] /* filtering_effect */,
3381 "final_filtering_effect": 1,
3382 "access_type": "scan",
3383 "resulting_rows": 3,
3384 "cost": 0.807324,
3385 "chosen": true
3386 }
3387 ] /* considered_access_paths */
3388 } /* best_access_path */,
3389 "condition_filtering_pct": 100,
3390 "rows_for_plan": 3,
3391 "cost_for_plan": 0.807324,
3392 "chosen": true
3393 }
3394 ] /* considered_execution_plans */
3395 },
3396 {
3397 "attaching_conditions_to_tables": {
3398 "original_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))",
3399 "attached_conditions_computation": [
3400 ] /* attached_conditions_computation */,
3401 "attached_conditions_summary": [
3402 {
3403 "table": "`t1_16`",
3404 "attached": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3405 }
3406 ] /* attached_conditions_summary */
3407 } /* attaching_conditions_to_tables */
3408 },
3409 {
3410 "finalizing_table_conditions": [
3411 {
3412 "table": "`t1_16`",
3413 "original_table_condition": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))",
3414 "final_table_condition ": "<in_optimizer>(`t1_16`.`a1`,<exists>(/* select#2 */ select `t2_16`.`b1` from `t2_16` where ((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))))"
3415 }
3416 ] /* finalizing_table_conditions */
3417 },
3418 {
3419 "refine_plan": [
3420 {
3421 "table": "`t1_16`"
3422 }
3423 ] /* refine_plan */
3424 }
3425 ] /* steps */
3426 } /* join_optimization */
3427 },
3428 {
3429 "join_optimization": {
3430 "select#": 2,
3431 "steps": [
3432 {
3433 "condition_processing": {
3434 "condition": "WHERE",
3435 "original_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3436 "steps": [
3437 {
3438 "transformation": "equality_propagation",
3439 "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3440 },
3441 {
3442 "transformation": "constant_propagation",
3443 "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3444 },
3445 {
3446 "transformation": "trivial_condition_removal",
3447 "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3448 }
3449 ] /* steps */
3450 } /* condition_processing */
3451 },
3452 {
3453 "substitute_generated_columns": {
3454 } /* substitute_generated_columns */
3455 },
3456 {
3457 "table_dependencies": [
3458 {
3459 "table": "`t2_16`",
3460 "row_may_be_null": false,
3461 "map_bit": 0,
3462 "depends_on_map_bits": [
3463 ] /* depends_on_map_bits */
3464 }
3465 ] /* table_dependencies */
3466 },
3467 {
3468 "ref_optimizer_key_uses": [
3469 ] /* ref_optimizer_key_uses */
3470 },
3471 {
3472 "rows_estimation": [
3473 {
3474 "table": "`t2_16`",
3475 "table_scan": {
3476 "rows": 3,
3477 "cost": 0.507324
3478 } /* table_scan */
3479 }
3480 ] /* rows_estimation */
3481 },
3482 {
3483 "considered_execution_plans": [
3484 {
3485 "plan_prefix": [
3486 ] /* plan_prefix */,
3487 "table": "`t2_16`",
3488 "best_access_path": {
3489 "considered_access_paths": [
3490 {
3491 "rows_to_scan": 3,
3492 "filtering_effect": [
3493 ] /* filtering_effect */,
3494 "final_filtering_effect": 0.333333,
3495 "access_type": "scan",
3496 "resulting_rows": 1,
3497 "cost": 0.807324,
3498 "chosen": true
3499 }
3500 ] /* considered_access_paths */
3501 } /* best_access_path */,
3502 "condition_filtering_pct": 100,
3503 "rows_for_plan": 1,
3504 "cost_for_plan": 0.807324,
3505 "chosen": true
3506 }
3507 ] /* considered_execution_plans */
3508 },
3509 {
3510 "transformation": {
3511 "select#": 2,
3512 "from": "IN (SELECT)",
3513 "to": "materialization",
3514 "possible": false,
3515 "cause": "inner blob"
3516 } /* transformation */
3517 },
3518 {
3519 "attaching_conditions_to_tables": {
3520 "original_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3521 "attached_conditions_computation": [
3522 ] /* attached_conditions_computation */,
3523 "attached_conditions_summary": [
3524 {
3525 "table": "`t2_16`",
3526 "attached": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3527 }
3528 ] /* attached_conditions_summary */
3529 } /* attaching_conditions_to_tables */
3530 },
3531 {
3532 "finalizing_table_conditions": [
3533 {
3534 "table": "`t2_16`",
3535 "original_table_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3536 "final_table_condition ": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3537 }
3538 ] /* finalizing_table_conditions */
3539 },
3540 {
3541 "refine_plan": [
3542 {
3543 "table": "`t2_16`"
3544 }
3545 ] /* refine_plan */
3546 }
3547 ] /* steps */
3548 } /* join_optimization */
3549 },
3550 {
3551 "join_explain": {
3552 "select#": 1,
3553 "steps": [
3554 {
3555 "join_explain": {
3556 "select#": 2,
3557 "steps": [
3558 ] /* steps */
3559 } /* join_explain */
3560 }
3561 ] /* steps */
3562 } /* join_explain */
3563 }
3564 ] /* steps */
3565 } 0 0
3566 drop table t1_16,t2_16,t3_16;
3567 set @@optimizer_switch=@old_opt_switch;
3568 CREATE table t1 ( c1 integer );
3569 INSERT INTO t1 VALUES ( 1 );
3570 INSERT INTO t1 VALUES ( 2 );
3571 INSERT INTO t1 VALUES ( 3 );
3572 CREATE TABLE t2 ( c2 integer );
3573 INSERT INTO t2 VALUES ( 1 );
3574 INSERT INTO t2 VALUES ( 4 );
3575 INSERT INTO t2 VALUES ( 5 );
3576 SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
3577 WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
3578 c1 c2
3579 1 1
3580 select * from information_schema.OPTIMIZER_TRACE;
3581 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
3582 SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
3583 WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) ) {
3584 "steps": [
3585 {
3586 "join_preparation": {
3587 "select#": 1,
3588 "steps": [
3589 {
3590 "join_preparation": {
3591 "select#": 2,
3592 "steps": [
3593 {
3594 "expanded_query": "/* select#2 */ select `t2`.`c2` from `t2` where (`t2`.`c2` = 1)"
3595 }
3596 ] /* steps */
3597 } /* join_preparation */
3598 },
3599 {
3600 "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t2`.`c2` AS `c2` from (`t1` left join `t2` on((`t1`.`c1` = `t2`.`c2`))) where `t2`.`c2` in (/* select#2 */ select `t2`.`c2` from `t2` where (`t2`.`c2` = 1))"
3601 },
3602 {
3603 "transformation": {
3604 "select#": 2,
3605 "from": "IN (SELECT)",
3606 "to": "semijoin",
3607 "chosen": true,
3608 "transformation_to_semi_join": {
3609 "subquery_predicate": "`t2`.`c2` in (/* select#2 */ select `t2`.`c2` from `t2` where (`t2`.`c2` = 1))",
3610 "embedded in": "WHERE",
3611 "evaluating_constant_semijoin_conditions": [
3612 ] /* evaluating_constant_semijoin_conditions */,
3613 "semi-join condition": "((`t2`.`c2` = 1) and (`t2`.`c2` = `t2`.`c2`))",
3614 "decorrelated_predicates": [
3615 {
3616 "outer": "`t2`.`c2`",
3617 "inner": "`t2`.`c2`"
3618 }
3619 ] /* decorrelated_predicates */
3620 } /* transformation_to_semi_join */
3621 } /* transformation */
3622 },
3623 {
3624 "transformations_to_nested_joins": {
3625 "transformations": [
3626 "semijoin",
3627 "outer_join_to_inner_join",
3628 "JOIN_condition_to_WHERE",
3629 "parenthesis_removal"
3630 ] /* transformations */,
3631 "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1`,`t2`.`c2` AS `c2` from `t1` join `t2` semi join (`t2`) where ((`t2`.`c2` = 1) and (`t2`.`c2` = `t2`.`c2`) and (`t1`.`c1` = `t2`.`c2`))"
3632 } /* transformations_to_nested_joins */
3633 }
3634 ] /* steps */
3635 } /* join_preparation */
3636 },
3637 {
3638 "join_optimization": {
3639 "select#": 1,
3640 "steps": [
3641 {
3642 "condition_processing": {
3643 "condition": "WHERE",
3644 "original_condition": "((`t2`.`c2` = 1) and (`t2`.`c2` = `t2`.`c2`) and (`t1`.`c1` = `t2`.`c2`))",
3645 "steps": [
3646 {
3647 "transformation": "equality_propagation",
3648 "resulting_condition": "(multiple equal(1, `t2`.`c2`, `t2`.`c2`, `t1`.`c1`))"
3649 },
3650 {
3651 "transformation": "constant_propagation",
3652 "resulting_condition": "(multiple equal(1, `t2`.`c2`, `t2`.`c2`, `t1`.`c1`))"
3653 },
3654 {
3655 "transformation": "trivial_condition_removal",
3656 "resulting_condition": "multiple equal(1, `t2`.`c2`, `t2`.`c2`, `t1`.`c1`)"
3657 }
3658 ] /* steps */
3659 } /* condition_processing */
3660 },
3661 {
3662 "substitute_generated_columns": {
3663 } /* substitute_generated_columns */
3664 },
3665 {
3666 "table_dependencies": [
3667 {
3668 "table": "`t1`",
3669 "row_may_be_null": false,
3670 "map_bit": 0,
3671 "depends_on_map_bits": [
3672 ] /* depends_on_map_bits */
3673 },
3674 {
3675 "table": "`t2`",
3676 "row_may_be_null": true,
3677 "map_bit": 1,
3678 "depends_on_map_bits": [
3679 ] /* depends_on_map_bits */
3680 },
3681 {
3682 "table": "`t2`",
3683 "row_may_be_null": false,
3684 "map_bit": 2,
3685 "depends_on_map_bits": [
3686 ] /* depends_on_map_bits */
3687 }
3688 ] /* table_dependencies */
3689 },
3690 {
3691 "ref_optimizer_key_uses": [
3692 ] /* ref_optimizer_key_uses */
3693 },
3694 {
3695 "pulled_out_semijoin_tables": [
3696 ] /* pulled_out_semijoin_tables */
3697 },
3698 {
3699 "rows_estimation": [
3700 {
3701 "table": "`t1`",
3702 "table_scan": {
3703 "rows": 3,
3704 "cost": 0.501282
3705 } /* table_scan */
3706 },
3707 {
3708 "table": "`t2`",
3709 "table_scan": {
3710 "rows": 3,
3711 "cost": 0.501282
3712 } /* table_scan */
3713 },
3714 {
3715 "table": "`t2`",
3716 "table_scan": {
3717 "rows": 3,
3718 "cost": 0.501282
3719 } /* table_scan */
3720 }
3721 ] /* rows_estimation */
3722 },
3723 {
3724 "execution_plan_for_potential_materialization": {
3725 "steps": [
3726 {
3727 "considered_execution_plans": [
3728 {
3729 "plan_prefix": [
3730 ] /* plan_prefix */,
3731 "table": "`t2`",
3732 "best_access_path": {
3733 "considered_access_paths": [
3734 {
3735 "rows_to_scan": 3,
3736 "filtering_effect": [
3737 ] /* filtering_effect */,
3738 "final_filtering_effect": 0.333333,
3739 "access_type": "scan",
3740 "resulting_rows": 1,
3741 "cost": 0.801282,
3742 "chosen": true
3743 }
3744 ] /* considered_access_paths */
3745 } /* best_access_path */,
3746 "condition_filtering_pct": 100,
3747 "rows_for_plan": 1,
3748 "cost_for_plan": 0.801282,
3749 "chosen": true
3750 }
3751 ] /* considered_execution_plans */
3752 }
3753 ] /* steps */
3754 } /* execution_plan_for_potential_materialization */
3755 },
3756 {
3757 "considered_execution_plans": [
3758 {
3759 "plan_prefix": [
3760 ] /* plan_prefix */,
3761 "table": "`t1`",
3762 "best_access_path": {
3763 "considered_access_paths": [
3764 {
3765 "rows_to_scan": 3,
3766 "filtering_effect": [
3767 ] /* filtering_effect */,
3768 "final_filtering_effect": 0.333333,
3769 "access_type": "scan",
3770 "resulting_rows": 1,
3771 "cost": 0.801282,
3772 "chosen": true
3773 }
3774 ] /* considered_access_paths */
3775 } /* best_access_path */,
3776 "condition_filtering_pct": 100,
3777 "rows_for_plan": 1,
3778 "cost_for_plan": 0.801282,
3779 "semijoin_strategy_choice": [
3780 ] /* semijoin_strategy_choice */,
3781 "rest_of_plan": [
3782 {
3783 "plan_prefix": [
3784 "`t1`"
3785 ] /* plan_prefix */,
3786 "table": "`t2`",
3787 "best_access_path": {
3788 "considered_access_paths": [
3789 {
3790 "rows_to_scan": 3,
3791 "filtering_effect": [
3792 ] /* filtering_effect */,
3793 "final_filtering_effect": 0.333333,
3794 "access_type": "scan",
3795 "using_join_cache": true,
3796 "buffers_needed": 1,
3797 "resulting_rows": 1,
3798 "cost": 0.801295,
3799 "chosen": true
3800 }
3801 ] /* considered_access_paths */
3802 } /* best_access_path */,
3803 "condition_filtering_pct": 100,
3804 "rows_for_plan": 1,
3805 "cost_for_plan": 1.60258,
3806 "semijoin_strategy_choice": [
3807 ] /* semijoin_strategy_choice */,
3808 "rest_of_plan": [
3809 {
3810 "plan_prefix": [
3811 "`t1`",
3812 "`t2`"
3813 ] /* plan_prefix */,
3814 "table": "`t2`",
3815 "best_access_path": {
3816 "considered_access_paths": [
3817 {
3818 "rows_to_scan": 3,
3819 "filtering_effect": [
3820 ] /* filtering_effect */,
3821 "final_filtering_effect": 0.333333,
3822 "access_type": "scan",
3823 "using_join_cache": true,
3824 "buffers_needed": 1,
3825 "resulting_rows": 1,
3826 "cost": 0.801311,
3827 "chosen": true
3828 }
3829 ] /* considered_access_paths */
3830 } /* best_access_path */,
3831 "condition_filtering_pct": 100,
3832 "rows_for_plan": 1,
3833 "cost_for_plan": 2.40389,
3834 "semijoin_strategy_choice": [
3835 {
3836 "strategy": "FirstMatch",
3837 "recalculate_access_paths_and_cost": {
3838 "tables": [
3839 {
3840 "table": "`t2`",
3841 "best_access_path": {
3842 "considered_access_paths": [
3843 {
3844 "rows_to_scan": 3,
3845 "filtering_effect": [
3846 ] /* filtering_effect */,
3847 "final_filtering_effect": 0.333333,
3848 "access_type": "scan",
3849 "using_join_cache": true,
3850 "buffers_needed": 1,
3851 "resulting_rows": 1,
3852 "cost": 0.801311,
3853 "chosen": true
3854 }
3855 ] /* considered_access_paths */
3856 } /* best_access_path */
3857 }
3858 ] /* tables */
3859 } /* recalculate_access_paths_and_cost */,
3860 "cost": 2.40389,
3861 "rows": 1,
3862 "chosen": true
3863 },
3864 {
3865 "strategy": "MaterializeLookup",
3866 "cost": 3.60386,
3867 "rows": 1,
3868 "duplicate_tables_left": false,
3869 "chosen": false
3870 },
3871 {
3872 "strategy": "DuplicatesWeedout",
3873 "cost": 3.60389,
3874 "rows": 1,
3875 "duplicate_tables_left": false,
3876 "chosen": false
3877 }
3878 ] /* semijoin_strategy_choice */,
3879 "chosen": true
3880 }
3881 ] /* rest_of_plan */
3882 },
3883 {
3884 "plan_prefix": [
3885 "`t1`"
3886 ] /* plan_prefix */,
3887 "table": "`t2`",
3888 "best_access_path": {
3889 "considered_access_paths": [
3890 {
3891 "rows_to_scan": 3,
3892 "filtering_effect": [
3893 ] /* filtering_effect */,
3894 "final_filtering_effect": 0.333333,
3895 "access_type": "scan",
3896 "using_join_cache": true,
3897 "buffers_needed": 1,
3898 "resulting_rows": 1,
3899 "cost": 0.801295,
3900 "chosen": true
3901 }
3902 ] /* considered_access_paths */
3903 } /* best_access_path */,
3904 "condition_filtering_pct": 100,
3905 "rows_for_plan": 1,
3906 "cost_for_plan": 1.60258,
3907 "semijoin_strategy_choice": [
3908 {
3909 "strategy": "MaterializeScan",
3910 "choice": "deferred"
3911 }
3912 ] /* semijoin_strategy_choice */,
3913 "pruned_by_heuristic": true
3914 }
3915 ] /* rest_of_plan */
3916 },
3917 {
3918 "plan_prefix": [
3919 ] /* plan_prefix */,
3920 "table": "`t2`",
3921 "best_access_path": {
3922 "considered_access_paths": [
3923 {
3924 "rows_to_scan": 3,
3925 "filtering_effect": [
3926 ] /* filtering_effect */,
3927 "final_filtering_effect": 0.333333,
3928 "access_type": "scan",
3929 "resulting_rows": 1,
3930 "cost": 0.801282,
3931 "chosen": true
3932 }
3933 ] /* considered_access_paths */
3934 } /* best_access_path */,
3935 "condition_filtering_pct": 100,
3936 "rows_for_plan": 1,
3937 "cost_for_plan": 0.801282,
3938 "semijoin_strategy_choice": [
3939 ] /* semijoin_strategy_choice */,
3940 "pruned_by_heuristic": true
3941 },
3942 {
3943 "plan_prefix": [
3944 ] /* plan_prefix */,
3945 "table": "`t2`",
3946 "best_access_path": {
3947 "considered_access_paths": [
3948 {
3949 "rows_to_scan": 3,
3950 "filtering_effect": [
3951 ] /* filtering_effect */,
3952 "final_filtering_effect": 0.333333,
3953 "access_type": "scan",
3954 "resulting_rows": 1,
3955 "cost": 0.801282,
3956 "chosen": true
3957 }
3958 ] /* considered_access_paths */
3959 } /* best_access_path */,
3960 "condition_filtering_pct": 100,
3961 "rows_for_plan": 1,
3962 "cost_for_plan": 0.801282,
3963 "semijoin_strategy_choice": [
3964 {
3965 "strategy": "MaterializeScan",
3966 "choice": "deferred"
3967 }
3968 ] /* semijoin_strategy_choice */,
3969 "pruned_by_heuristic": true
3970 },
3971 {
3972 "final_semijoin_strategy": "FirstMatch",
3973 "recalculate_access_paths_and_cost": {
3974 "tables": [
3975 {
3976 "table": "`t2`",
3977 "best_access_path": {
3978 "considered_access_paths": [
3979 {
3980 "rows_to_scan": 3,
3981 "filtering_effect": [
3982 ] /* filtering_effect */,
3983 "final_filtering_effect": 0.333333,
3984 "access_type": "scan",
3985 "using_join_cache": true,
3986 "buffers_needed": 1,
3987 "resulting_rows": 1,
3988 "cost": 0.801311,
3989 "chosen": true
3990 }
3991 ] /* considered_access_paths */
3992 } /* best_access_path */
3993 }
3994 ] /* tables */
3995 } /* recalculate_access_paths_and_cost */
3996 }
3997 ] /* considered_execution_plans */
3998 },
3999 {
4000 "attaching_conditions_to_tables": {
4001 "original_condition": "((`t1`.`c1` = 1) and (`t2`.`c2` = 1) and (`t2`.`c2` = 1))",
4002 "attached_conditions_computation": [
4003 ] /* attached_conditions_computation */,
4004 "attached_conditions_summary": [
4005 {
4006 "table": "`t1`",
4007 "attached": "(`t1`.`c1` = 1)"
4008 },
4009 {
4010 "table": "`t2`",
4011 "attached": "(`t2`.`c2` = 1)"
4012 },
4013 {
4014 "table": "`t2`",
4015 "attached": "(`t2`.`c2` = 1)"
4016 }
4017 ] /* attached_conditions_summary */
4018 } /* attaching_conditions_to_tables */
4019 },
4020 {
4021 "finalizing_table_conditions": [
4022 {
4023 "table": "`t1`",
4024 "original_table_condition": "(`t1`.`c1` = 1)",
4025 "final_table_condition ": "(`t1`.`c1` = 1)"
4026 },
4027 {
4028 "table": "`t2`",
4029 "original_table_condition": "(`t2`.`c2` = 1)",
4030 "final_table_condition ": "(`t2`.`c2` = 1)"
4031 },
4032 {
4033 "table": "`t2`",
4034 "original_table_condition": "(`t2`.`c2` = 1)",
4035 "final_table_condition ": "(`t2`.`c2` = 1)"
4036 }
4037 ] /* finalizing_table_conditions */
4038 },
4039 {
4040 "refine_plan": [
4041 {
4042 "table": "`t1`"
4043 },
4044 {
4045 "table": "`t2`"
4046 },
4047 {
4048 "table": "`t2`"
4049 }
4050 ] /* refine_plan */
4051 }
4052 ] /* steps */
4053 } /* join_optimization */
4054 },
4055 {
4056 "join_execution": {
4057 "select#": 1,
4058 "steps": [
4059 ] /* steps */
4060 } /* join_execution */
4061 }
4062 ] /* steps */
4063 } 0 0
4064 SELECT * FROM t1 WHERE c1=5 UNION SELECT * FROM t2 WHERE c2=5;
4065 c1
4066 5
4067 select * from information_schema.OPTIMIZER_TRACE;
4068 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
4069 SELECT * FROM t1 WHERE c1=5 UNION SELECT * FROM t2 WHERE c2=5 {
4070 "steps": [
4071 {
4072 "join_preparation": {
4073 "select#": 1,
4074 "steps": [
4075 {
4076 "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1` from `t1` where (`t1`.`c1` = 5)"
4077 }
4078 ] /* steps */
4079 } /* join_preparation */
4080 },
4081 {
4082 "join_preparation": {
4083 "select#": 2,
4084 "steps": [
4085 {
4086 "expanded_query": "/* select#2 */ select `t2`.`c2` AS `c2` from `t2` where (`t2`.`c2` = 5)"
4087 }
4088 ] /* steps */
4089 } /* join_preparation */
4090 },
4091 {
4092 "creating_tmp_table": {
4093 "tmp_table_info": {
4094 "table": "<union temporary>",
4095 "columns": 1,
4096 "row_length": 5,
4097 "key_length": 5,
4098 "unique_constraint": false,
4099 "makes_grouped_rows": false,
4100 "cannot_insert_duplicates": true,
4101 "location": "TempTable"
4102 } /* tmp_table_info */
4103 } /* creating_tmp_table */
4104 },
4105 {
4106 "join_preparation": {
4107 "select#": 3,
4108 "steps": [
4109 {
4110 "expanded_query": "/* select#3 */ select `c1` AS `c1` from dual"
4111 }
4112 ] /* steps */
4113 } /* join_preparation */
4114 },
4115 {
4116 "join_optimization": {
4117 "select#": 1,
4118 "steps": [
4119 {
4120 "condition_processing": {
4121 "condition": "WHERE",
4122 "original_condition": "(`t1`.`c1` = 5)",
4123 "steps": [
4124 {
4125 "transformation": "equality_propagation",
4126 "resulting_condition": "multiple equal(5, `t1`.`c1`)"
4127 },
4128 {
4129 "transformation": "constant_propagation",
4130 "resulting_condition": "multiple equal(5, `t1`.`c1`)"
4131 },
4132 {
4133 "transformation": "trivial_condition_removal",
4134 "resulting_condition": "multiple equal(5, `t1`.`c1`)"
4135 }
4136 ] /* steps */
4137 } /* condition_processing */
4138 },
4139 {
4140 "substitute_generated_columns": {
4141 } /* substitute_generated_columns */
4142 },
4143 {
4144 "table_dependencies": [
4145 {
4146 "table": "`t1`",
4147 "row_may_be_null": false,
4148 "map_bit": 0,
4149 "depends_on_map_bits": [
4150 ] /* depends_on_map_bits */
4151 }
4152 ] /* table_dependencies */
4153 },
4154 {
4155 "ref_optimizer_key_uses": [
4156 ] /* ref_optimizer_key_uses */
4157 },
4158 {
4159 "rows_estimation": [
4160 {
4161 "table": "`t1`",
4162 "table_scan": {
4163 "rows": 3,
4164 "cost": 0.501282
4165 } /* table_scan */
4166 }
4167 ] /* rows_estimation */
4168 },
4169 {
4170 "considered_execution_plans": [
4171 {
4172 "plan_prefix": [
4173 ] /* plan_prefix */,
4174 "table": "`t1`",
4175 "best_access_path": {
4176 "considered_access_paths": [
4177 {
4178 "rows_to_scan": 3,
4179 "access_type": "scan",
4180 "resulting_rows": 3,
4181 "cost": 0.801282,
4182 "chosen": true
4183 }
4184 ] /* considered_access_paths */
4185 } /* best_access_path */,
4186 "condition_filtering_pct": 100,
4187 "rows_for_plan": 3,
4188 "cost_for_plan": 0.801282,
4189 "chosen": true
4190 }
4191 ] /* considered_execution_plans */
4192 },
4193 {
4194 "attaching_conditions_to_tables": {
4195 "original_condition": "(`t1`.`c1` = 5)",
4196 "attached_conditions_computation": [
4197 ] /* attached_conditions_computation */,
4198 "attached_conditions_summary": [
4199 {
4200 "table": "`t1`",
4201 "attached": "(`t1`.`c1` = 5)"
4202 }
4203 ] /* attached_conditions_summary */
4204 } /* attaching_conditions_to_tables */
4205 },
4206 {
4207 "finalizing_table_conditions": [
4208 {
4209 "table": "`t1`",
4210 "original_table_condition": "(`t1`.`c1` = 5)",
4211 "final_table_condition ": "(`t1`.`c1` = 5)"
4212 }
4213 ] /* finalizing_table_conditions */
4214 },
4215 {
4216 "refine_plan": [
4217 {
4218 "table": "`t1`"
4219 }
4220 ] /* refine_plan */
4221 }
4222 ] /* steps */
4223 } /* join_optimization */
4224 },
4225 {
4226 "join_optimization": {
4227 "select#": 2,
4228 "steps": [
4229 {
4230 "condition_processing": {
4231 "condition": "WHERE",
4232 "original_condition": "(`t2`.`c2` = 5)",
4233 "steps": [
4234 {
4235 "transformation": "equality_propagation",
4236 "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4237 },
4238 {
4239 "transformation": "constant_propagation",
4240 "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4241 },
4242 {
4243 "transformation": "trivial_condition_removal",
4244 "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4245 }
4246 ] /* steps */
4247 } /* condition_processing */
4248 },
4249 {
4250 "substitute_generated_columns": {
4251 } /* substitute_generated_columns */
4252 },
4253 {
4254 "table_dependencies": [
4255 {
4256 "table": "`t2`",
4257 "row_may_be_null": false,
4258 "map_bit": 0,
4259 "depends_on_map_bits": [
4260 ] /* depends_on_map_bits */
4261 }
4262 ] /* table_dependencies */
4263 },
4264 {
4265 "ref_optimizer_key_uses": [
4266 ] /* ref_optimizer_key_uses */
4267 },
4268 {
4269 "rows_estimation": [
4270 {
4271 "table": "`t2`",
4272 "table_scan": {
4273 "rows": 3,
4274 "cost": 0.501282
4275 } /* table_scan */
4276 }
4277 ] /* rows_estimation */
4278 },
4279 {
4280 "considered_execution_plans": [
4281 {
4282 "plan_prefix": [
4283 ] /* plan_prefix */,
4284 "table": "`t2`",
4285 "best_access_path": {
4286 "considered_access_paths": [
4287 {
4288 "rows_to_scan": 3,
4289 "access_type": "scan",
4290 "resulting_rows": 3,
4291 "cost": 0.801282,
4292 "chosen": true
4293 }
4294 ] /* considered_access_paths */
4295 } /* best_access_path */,
4296 "condition_filtering_pct": 100,
4297 "rows_for_plan": 3,
4298 "cost_for_plan": 0.801282,
4299 "chosen": true
4300 }
4301 ] /* considered_execution_plans */
4302 },
4303 {
4304 "attaching_conditions_to_tables": {
4305 "original_condition": "(`t2`.`c2` = 5)",
4306 "attached_conditions_computation": [
4307 ] /* attached_conditions_computation */,
4308 "attached_conditions_summary": [
4309 {
4310 "table": "`t2`",
4311 "attached": "(`t2`.`c2` = 5)"
4312 }
4313 ] /* attached_conditions_summary */
4314 } /* attaching_conditions_to_tables */
4315 },
4316 {
4317 "finalizing_table_conditions": [
4318 {
4319 "table": "`t2`",
4320 "original_table_condition": "(`t2`.`c2` = 5)",
4321 "final_table_condition ": "(`t2`.`c2` = 5)"
4322 }
4323 ] /* finalizing_table_conditions */
4324 },
4325 {
4326 "refine_plan": [
4327 {
4328 "table": "`t2`"
4329 }
4330 ] /* refine_plan */
4331 }
4332 ] /* steps */
4333 } /* join_optimization */
4334 },
4335 {
4336 "join_optimization": {
4337 "select#": 3,
4338 "steps": [
4339 {
4340 "table_dependencies": [
4341 {
4342 "table": "``",
4343 "row_may_be_null": false,
4344 "map_bit": 0,
4345 "depends_on_map_bits": [
4346 ] /* depends_on_map_bits */
4347 }
4348 ] /* table_dependencies */
4349 },
4350 {
4351 "rows_estimation": [
4352 {
4353 "table": "``",
4354 "table_scan": {
4355 "rows": 0,
4356 "cost": 2.5
4357 } /* table_scan */
4358 }
4359 ] /* rows_estimation */
4360 },
4361 {
4362 "considered_execution_plans": [
4363 {
4364 "plan_prefix": [
4365 ] /* plan_prefix */,
4366 "table": "``",
4367 "best_access_path": {
4368 "considered_access_paths": [
4369 {
4370 "rows_to_scan": 0,
4371 "access_type": "scan",
4372 "resulting_rows": 0,
4373 "cost": 2.5,
4374 "chosen": true
4375 }
4376 ] /* considered_access_paths */
4377 } /* best_access_path */,
4378 "condition_filtering_pct": 100,
4379 "rows_for_plan": 0,
4380 "cost_for_plan": 2.5,
4381 "chosen": true
4382 }
4383 ] /* considered_execution_plans */
4384 },
4385 {
4386 "attaching_conditions_to_tables": {
4387 "original_condition": null,
4388 "attached_conditions_computation": [
4389 ] /* attached_conditions_computation */,
4390 "attached_conditions_summary": [
4391 {
4392 "table": "``",
4393 "attached": null
4394 }
4395 ] /* attached_conditions_summary */
4396 } /* attaching_conditions_to_tables */
4397 },
4398 {
4399 "finalizing_table_conditions": [
4400 ] /* finalizing_table_conditions */
4401 },
4402 {
4403 "refine_plan": [
4404 {
4405 "table": "``"
4406 }
4407 ] /* refine_plan */
4408 }
4409 ] /* steps */
4410 } /* join_optimization */
4411 },
4412 {
4413 "join_execution": {
4414 "steps": [
4415 {
4416 "materialize": {
4417 "select#": 1,
4418 "steps": [
4419 ] /* steps */
4420 } /* materialize */
4421 },
4422 {
4423 "materialize": {
4424 "select#": 2,
4425 "steps": [
4426 ] /* steps */
4427 } /* materialize */
4428 }
4429 ] /* steps */
4430 } /* join_execution */
4431 }
4432 ] /* steps */
4433 } 0 0
4434 explain
4435 select * from t1
4436 where concat(c1,'x') IN
4437 (select left(c2,8) from t2)
4438 and
4439 concat(c1,'y') IN
4440 (select left(c2,9) from t2);
4441 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
4442 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where
4443 3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
4444 2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
4445 Warnings:
4446 Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (<in_optimizer>(concat(`test`.`t1`.`c1`,'x'),concat(`test`.`t1`.`c1`,'x') in ( <materialize> (/* select#2 */ select left(`test`.`t2`.`c2`,8) from `test`.`t2` where true ), <primary_index_lookup>(concat(`test`.`t1`.`c1`,'x') in <temporary table> on <auto_distinct_key> where ((concat(`test`.`t1`.`c1`,'x') = `<materialized_subquery>`.`left(c2,8)`))))) and <in_optimizer>(concat(`test`.`t1`.`c1`,'y'),concat(`test`.`t1`.`c1`,'y') in ( <materialize> (/* select#3 */ select left(`test`.`t2`.`c2`,9) from `test`.`t2` where true ), <primary_index_lookup>(concat(`test`.`t1`.`c1`,'y') in <temporary table> on <auto_distinct_key> where ((concat(`test`.`t1`.`c1`,'y') = `<materialized_subquery>`.`left(c2,9)`))))))
4447 select * from information_schema.OPTIMIZER_TRACE;
4448 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
4449 explain
4450 select * from t1
4451 where concat(c1,'x') IN
4452 (select left(c2,8) from t2)
4453 and
4454 concat(c1,'y') IN
4455 (select left(c2,9) from t2) {
4456 "steps": [
4457 {
4458 "join_preparation": {
4459 "select#": 1,
4460 "steps": [
4461 {
4462 "join_preparation": {
4463 "select#": 2,
4464 "steps": [
4465 {
4466 "expanded_query": "/* select#2 */ select left(`t2`.`c2`,8) from `t2`"
4467 },
4468 {
4469 "transformation": {
4470 "select#": 2,
4471 "from": "IN (SELECT)",
4472 "to": "EXISTS (CORRELATED SELECT)",
4473 "chosen": true,
4474 "evaluating_constant_where_conditions": [
4475 ] /* evaluating_constant_where_conditions */
4476 } /* transformation */
4477 }
4478 ] /* steps */
4479 } /* join_preparation */
4480 },
4481 {
4482 "join_preparation": {
4483 "select#": 3,
4484 "steps": [
4485 {
4486 "expanded_query": "/* select#3 */ select left(`t2`.`c2`,9) from `t2`"
4487 },
4488 {
4489 "transformation": {
4490 "select#": 3,
4491 "from": "IN (SELECT)",
4492 "to": "EXISTS (CORRELATED SELECT)",
4493 "chosen": true,
4494 "evaluating_constant_where_conditions": [
4495 ] /* evaluating_constant_where_conditions */
4496 } /* transformation */
4497 }
4498 ] /* steps */
4499 } /* join_preparation */
4500 },
4501 {
4502 "expanded_query": "/* select#1 */ select `t1`.`c1` AS `c1` from `t1` where (<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4503 }
4504 ] /* steps */
4505 } /* join_preparation */
4506 },
4507 {
4508 "join_optimization": {
4509 "select#": 1,
4510 "steps": [
4511 {
4512 "condition_processing": {
4513 "condition": "WHERE",
4514 "original_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))",
4515 "steps": [
4516 {
4517 "transformation": "equality_propagation",
4518 "subselect_evaluation": [
4519 ] /* subselect_evaluation */,
4520 "resulting_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4521 },
4522 {
4523 "transformation": "constant_propagation",
4524 "subselect_evaluation": [
4525 ] /* subselect_evaluation */,
4526 "resulting_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4527 },
4528 {
4529 "transformation": "trivial_condition_removal",
4530 "subselect_evaluation": [
4531 ] /* subselect_evaluation */,
4532 "resulting_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4533 }
4534 ] /* steps */
4535 } /* condition_processing */
4536 },
4537 {
4538 "substitute_generated_columns": {
4539 } /* substitute_generated_columns */
4540 },
4541 {
4542 "table_dependencies": [
4543 {
4544 "table": "`t1`",
4545 "row_may_be_null": false,
4546 "map_bit": 0,
4547 "depends_on_map_bits": [
4548 ] /* depends_on_map_bits */
4549 }
4550 ] /* table_dependencies */
4551 },
4552 {
4553 "ref_optimizer_key_uses": [
4554 ] /* ref_optimizer_key_uses */
4555 },
4556 {
4557 "rows_estimation": [
4558 {
4559 "table": "`t1`",
4560 "table_scan": {
4561 "rows": 3,
4562 "cost": 0.501282
4563 } /* table_scan */
4564 }
4565 ] /* rows_estimation */
4566 },
4567 {
4568 "considered_execution_plans": [
4569 {
4570 "plan_prefix": [
4571 ] /* plan_prefix */,
4572 "table": "`t1`",
4573 "best_access_path": {
4574 "considered_access_paths": [
4575 {
4576 "rows_to_scan": 3,
4577 "filtering_effect": [
4578 ] /* filtering_effect */,
4579 "final_filtering_effect": 1,
4580 "access_type": "scan",
4581 "resulting_rows": 3,
4582 "cost": 0.801282,
4583 "chosen": true
4584 }
4585 ] /* considered_access_paths */
4586 } /* best_access_path */,
4587 "condition_filtering_pct": 100,
4588 "rows_for_plan": 3,
4589 "cost_for_plan": 0.801282,
4590 "chosen": true
4591 }
4592 ] /* considered_execution_plans */
4593 },
4594 {
4595 "attaching_conditions_to_tables": {
4596 "original_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))",
4597 "attached_conditions_computation": [
4598 ] /* attached_conditions_computation */,
4599 "attached_conditions_summary": [
4600 {
4601 "table": "`t1`",
4602 "attached": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4603 }
4604 ] /* attached_conditions_summary */
4605 } /* attaching_conditions_to_tables */
4606 },
4607 {
4608 "finalizing_table_conditions": [
4609 {
4610 "table": "`t1`",
4611 "original_table_condition": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))",
4612 "final_table_condition ": "(<in_optimizer>(concat(`t1`.`c1`,'x'),<exists>(/* select#2 */ select left(`t2`.`c2`,8) from `t2` where (<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8)))) and <in_optimizer>(concat(`t1`.`c1`,'y'),<exists>(/* select#3 */ select left(`t2`.`c2`,9) from `t2` where (<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9)))))"
4613 }
4614 ] /* finalizing_table_conditions */
4615 },
4616 {
4617 "refine_plan": [
4618 {
4619 "table": "`t1`"
4620 }
4621 ] /* refine_plan */
4622 }
4623 ] /* steps */
4624 } /* join_optimization */
4625 },
4626 {
4627 "join_optimization": {
4628 "select#": 3,
4629 "steps": [
4630 {
4631 "condition_processing": {
4632 "condition": "WHERE",
4633 "original_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))",
4634 "steps": [
4635 {
4636 "transformation": "equality_propagation",
4637 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4638 },
4639 {
4640 "transformation": "constant_propagation",
4641 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4642 },
4643 {
4644 "transformation": "trivial_condition_removal",
4645 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4646 }
4647 ] /* steps */
4648 } /* condition_processing */
4649 },
4650 {
4651 "substitute_generated_columns": {
4652 } /* substitute_generated_columns */
4653 },
4654 {
4655 "table_dependencies": [
4656 {
4657 "table": "`t2`",
4658 "row_may_be_null": false,
4659 "map_bit": 0,
4660 "depends_on_map_bits": [
4661 ] /* depends_on_map_bits */
4662 }
4663 ] /* table_dependencies */
4664 },
4665 {
4666 "ref_optimizer_key_uses": [
4667 ] /* ref_optimizer_key_uses */
4668 },
4669 {
4670 "rows_estimation": [
4671 {
4672 "table": "`t2`",
4673 "table_scan": {
4674 "rows": 3,
4675 "cost": 0.501282
4676 } /* table_scan */
4677 }
4678 ] /* rows_estimation */
4679 },
4680 {
4681 "considered_execution_plans": [
4682 {
4683 "plan_prefix": [
4684 ] /* plan_prefix */,
4685 "table": "`t2`",
4686 "best_access_path": {
4687 "considered_access_paths": [
4688 {
4689 "rows_to_scan": 3,
4690 "filtering_effect": [
4691 ] /* filtering_effect */,
4692 "final_filtering_effect": 1,
4693 "access_type": "scan",
4694 "resulting_rows": 3,
4695 "cost": 0.801282,
4696 "chosen": true
4697 }
4698 ] /* considered_access_paths */
4699 } /* best_access_path */,
4700 "condition_filtering_pct": 100,
4701 "rows_for_plan": 3,
4702 "cost_for_plan": 0.801282,
4703 "chosen": true
4704 }
4705 ] /* considered_execution_plans */
4706 },
4707 {
4708 "transformation": {
4709 "select#": 3,
4710 "from": "IN (SELECT)",
4711 "to": "materialization",
4712 "has_nullable_expressions": true,
4713 "treat_UNKNOWN_as_FALSE": true,
4714 "possible": true
4715 } /* transformation */
4716 },
4717 {
4718 "execution_plan_for_potential_materialization": {
4719 "steps": [
4720 {
4721 "considered_execution_plans": [
4722 {
4723 "plan_prefix": [
4724 ] /* plan_prefix */,
4725 "table": "`t2`",
4726 "best_access_path": {
4727 "considered_access_paths": [
4728 {
4729 "rows_to_scan": 3,
4730 "filtering_effect": [
4731 ] /* filtering_effect */,
4732 "final_filtering_effect": 1,
4733 "access_type": "scan",
4734 "resulting_rows": 3,
4735 "cost": 0.801282,
4736 "chosen": true
4737 }
4738 ] /* considered_access_paths */
4739 } /* best_access_path */,
4740 "condition_filtering_pct": 100,
4741 "rows_for_plan": 3,
4742 "cost_for_plan": 0.801282,
4743 "chosen": true
4744 }
4745 ] /* considered_execution_plans */
4746 }
4747 ] /* steps */,
4748 "subq_mat_decision": {
4749 "parent_fanouts": [
4750 {
4751 "select#": 1,
4752 "subq_attached_to_table": true,
4753 "table": "`t1`",
4754 "fanout": 3,
4755 "cacheable": true
4756 }
4757 ] /* parent_fanouts */,
4758 "cost_to_create_and_fill_materialized_table": 2.10028,
4759 "cost_of_one_EXISTS": 0.800282,
4760 "number_of_subquery_evaluations": 3,
4761 "cost_of_materialization": 2.40028,
4762 "cost_of_EXISTS": 2.40085,
4763 "chosen": true
4764 } /* subq_mat_decision */
4765 } /* execution_plan_for_potential_materialization */
4766 },
4767 {
4768 "transformation": {
4769 "select#": 3,
4770 "from": "IN (SELECT)",
4771 "to": "materialization",
4772 "chosen": true,
4773 "unknown_key_1": {
4774 "creating_tmp_table": {
4775 "tmp_table_info": {
4776 "table": "<materialized_subquery>",
4777 "columns": 1,
4778 "row_length": 38,
4779 "key_length": 39,
4780 "unique_constraint": false,
4781 "makes_grouped_rows": false,
4782 "cannot_insert_duplicates": true,
4783 "location": "TempTable"
4784 } /* tmp_table_info */
4785 } /* creating_tmp_table */
4786 }
4787 } /* transformation */
4788 },
4789 {
4790 "attaching_conditions_to_tables": {
4791 "original_condition": null,
4792 "attached_conditions_computation": [
4793 ] /* attached_conditions_computation */,
4794 "attached_conditions_summary": [
4795 {
4796 "table": "`t2`",
4797 "attached": null
4798 }
4799 ] /* attached_conditions_summary */
4800 } /* attaching_conditions_to_tables */
4801 },
4802 {
4803 "finalizing_table_conditions": [
4804 ] /* finalizing_table_conditions */
4805 },
4806 {
4807 "refine_plan": [
4808 {
4809 "table": "`t2`"
4810 }
4811 ] /* refine_plan */
4812 }
4813 ] /* steps */
4814 } /* join_optimization */
4815 },
4816 {
4817 "join_optimization": {
4818 "select#": 2,
4819 "steps": [
4820 {
4821 "condition_processing": {
4822 "condition": "WHERE",
4823 "original_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))",
4824 "steps": [
4825 {
4826 "transformation": "equality_propagation",
4827 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4828 },
4829 {
4830 "transformation": "constant_propagation",
4831 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4832 },
4833 {
4834 "transformation": "trivial_condition_removal",
4835 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4836 }
4837 ] /* steps */
4838 } /* condition_processing */
4839 },
4840 {
4841 "substitute_generated_columns": {
4842 } /* substitute_generated_columns */
4843 },
4844 {
4845 "table_dependencies": [
4846 {
4847 "table": "`t2`",
4848 "row_may_be_null": false,
4849 "map_bit": 0,
4850 "depends_on_map_bits": [
4851 ] /* depends_on_map_bits */
4852 }
4853 ] /* table_dependencies */
4854 },
4855 {
4856 "ref_optimizer_key_uses": [
4857 ] /* ref_optimizer_key_uses */
4858 },
4859 {
4860 "rows_estimation": [
4861 {
4862 "table": "`t2`",
4863 "table_scan": {
4864 "rows": 3,
4865 "cost": 0.501282
4866 } /* table_scan */
4867 }
4868 ] /* rows_estimation */
4869 },
4870 {
4871 "considered_execution_plans": [
4872 {
4873 "plan_prefix": [
4874 ] /* plan_prefix */,
4875 "table": "`t2`",
4876 "best_access_path": {
4877 "considered_access_paths": [
4878 {
4879 "rows_to_scan": 3,
4880 "filtering_effect": [
4881 ] /* filtering_effect */,
4882 "final_filtering_effect": 1,
4883 "access_type": "scan",
4884 "resulting_rows": 3,
4885 "cost": 0.801282,
4886 "chosen": true
4887 }
4888 ] /* considered_access_paths */
4889 } /* best_access_path */,
4890 "condition_filtering_pct": 100,
4891 "rows_for_plan": 3,
4892 "cost_for_plan": 0.801282,
4893 "chosen": true
4894 }
4895 ] /* considered_execution_plans */
4896 },
4897 {
4898 "transformation": {
4899 "select#": 2,
4900 "from": "IN (SELECT)",
4901 "to": "materialization",
4902 "has_nullable_expressions": true,
4903 "treat_UNKNOWN_as_FALSE": true,
4904 "possible": true
4905 } /* transformation */
4906 },
4907 {
4908 "execution_plan_for_potential_materialization": {
4909 "steps": [
4910 {
4911 "considered_execution_plans": [
4912 {
4913 "plan_prefix": [
4914 ] /* plan_prefix */,
4915 "table": "`t2`",
4916 "best_access_path": {
4917 "considered_access_paths": [
4918 {
4919 "rows_to_scan": 3,
4920 "filtering_effect": [
4921 ] /* filtering_effect */,
4922 "final_filtering_effect": 1,
4923 "access_type": "scan",
4924 "resulting_rows": 3,
4925 "cost": 0.801282,
4926 "chosen": true
4927 }
4928 ] /* considered_access_paths */
4929 } /* best_access_path */,
4930 "condition_filtering_pct": 100,
4931 "rows_for_plan": 3,
4932 "cost_for_plan": 0.801282,
4933 "chosen": true
4934 }
4935 ] /* considered_execution_plans */
4936 }
4937 ] /* steps */,
4938 "subq_mat_decision": {
4939 "parent_fanouts": [
4940 {
4941 "select#": 1,
4942 "subq_attached_to_table": true,
4943 "table": "`t1`",
4944 "fanout": 3,
4945 "cacheable": true
4946 }
4947 ] /* parent_fanouts */,
4948 "cost_to_create_and_fill_materialized_table": 2.10028,
4949 "cost_of_one_EXISTS": 0.800282,
4950 "number_of_subquery_evaluations": 3,
4951 "cost_of_materialization": 2.40028,
4952 "cost_of_EXISTS": 2.40085,
4953 "chosen": true
4954 } /* subq_mat_decision */
4955 } /* execution_plan_for_potential_materialization */
4956 },
4957 {
4958 "transformation": {
4959 "select#": 2,
4960 "from": "IN (SELECT)",
4961 "to": "materialization",
4962 "chosen": true,
4963 "unknown_key_2": {
4964 "creating_tmp_table": {
4965 "tmp_table_info": {
4966 "table": "<materialized_subquery>",
4967 "columns": 1,
4968 "row_length": 34,
4969 "key_length": 35,
4970 "unique_constraint": false,
4971 "makes_grouped_rows": false,
4972 "cannot_insert_duplicates": true,
4973 "location": "TempTable"
4974 } /* tmp_table_info */
4975 } /* creating_tmp_table */
4976 }
4977 } /* transformation */
4978 },
4979 {
4980 "attaching_conditions_to_tables": {
4981 "original_condition": null,
4982 "attached_conditions_computation": [
4983 ] /* attached_conditions_computation */,
4984 "attached_conditions_summary": [
4985 {
4986 "table": "`t2`",
4987 "attached": null
4988 }
4989 ] /* attached_conditions_summary */
4990 } /* attaching_conditions_to_tables */
4991 },
4992 {
4993 "finalizing_table_conditions": [
4994 ] /* finalizing_table_conditions */
4995 },
4996 {
4997 "refine_plan": [
4998 {
4999 "table": "`t2`"
5000 }
5001 ] /* refine_plan */
5002 }
5003 ] /* steps */
5004 } /* join_optimization */
5005 },
5006 {
5007 "join_explain": {
5008 "select#": 1,
5009 "steps": [
5010 {
5011 "join_explain": {
5012 "select#": 3,
5013 "steps": [
5014 ] /* steps */
5015 } /* join_explain */
5016 },
5017 {
5018 "join_explain": {
5019 "select#": 2,
5020 "steps": [
5021 ] /* steps */
5022 } /* join_explain */
5023 }
5024 ] /* steps */
5025 } /* join_explain */
5026 }
5027 ] /* steps */
5028 } 0 0
5029 set optimizer_switch=@old_opt_switch;
5030 DROP TABLE t1,t2;
5031 create table t1 (a int);
5032 insert into t1 values(1);
5033 create table t2 (a int);
5034 insert into t2 values(1);
5035 select * from t1,t2;
5036 a a
5037 1 1
5038 select * from information_schema.OPTIMIZER_TRACE;
5039 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
5040 select * from t1,t2 {
5041 "steps": [
5042 {
5043 "join_preparation": {
5044 "select#": 1,
5045 "steps": [
5046 {
5047 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
5048 }
5049 ] /* steps */
5050 } /* join_preparation */
5051 },
5052 {
5053 "join_optimization": {
5054 "select#": 1,
5055 "steps": [
5056 {
5057 "table_dependencies": [
5058 {
5059 "table": "`t1`",
5060 "row_may_be_null": false,
5061 "map_bit": 0,
5062 "depends_on_map_bits": [
5063 ] /* depends_on_map_bits */
5064 },
5065 {
5066 "table": "`t2`",
5067 "row_may_be_null": false,
5068 "map_bit": 1,
5069 "depends_on_map_bits": [
5070 ] /* depends_on_map_bits */
5071 }
5072 ] /* table_dependencies */
5073 },
5074 {
5075 "rows_estimation": [
5076 {
5077 "table": "`t1`",
5078 "rows": 1,
5079 "cost": 1,
5080 "table_type": "system",
5081 "empty": false
5082 },
5083 {
5084 "table": "`t2`",
5085 "rows": 1,
5086 "cost": 1,
5087 "table_type": "system",
5088 "empty": false
5089 }
5090 ] /* rows_estimation */
5091 },
5092 {
5093 "attaching_conditions_to_tables": {
5094 "original_condition": null,
5095 "attached_conditions_computation": [
5096 ] /* attached_conditions_computation */,
5097 "attached_conditions_summary": [
5098 ] /* attached_conditions_summary */
5099 } /* attaching_conditions_to_tables */
5100 },
5101 {
5102 "refine_plan": [
5103 ] /* refine_plan */
5104 }
5105 ] /* steps */
5106 } /* join_optimization */
5107 },
5108 {
5109 "join_execution": {
5110 "select#": 1,
5111 "steps": [
5112 ] /* steps */
5113 } /* join_execution */
5114 }
5115 ] /* steps */
5116 } 0 0
5117 create table t3 (a int, b int);
5118 create table t4 (a int primary key);
5119 insert into t4 values(1),(2);
5120 prepare stmt from 'select * from t3 where (a,a,b) in (select * from t1,t2,t4)';
5121 select trace from information_schema.OPTIMIZER_TRACE;
5122 trace
5123 {
5124 "steps": [
5125 {
5126 "join_preparation": {
5127 "select#": 1,
5128 "steps": [
5129 {
5130 "join_preparation": {
5131 "select#": 2,
5132 "steps": [
5133 {
5134 "expanded_query": "/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4`"
5135 }
5136 ] /* steps */
5137 } /* join_preparation */
5138 },
5139 {
5140 "expanded_query": "/* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from `t3` where (`t3`.`a`,`t3`.`a`,`t3`.`b`) in (/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4`)"
5141 },
5142 {
5143 "transformation": {
5144 "select#": 2,
5145 "from": "IN (SELECT)",
5146 "to": "semijoin",
5147 "chosen": true,
5148 "transformation_to_semi_join": {
5149 "subquery_predicate": "(`t3`.`a`,`t3`.`a`,`t3`.`b`) in (/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4`)",
5150 "embedded in": "WHERE",
5151 "evaluating_constant_semijoin_conditions": [
5152 ] /* evaluating_constant_semijoin_conditions */,
5153 "semi-join condition": "((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))",
5154 "decorrelated_predicates": [
5155 {
5156 "outer": "`t3`.`a`",
5157 "inner": "`t1`.`a`"
5158 },
5159 {
5160 "outer": "`t3`.`a`",
5161 "inner": "`t2`.`a`"
5162 },
5163 {
5164 "outer": "`t3`.`b`",
5165 "inner": "`t4`.`a`"
5166 }
5167 ] /* decorrelated_predicates */
5168 } /* transformation_to_semi_join */
5169 } /* transformation */
5170 },
5171 {
5172 "transformations_to_nested_joins": {
5173 "transformations": [
5174 "semijoin"
5175 ] /* transformations */,
5176 "expanded_query": "/* select#1 */ select `t3`.`a` AS `a`,`t3`.`b` AS `b` from `t3` semi join (`t1` join `t2` join `t4`) where ((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))"
5177 } /* transformations_to_nested_joins */
5178 }
5179 ] /* steps */
5180 } /* join_preparation */
5181 }
5182 ] /* steps */
5183 }
5184 execute stmt;
5185 a b
5186 select trace from information_schema.OPTIMIZER_TRACE;
5187 trace
5188 {
5189 "steps": [
5190 {
5191 "join_optimization": {
5192 "select#": 1,
5193 "steps": [
5194 {
5195 "condition_processing": {
5196 "condition": "WHERE",
5197 "original_condition": "((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))",
5198 "steps": [
5199 {
5200 "transformation": "equality_propagation",
5201 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5202 },
5203 {
5204 "transformation": "constant_propagation",
5205 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5206 },
5207 {
5208 "transformation": "trivial_condition_removal",
5209 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5210 }
5211 ] /* steps */
5212 } /* condition_processing */
5213 },
5214 {
5215 "substitute_generated_columns": {
5216 } /* substitute_generated_columns */
5217 },
5218 {
5219 "table_dependencies": [
5220 {
5221 "table": "`t3`",
5222 "row_may_be_null": false,
5223 "map_bit": 0,
5224 "depends_on_map_bits": [
5225 ] /* depends_on_map_bits */
5226 },
5227 {
5228 "table": "`t1`",
5229 "row_may_be_null": false,
5230 "map_bit": 1,
5231 "depends_on_map_bits": [
5232 ] /* depends_on_map_bits */
5233 },
5234 {
5235 "table": "`t2`",
5236 "row_may_be_null": false,
5237 "map_bit": 2,
5238 "depends_on_map_bits": [
5239 ] /* depends_on_map_bits */
5240 },
5241 {
5242 "table": "`t4`",
5243 "row_may_be_null": false,
5244 "map_bit": 3,
5245 "depends_on_map_bits": [
5246 ] /* depends_on_map_bits */
5247 }
5248 ] /* table_dependencies */
5249 },
5250 {
5251 "ref_optimizer_key_uses": [
5252 {
5253 "table": "`t4`",
5254 "field": "a",
5255 "equals": "`t3`.`b`",
5256 "null_rejecting": true
5257 }
5258 ] /* ref_optimizer_key_uses */
5259 },
5260 {
5261 "pulled_out_semijoin_tables": [
5262 {
5263 "table": "`t4`",
5264 "functionally_dependent": true
5265 }
5266 ] /* pulled_out_semijoin_tables */
5267 },
5268 {
5269 "rows_estimation": [
5270 {
5271 "table": "`t3`",
5272 "rows": 1,
5273 "cost": 1,
5274 "table_type": "system",
5275 "empty": true
5276 },
5277 {
5278 "table": "`t1`",
5279 "table_scan": {
5280 "rows": 1,
5281 "cost": 0.500427
5282 } /* table_scan */
5283 },
5284 {
5285 "table": "`t2`",
5286 "table_scan": {
5287 "rows": 1,
5288 "cost": 0.500427
5289 } /* table_scan */
5290 },
5291 {
5292 "table": "`t4`",
5293 "table_scan": {
5294 "rows": 2,
5295 "cost": 0.500854
5296 } /* table_scan */
5297 }
5298 ] /* rows_estimation */
5299 },
5300 {
5301 "execution_plan_for_potential_materialization": {
5302 "steps": [
5303 ] /* steps */
5304 } /* execution_plan_for_potential_materialization */
5305 },
5306 {
5307 "considered_execution_plans": [
5308 {
5309 "plan_prefix": [
5310 "`t3`"
5311 ] /* plan_prefix */,
5312 "table": "`t1`",
5313 "best_access_path": {
5314 "considered_access_paths": [
5315 {
5316 "rows_to_scan": 1,
5317 "filtering_effect": [
5318 ] /* filtering_effect */,
5319 "final_filtering_effect": 1,
5320 "access_type": "scan",
5321 "resulting_rows": 1,
5322 "cost": 0.600427,
5323 "chosen": true
5324 }
5325 ] /* considered_access_paths */
5326 } /* best_access_path */,
5327 "condition_filtering_pct": 100,
5328 "rows_for_plan": 1,
5329 "cost_for_plan": 0.600427,
5330 "semijoin_strategy_choice": [
5331 ] /* semijoin_strategy_choice */,
5332 "rest_of_plan": [
5333 {
5334 "plan_prefix": [
5335 "`t3`",
5336 "`t1`"
5337 ] /* plan_prefix */,
5338 "table": "`t2`",
5339 "best_access_path": {
5340 "considered_access_paths": [
5341 {
5342 "rows_to_scan": 1,
5343 "filtering_effect": [
5344 ] /* filtering_effect */,
5345 "final_filtering_effect": 1,
5346 "access_type": "scan",
5347 "using_join_cache": true,
5348 "buffers_needed": 1,
5349 "resulting_rows": 1,
5350 "cost": 0.600437,
5351 "chosen": true
5352 }
5353 ] /* considered_access_paths */
5354 } /* best_access_path */,
5355 "condition_filtering_pct": 100,
5356 "rows_for_plan": 1,
5357 "cost_for_plan": 1.20086,
5358 "semijoin_strategy_choice": [
5359 ] /* semijoin_strategy_choice */,
5360 "rest_of_plan": [
5361 {
5362 "plan_prefix": [
5363 "`t3`",
5364 "`t1`",
5365 "`t2`"
5366 ] /* plan_prefix */,
5367 "table": "`t4`",
5368 "best_access_path": {
5369 "considered_access_paths": [
5370 {
5371 "access_type": "eq_ref",
5372 "index": "PRIMARY",
5373 "rows": 1,
5374 "cost": 0.1,
5375 "chosen": true
5376 },
5377 {
5378 "access_type": "scan",
5379 "cost": 0.700854,
5380 "rows": 2,
5381 "chosen": false,
5382 "cause": "cost"
5383 }
5384 ] /* considered_access_paths */
5385 } /* best_access_path */,
5386 "condition_filtering_pct": 100,
5387 "rows_for_plan": 1,
5388 "cost_for_plan": 1.30086,
5389 "semijoin_strategy_choice": [
5390 {
5391 "strategy": "DuplicatesWeedout",
5392 "cost": 2.50086,
5393 "rows": 1,
5394 "duplicate_tables_left": true,
5395 "chosen": true
5396 }
5397 ] /* semijoin_strategy_choice */,
5398 "chosen": true
5399 }
5400 ] /* rest_of_plan */
5401 },
5402 {
5403 "plan_prefix": [
5404 "`t3`",
5405 "`t1`"
5406 ] /* plan_prefix */,
5407 "table": "`t4`",
5408 "best_access_path": {
5409 "considered_access_paths": [
5410 {
5411 "access_type": "eq_ref",
5412 "index": "PRIMARY",
5413 "rows": 1,
5414 "cost": 0.1,
5415 "chosen": true
5416 },
5417 {
5418 "access_type": "scan",
5419 "cost": 0.700854,
5420 "rows": 2,
5421 "chosen": false,
5422 "cause": "cost"
5423 }
5424 ] /* considered_access_paths */
5425 } /* best_access_path */,
5426 "condition_filtering_pct": 100,
5427 "rows_for_plan": 1,
5428 "cost_for_plan": 0.700427,
5429 "semijoin_strategy_choice": [
5430 ] /* semijoin_strategy_choice */,
5431 "rest_of_plan": [
5432 {
5433 "plan_prefix": [
5434 "`t3`",
5435 "`t1`",
5436 "`t4`"
5437 ] /* plan_prefix */,
5438 "table": "`t2`",
5439 "best_access_path": {
5440 "considered_access_paths": [
5441 {
5442 "rows_to_scan": 1,
5443 "filtering_effect": [
5444 ] /* filtering_effect */,
5445 "final_filtering_effect": 1,
5446 "access_type": "scan",
5447 "using_join_cache": true,
5448 "buffers_needed": 1,
5449 "resulting_rows": 1,
5450 "cost": 0.600444,
5451 "chosen": true
5452 }
5453 ] /* considered_access_paths */
5454 } /* best_access_path */,
5455 "condition_filtering_pct": 100,
5456 "rows_for_plan": 1,
5457 "cost_for_plan": 1.30087,
5458 "semijoin_strategy_choice": [
5459 {
5460 "strategy": "DuplicatesWeedout",
5461 "cost": 2.50087,
5462 "rows": 1,
5463 "duplicate_tables_left": true,
5464 "chosen": true
5465 }
5466 ] /* semijoin_strategy_choice */,
5467 "pruned_by_cost": true
5468 }
5469 ] /* rest_of_plan */
5470 }
5471 ] /* rest_of_plan */
5472 },
5473 {
5474 "plan_prefix": [
5475 "`t3`"
5476 ] /* plan_prefix */,
5477 "table": "`t2`",
5478 "best_access_path": {
5479 "considered_access_paths": [
5480 {
5481 "rows_to_scan": 1,
5482 "filtering_effect": [
5483 ] /* filtering_effect */,
5484 "final_filtering_effect": 1,
5485 "access_type": "scan",
5486 "resulting_rows": 1,
5487 "cost": 0.600427,
5488 "chosen": true
5489 }
5490 ] /* considered_access_paths */
5491 } /* best_access_path */,
5492 "condition_filtering_pct": 100,
5493 "rows_for_plan": 1,
5494 "cost_for_plan": 0.600427,
5495 "semijoin_strategy_choice": [
5496 ] /* semijoin_strategy_choice */,
5497 "pruned_by_heuristic": true
5498 },
5499 {
5500 "plan_prefix": [
5501 "`t3`"
5502 ] /* plan_prefix */,
5503 "table": "`t4`",
5504 "best_access_path": {
5505 "considered_access_paths": [
5506 {
5507 "access_type": "eq_ref",
5508 "index": "PRIMARY",
5509 "rows": 1,
5510 "cost": 0.1,
5511 "chosen": true
5512 },
5513 {
5514 "access_type": "scan",
5515 "cost": 0.700854,
5516 "rows": 2,
5517 "chosen": false,
5518 "cause": "cost"
5519 }
5520 ] /* considered_access_paths */
5521 } /* best_access_path */,
5522 "condition_filtering_pct": 100,
5523 "rows_for_plan": 1,
5524 "cost_for_plan": 0.1,
5525 "semijoin_strategy_choice": [
5526 ] /* semijoin_strategy_choice */,
5527 "rest_of_plan": [
5528 {
5529 "plan_prefix": [
5530 "`t3`",
5531 "`t4`"
5532 ] /* plan_prefix */,
5533 "table": "`t1`",
5534 "best_access_path": {
5535 "considered_access_paths": [
5536 {
5537 "rows_to_scan": 1,
5538 "filtering_effect": [
5539 ] /* filtering_effect */,
5540 "final_filtering_effect": 1,
5541 "access_type": "scan",
5542 "using_join_cache": true,
5543 "buffers_needed": 1,
5544 "resulting_rows": 1,
5545 "cost": 0.600435,
5546 "chosen": true
5547 }
5548 ] /* considered_access_paths */
5549 } /* best_access_path */,
5550 "condition_filtering_pct": 100,
5551 "rows_for_plan": 1,
5552 "cost_for_plan": 0.700435,
5553 "semijoin_strategy_choice": [
5554 ] /* semijoin_strategy_choice */,
5555 "rest_of_plan": [
5556 {
5557 "plan_prefix": [
5558 "`t3`",
5559 "`t4`",
5560 "`t1`"
5561 ] /* plan_prefix */,
5562 "table": "`t2`",
5563 "best_access_path": {
5564 "considered_access_paths": [
5565 {
5566 "rows_to_scan": 1,
5567 "filtering_effect": [
5568 ] /* filtering_effect */,
5569 "final_filtering_effect": 1,
5570 "access_type": "scan",
5571 "using_join_cache": true,
5572 "buffers_needed": 1,
5573 "resulting_rows": 1,
5574 "cost": 0.600444,
5575 "chosen": true
5576 }
5577 ] /* considered_access_paths */
5578 } /* best_access_path */,
5579 "condition_filtering_pct": 100,
5580 "rows_for_plan": 1,
5581 "cost_for_plan": 1.30088,
5582 "semijoin_strategy_choice": [
5583 {
5584 "strategy": "FirstMatch",
5585 "recalculate_access_paths_and_cost": {
5586 "tables": [
5587 {
5588 "table": "`t1`",
5589 "best_access_path": {
5590 "considered_access_paths": [
5591 {
5592 "rows_to_scan": 1,
5593 "filtering_effect": [
5594 ] /* filtering_effect */,
5595 "final_filtering_effect": 1,
5596 "access_type": "scan",
5597 "resulting_rows": 1,
5598 "cost": 0.600427,
5599 "chosen": true
5600 }
5601 ] /* considered_access_paths */
5602 } /* best_access_path */
5603 },
5604 {
5605 "table": "`t2`",
5606 "best_access_path": {
5607 "considered_access_paths": [
5608 {
5609 "rows_to_scan": 1,
5610 "filtering_effect": [
5611 ] /* filtering_effect */,
5612 "final_filtering_effect": 1,
5613 "access_type": "scan",
5614 "resulting_rows": 1,
5615 "cost": 0.600427,
5616 "chosen": true
5617 }
5618 ] /* considered_access_paths */
5619 } /* best_access_path */
5620 }
5621 ] /* tables */
5622 } /* recalculate_access_paths_and_cost */,
5623 "cost": 1.30085,
5624 "rows": 1,
5625 "chosen": true
5626 },
5627 {
5628 "strategy": "DuplicatesWeedout",
5629 "cost": 2.50088,
5630 "rows": 1,
5631 "duplicate_tables_left": false,
5632 "chosen": false
5633 }
5634 ] /* semijoin_strategy_choice */,
5635 "chosen": true
5636 }
5637 ] /* rest_of_plan */
5638 },
5639 {
5640 "plan_prefix": [
5641 "`t3`",
5642 "`t4`"
5643 ] /* plan_prefix */,
5644 "table": "`t2`",
5645 "best_access_path": {
5646 "considered_access_paths": [
5647 {
5648 "rows_to_scan": 1,
5649 "filtering_effect": [
5650 ] /* filtering_effect */,
5651 "final_filtering_effect": 1,
5652 "access_type": "scan",
5653 "using_join_cache": true,
5654 "buffers_needed": 1,
5655 "resulting_rows": 1,
5656 "cost": 0.600435,
5657 "chosen": true
5658 }
5659 ] /* considered_access_paths */
5660 } /* best_access_path */,
5661 "condition_filtering_pct": 100,
5662 "rows_for_plan": 1,
5663 "cost_for_plan": 0.700435,
5664 "semijoin_strategy_choice": [
5665 ] /* semijoin_strategy_choice */,
5666 "pruned_by_heuristic": true
5667 }
5668 ] /* rest_of_plan */
5669 },
5670 {
5671 "final_semijoin_strategy": "FirstMatch",
5672 "recalculate_access_paths_and_cost": {
5673 "tables": [
5674 {
5675 "table": "`t1`",
5676 "best_access_path": {
5677 "considered_access_paths": [
5678 {
5679 "rows_to_scan": 1,
5680 "filtering_effect": [
5681 ] /* filtering_effect */,
5682 "final_filtering_effect": 1,
5683 "access_type": "scan",
5684 "resulting_rows": 1,
5685 "cost": 0.600427,
5686 "chosen": true
5687 }
5688 ] /* considered_access_paths */
5689 } /* best_access_path */
5690 },
5691 {
5692 "table": "`t2`",
5693 "best_access_path": {
5694 "considered_access_paths": [
5695 {
5696 "rows_to_scan": 1,
5697 "filtering_effect": [
5698 ] /* filtering_effect */,
5699 "final_filtering_effect": 1,
5700 "access_type": "scan",
5701 "resulting_rows": 1,
5702 "cost": 0.600427,
5703 "chosen": true
5704 }
5705 ] /* considered_access_paths */
5706 } /* best_access_path */
5707 }
5708 ] /* tables */
5709 } /* recalculate_access_paths_and_cost */
5710 }
5711 ] /* considered_execution_plans */
5712 }
5713 ] /* steps */,
5714 "empty_result": {
5715 "cause": "no matching row in const table"
5716 } /* empty_result */
5717 } /* join_optimization */
5718 },
5719 {
5720 "join_execution": {
5721 "select#": 1,
5722 "steps": [
5723 ] /* steps */
5724 } /* join_execution */
5725 }
5726 ] /* steps */
5727 }
5728 execute stmt;
5729 a b
5730 select trace from information_schema.OPTIMIZER_TRACE;
5731 trace
5732 {
5733 "steps": [
5734 {
5735 "join_optimization": {
5736 "select#": 1,
5737 "steps": [
5738 {
5739 "condition_processing": {
5740 "condition": "WHERE",
5741 "original_condition": "((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))",
5742 "steps": [
5743 {
5744 "transformation": "equality_propagation",
5745 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5746 },
5747 {
5748 "transformation": "constant_propagation",
5749 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5750 },
5751 {
5752 "transformation": "trivial_condition_removal",
5753 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5754 }
5755 ] /* steps */
5756 } /* condition_processing */
5757 },
5758 {
5759 "substitute_generated_columns": {
5760 } /* substitute_generated_columns */
5761 },
5762 {
5763 "table_dependencies": [
5764 {
5765 "table": "`t3`",
5766 "row_may_be_null": false,
5767 "map_bit": 0,
5768 "depends_on_map_bits": [
5769 ] /* depends_on_map_bits */
5770 },
5771 {
5772 "table": "`t1`",
5773 "row_may_be_null": false,
5774 "map_bit": 1,
5775 "depends_on_map_bits": [
5776 ] /* depends_on_map_bits */
5777 },
5778 {
5779 "table": "`t2`",
5780 "row_may_be_null": false,
5781 "map_bit": 2,
5782 "depends_on_map_bits": [
5783 ] /* depends_on_map_bits */
5784 },
5785 {
5786 "table": "`t4`",
5787 "row_may_be_null": false,
5788 "map_bit": 3,
5789 "depends_on_map_bits": [
5790 ] /* depends_on_map_bits */
5791 }
5792 ] /* table_dependencies */
5793 },
5794 {
5795 "ref_optimizer_key_uses": [
5796 {
5797 "table": "`t4`",
5798 "field": "a",
5799 "equals": "`t3`.`b`",
5800 "null_rejecting": true
5801 }
5802 ] /* ref_optimizer_key_uses */
5803 },
5804 {
5805 "rows_estimation": [
5806 {
5807 "table": "`t3`",
5808 "rows": 1,
5809 "cost": 1,
5810 "table_type": "system",
5811 "empty": true
5812 },
5813 {
5814 "table": "`t1`",
5815 "table_scan": {
5816 "rows": 1,
5817 "cost": 0.500427
5818 } /* table_scan */
5819 },
5820 {
5821 "table": "`t2`",
5822 "table_scan": {
5823 "rows": 1,
5824 "cost": 0.500427
5825 } /* table_scan */
5826 },
5827 {
5828 "table": "`t4`",
5829 "table_scan": {
5830 "rows": 2,
5831 "cost": 0.500854
5832 } /* table_scan */
5833 }
5834 ] /* rows_estimation */
5835 },
5836 {
5837 "execution_plan_for_potential_materialization": {
5838 "steps": [
5839 ] /* steps */
5840 } /* execution_plan_for_potential_materialization */
5841 },
5842 {
5843 "considered_execution_plans": [
5844 {
5845 "plan_prefix": [
5846 "`t3`"
5847 ] /* plan_prefix */,
5848 "table": "`t1`",
5849 "best_access_path": {
5850 "considered_access_paths": [
5851 {
5852 "rows_to_scan": 1,
5853 "filtering_effect": [
5854 ] /* filtering_effect */,
5855 "final_filtering_effect": 1,
5856 "access_type": "scan",
5857 "resulting_rows": 1,
5858 "cost": 0.600427,
5859 "chosen": true
5860 }
5861 ] /* considered_access_paths */
5862 } /* best_access_path */,
5863 "condition_filtering_pct": 100,
5864 "rows_for_plan": 1,
5865 "cost_for_plan": 0.600427,
5866 "semijoin_strategy_choice": [
5867 ] /* semijoin_strategy_choice */,
5868 "rest_of_plan": [
5869 {
5870 "plan_prefix": [
5871 "`t3`",
5872 "`t1`"
5873 ] /* plan_prefix */,
5874 "table": "`t2`",
5875 "best_access_path": {
5876 "considered_access_paths": [
5877 {
5878 "rows_to_scan": 1,
5879 "filtering_effect": [
5880 ] /* filtering_effect */,
5881 "final_filtering_effect": 1,
5882 "access_type": "scan",
5883 "using_join_cache": true,
5884 "buffers_needed": 1,
5885 "resulting_rows": 1,
5886 "cost": 0.600437,
5887 "chosen": true
5888 }
5889 ] /* considered_access_paths */
5890 } /* best_access_path */,
5891 "condition_filtering_pct": 100,
5892 "rows_for_plan": 1,
5893 "cost_for_plan": 1.20086,
5894 "semijoin_strategy_choice": [
5895 ] /* semijoin_strategy_choice */,
5896 "rest_of_plan": [
5897 {
5898 "plan_prefix": [
5899 "`t3`",
5900 "`t1`",
5901 "`t2`"
5902 ] /* plan_prefix */,
5903 "table": "`t4`",
5904 "best_access_path": {
5905 "considered_access_paths": [
5906 {
5907 "access_type": "eq_ref",
5908 "index": "PRIMARY",
5909 "rows": 1,
5910 "cost": 0.1,
5911 "chosen": true
5912 },
5913 {
5914 "access_type": "scan",
5915 "cost": 0.700854,
5916 "rows": 2,
5917 "chosen": false,
5918 "cause": "cost"
5919 }
5920 ] /* considered_access_paths */
5921 } /* best_access_path */,
5922 "condition_filtering_pct": 100,
5923 "rows_for_plan": 1,
5924 "cost_for_plan": 1.30086,
5925 "semijoin_strategy_choice": [
5926 {
5927 "strategy": "DuplicatesWeedout",
5928 "cost": 2.50086,
5929 "rows": 1,
5930 "duplicate_tables_left": true,
5931 "chosen": true
5932 }
5933 ] /* semijoin_strategy_choice */,
5934 "chosen": true
5935 }
5936 ] /* rest_of_plan */
5937 },
5938 {
5939 "plan_prefix": [
5940 "`t3`",
5941 "`t1`"
5942 ] /* plan_prefix */,
5943 "table": "`t4`",
5944 "best_access_path": {
5945 "considered_access_paths": [
5946 {
5947 "access_type": "eq_ref",
5948 "index": "PRIMARY",
5949 "rows": 1,
5950 "cost": 0.1,
5951 "chosen": true
5952 },
5953 {
5954 "access_type": "scan",
5955 "cost": 0.700854,
5956 "rows": 2,
5957 "chosen": false,
5958 "cause": "cost"
5959 }
5960 ] /* considered_access_paths */
5961 } /* best_access_path */,
5962 "condition_filtering_pct": 100,
5963 "rows_for_plan": 1,
5964 "cost_for_plan": 0.700427,
5965 "semijoin_strategy_choice": [
5966 ] /* semijoin_strategy_choice */,
5967 "rest_of_plan": [
5968 {
5969 "plan_prefix": [
5970 "`t3`",
5971 "`t1`",
5972 "`t4`"
5973 ] /* plan_prefix */,
5974 "table": "`t2`",
5975 "best_access_path": {
5976 "considered_access_paths": [
5977 {
5978 "rows_to_scan": 1,
5979 "filtering_effect": [
5980 ] /* filtering_effect */,
5981 "final_filtering_effect": 1,
5982 "access_type": "scan",
5983 "using_join_cache": true,
5984 "buffers_needed": 1,
5985 "resulting_rows": 1,
5986 "cost": 0.600444,
5987 "chosen": true
5988 }
5989 ] /* considered_access_paths */
5990 } /* best_access_path */,
5991 "condition_filtering_pct": 100,
5992 "rows_for_plan": 1,
5993 "cost_for_plan": 1.30087,
5994 "semijoin_strategy_choice": [
5995 {
5996 "strategy": "DuplicatesWeedout",
5997 "cost": 2.50087,
5998 "rows": 1,
5999 "duplicate_tables_left": true,
6000 "chosen": true
6001 }
6002 ] /* semijoin_strategy_choice */,
6003 "pruned_by_cost": true
6004 }
6005 ] /* rest_of_plan */
6006 }
6007 ] /* rest_of_plan */
6008 },
6009 {
6010 "plan_prefix": [
6011 "`t3`"
6012 ] /* plan_prefix */,
6013 "table": "`t2`",
6014 "best_access_path": {
6015 "considered_access_paths": [
6016 {
6017 "rows_to_scan": 1,
6018 "filtering_effect": [
6019 ] /* filtering_effect */,
6020 "final_filtering_effect": 1,
6021 "access_type": "scan",
6022 "resulting_rows": 1,
6023 "cost": 0.600427,
6024 "chosen": true
6025 }
6026 ] /* considered_access_paths */
6027 } /* best_access_path */,
6028 "condition_filtering_pct": 100,
6029 "rows_for_plan": 1,
6030 "cost_for_plan": 0.600427,
6031 "semijoin_strategy_choice": [
6032 ] /* semijoin_strategy_choice */,
6033 "pruned_by_heuristic": true
6034 },
6035 {
6036 "plan_prefix": [
6037 "`t3`"
6038 ] /* plan_prefix */,
6039 "table": "`t4`",
6040 "best_access_path": {
6041 "considered_access_paths": [
6042 {
6043 "access_type": "eq_ref",
6044 "index": "PRIMARY",
6045 "rows": 1,
6046 "cost": 0.1,
6047 "chosen": true
6048 },
6049 {
6050 "access_type": "scan",
6051 "cost": 0.700854,
6052 "rows": 2,
6053 "chosen": false,
6054 "cause": "cost"
6055 }
6056 ] /* considered_access_paths */
6057 } /* best_access_path */,
6058 "condition_filtering_pct": 100,
6059 "rows_for_plan": 1,
6060 "cost_for_plan": 0.1,
6061 "semijoin_strategy_choice": [
6062 ] /* semijoin_strategy_choice */,
6063 "rest_of_plan": [
6064 {
6065 "plan_prefix": [
6066 "`t3`",
6067 "`t4`"
6068 ] /* plan_prefix */,
6069 "table": "`t1`",
6070 "best_access_path": {
6071 "considered_access_paths": [
6072 {
6073 "rows_to_scan": 1,
6074 "filtering_effect": [
6075 ] /* filtering_effect */,
6076 "final_filtering_effect": 1,
6077 "access_type": "scan",
6078 "using_join_cache": true,
6079 "buffers_needed": 1,
6080 "resulting_rows": 1,
6081 "cost": 0.600435,
6082 "chosen": true
6083 }
6084 ] /* considered_access_paths */
6085 } /* best_access_path */,
6086 "condition_filtering_pct": 100,
6087 "rows_for_plan": 1,
6088 "cost_for_plan": 0.700435,
6089 "semijoin_strategy_choice": [
6090 ] /* semijoin_strategy_choice */,
6091 "rest_of_plan": [
6092 {
6093 "plan_prefix": [
6094 "`t3`",
6095 "`t4`",
6096 "`t1`"
6097 ] /* plan_prefix */,
6098 "table": "`t2`",
6099 "best_access_path": {
6100 "considered_access_paths": [
6101 {
6102 "rows_to_scan": 1,
6103 "filtering_effect": [
6104 ] /* filtering_effect */,
6105 "final_filtering_effect": 1,
6106 "access_type": "scan",
6107 "using_join_cache": true,
6108 "buffers_needed": 1,
6109 "resulting_rows": 1,
6110 "cost": 0.600444,
6111 "chosen": true
6112 }
6113 ] /* considered_access_paths */
6114 } /* best_access_path */,
6115 "condition_filtering_pct": 100,
6116 "rows_for_plan": 1,
6117 "cost_for_plan": 1.30088,
6118 "semijoin_strategy_choice": [
6119 {
6120 "strategy": "FirstMatch",
6121 "recalculate_access_paths_and_cost": {
6122 "tables": [
6123 {
6124 "table": "`t1`",
6125 "best_access_path": {
6126 "considered_access_paths": [
6127 {
6128 "rows_to_scan": 1,
6129 "filtering_effect": [
6130 ] /* filtering_effect */,
6131 "final_filtering_effect": 1,
6132 "access_type": "scan",
6133 "resulting_rows": 1,
6134 "cost": 0.600427,
6135 "chosen": true
6136 }
6137 ] /* considered_access_paths */
6138 } /* best_access_path */
6139 },
6140 {
6141 "table": "`t2`",
6142 "best_access_path": {
6143 "considered_access_paths": [
6144 {
6145 "rows_to_scan": 1,
6146 "filtering_effect": [
6147 ] /* filtering_effect */,
6148 "final_filtering_effect": 1,
6149 "access_type": "scan",
6150 "resulting_rows": 1,
6151 "cost": 0.600427,
6152 "chosen": true
6153 }
6154 ] /* considered_access_paths */
6155 } /* best_access_path */
6156 }
6157 ] /* tables */
6158 } /* recalculate_access_paths_and_cost */,
6159 "cost": 1.30085,
6160 "rows": 1,
6161 "chosen": true
6162 },
6163 {
6164 "strategy": "DuplicatesWeedout",
6165 "cost": 2.50088,
6166 "rows": 1,
6167 "duplicate_tables_left": false,
6168 "chosen": false
6169 }
6170 ] /* semijoin_strategy_choice */,
6171 "chosen": true
6172 }
6173 ] /* rest_of_plan */
6174 },
6175 {
6176 "plan_prefix": [
6177 "`t3`",
6178 "`t4`"
6179 ] /* plan_prefix */,
6180 "table": "`t2`",
6181 "best_access_path": {
6182 "considered_access_paths": [
6183 {
6184 "rows_to_scan": 1,
6185 "filtering_effect": [
6186 ] /* filtering_effect */,
6187 "final_filtering_effect": 1,
6188 "access_type": "scan",
6189 "using_join_cache": true,
6190 "buffers_needed": 1,
6191 "resulting_rows": 1,
6192 "cost": 0.600435,
6193 "chosen": true
6194 }
6195 ] /* considered_access_paths */
6196 } /* best_access_path */,
6197 "condition_filtering_pct": 100,
6198 "rows_for_plan": 1,
6199 "cost_for_plan": 0.700435,
6200 "semijoin_strategy_choice": [
6201 ] /* semijoin_strategy_choice */,
6202 "pruned_by_heuristic": true
6203 }
6204 ] /* rest_of_plan */
6205 },
6206 {
6207 "final_semijoin_strategy": "FirstMatch",
6208 "recalculate_access_paths_and_cost": {
6209 "tables": [
6210 {
6211 "table": "`t1`",
6212 "best_access_path": {
6213 "considered_access_paths": [
6214 {
6215 "rows_to_scan": 1,
6216 "filtering_effect": [
6217 ] /* filtering_effect */,
6218 "final_filtering_effect": 1,
6219 "access_type": "scan",
6220 "resulting_rows": 1,
6221 "cost": 0.600427,
6222 "chosen": true
6223 }
6224 ] /* considered_access_paths */
6225 } /* best_access_path */
6226 },
6227 {
6228 "table": "`t2`",
6229 "best_access_path": {
6230 "considered_access_paths": [
6231 {
6232 "rows_to_scan": 1,
6233 "filtering_effect": [
6234 ] /* filtering_effect */,
6235 "final_filtering_effect": 1,
6236 "access_type": "scan",
6237 "resulting_rows": 1,
6238 "cost": 0.600427,
6239 "chosen": true
6240 }
6241 ] /* considered_access_paths */
6242 } /* best_access_path */
6243 }
6244 ] /* tables */
6245 } /* recalculate_access_paths_and_cost */
6246 }
6247 ] /* considered_execution_plans */
6248 }
6249 ] /* steps */,
6250 "empty_result": {
6251 "cause": "no matching row in const table"
6252 } /* empty_result */
6253 } /* join_optimization */
6254 },
6255 {
6256 "join_execution": {
6257 "select#": 1,
6258 "steps": [
6259 ] /* steps */
6260 } /* join_execution */
6261 }
6262 ] /* steps */
6263 }
6264 DROP TABLE t1,t2,t3,t4;
6265 create table t1(a int);
6266 insert into t1 values(1),(1);
6267 create table t2(a int);
6268 insert into t2 values(1),(1);
6269 select * from t1 left join t2 on t2.a=500 where t2.a is NULL;
6270 a a
6271 1 NULL
6272 1 NULL
6273 select * from information_schema.OPTIMIZER_TRACE;
6274 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
6275 select * from t1 left join t2 on t2.a=500 where t2.a is NULL {
6276 "steps": [
6277 {
6278 "join_preparation": {
6279 "select#": 1,
6280 "steps": [
6281 {
6282 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from (`t1` left join `t2` on((`t2`.`a` = 500))) where (`t2`.`a` is null)"
6283 },
6284 {
6285 "transformations_to_nested_joins": {
6286 "transformations": [
6287 "parenthesis_removal"
6288 ] /* transformations */,
6289 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` left join `t2` on((`t2`.`a` = 500)) where (`t2`.`a` is null)"
6290 } /* transformations_to_nested_joins */
6291 }
6292 ] /* steps */
6293 } /* join_preparation */
6294 },
6295 {
6296 "join_optimization": {
6297 "select#": 1,
6298 "steps": [
6299 {
6300 "condition_processing": {
6301 "condition": "WHERE",
6302 "original_condition": "(`t2`.`a` is null)",
6303 "steps": [
6304 {
6305 "transformation": "equality_propagation",
6306 "resulting_condition": "(`t2`.`a` is null)"
6307 },
6308 {
6309 "transformation": "constant_propagation",
6310 "resulting_condition": "(`t2`.`a` is null)"
6311 },
6312 {
6313 "transformation": "trivial_condition_removal",
6314 "resulting_condition": "(`t2`.`a` is null)"
6315 }
6316 ] /* steps */
6317 } /* condition_processing */
6318 },
6319 {
6320 "substitute_generated_columns": {
6321 } /* substitute_generated_columns */
6322 },
6323 {
6324 "table_dependencies": [
6325 {
6326 "table": "`t1`",
6327 "row_may_be_null": false,
6328 "map_bit": 0,
6329 "depends_on_map_bits": [
6330 ] /* depends_on_map_bits */
6331 },
6332 {
6333 "table": "`t2`",
6334 "row_may_be_null": true,
6335 "map_bit": 1,
6336 "depends_on_map_bits": [
6337 0
6338 ] /* depends_on_map_bits */
6339 }
6340 ] /* table_dependencies */
6341 },
6342 {
6343 "ref_optimizer_key_uses": [
6344 ] /* ref_optimizer_key_uses */
6345 },
6346 {
6347 "rows_estimation": [
6348 {
6349 "table": "`t1`",
6350 "table_scan": {
6351 "rows": 2,
6352 "cost": 0.500854
6353 } /* table_scan */
6354 },
6355 {
6356 "table": "`t2`",
6357 "table_scan": {
6358 "rows": 2,
6359 "cost": 0.500854
6360 } /* table_scan */
6361 }
6362 ] /* rows_estimation */
6363 },
6364 {
6365 "considered_execution_plans": [
6366 {
6367 "plan_prefix": [
6368 ] /* plan_prefix */,
6369 "table": "`t1`",
6370 "best_access_path": {
6371 "considered_access_paths": [
6372 {
6373 "rows_to_scan": 2,
6374 "access_type": "scan",
6375 "resulting_rows": 2,
6376 "cost": 0.700854,
6377 "chosen": true
6378 }
6379 ] /* considered_access_paths */
6380 } /* best_access_path */,
6381 "condition_filtering_pct": 100,
6382 "rows_for_plan": 2,
6383 "cost_for_plan": 0.700854,
6384 "rest_of_plan": [
6385 {
6386 "plan_prefix": [
6387 "`t1`"
6388 ] /* plan_prefix */,
6389 "table": "`t2`",
6390 "best_access_path": {
6391 "considered_access_paths": [
6392 {
6393 "rows_to_scan": 2,
6394 "filtering_effect": [
6395 ] /* filtering_effect */,
6396 "final_filtering_effect": 0.5,
6397 "access_type": "scan",
6398 "using_join_cache": true,
6399 "buffers_needed": 1,
6400 "resulting_rows": 1,
6401 "cost": 0.800877,
6402 "chosen": true
6403 }
6404 ] /* considered_access_paths */
6405 } /* best_access_path */,
6406 "condition_filtering_pct": 100,
6407 "rows_for_plan": 2,
6408 "cost_for_plan": 1.50173,
6409 "chosen": true
6410 }
6411 ] /* rest_of_plan */
6412 }
6413 ] /* considered_execution_plans */
6414 },
6415 {
6416 "attaching_conditions_to_tables": {
6417 "original_condition": "(`t2`.`a` is null)",
6418 "attached_conditions_computation": [
6419 ] /* attached_conditions_computation */,
6420 "attached_conditions_summary": [
6421 {
6422 "table": "`t1`",
6423 "attached": null
6424 },
6425 {
6426 "table": "`t2`",
6427 "attached": "(<if>(found_match(t2), (`t2`.`a` is null), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))"
6428 }
6429 ] /* attached_conditions_summary */
6430 } /* attaching_conditions_to_tables */
6431 },
6432 {
6433 "finalizing_table_conditions": [
6434 {
6435 "table": "`t2`",
6436 "original_table_condition": "(<if>(found_match(t2), (`t2`.`a` is null), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))",
6437 "final_table_condition ": "(<if>(found_match(t2), (`t2`.`a` is null), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))"
6438 }
6439 ] /* finalizing_table_conditions */
6440 },
6441 {
6442 "refine_plan": [
6443 {
6444 "table": "`t1`"
6445 },
6446 {
6447 "table": "`t2`"
6448 }
6449 ] /* refine_plan */
6450 }
6451 ] /* steps */
6452 } /* join_optimization */
6453 },
6454 {
6455 "join_execution": {
6456 "select#": 1,
6457 "steps": [
6458 ] /* steps */
6459 } /* join_execution */
6460 }
6461 ] /* steps */
6462 } 0 0
6463 drop table t1,t2;
6464 create table t1(a int, b int);
6465 insert into t1 values(1,NULL),(NULL,2);
6466 create table t2(c int, d int);
6467 insert into t2 values(1,1),(2,2);
6468 select * from t1 where (t1.a,t1.b) not in (select c,d from t2 where c>0);
6469 a b
6470 select * from information_schema.OPTIMIZER_TRACE;
6471 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
6472 select * from t1 where (t1.a,t1.b) not in (select c,d from t2 where c>0) {
6473 "steps": [
6474 {
6475 "join_preparation": {
6476 "select#": 1,
6477 "steps": [
6478 {
6479 "join_preparation": {
6480 "select#": 2,
6481 "steps": [
6482 {
6483 "expanded_query": "/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where (`t2`.`c` > 0)"
6484 },
6485 {
6486 "transformation": {
6487 "select#": 2,
6488 "from": "IN (SELECT)",
6489 "to": "EXISTS (CORRELATED SELECT)",
6490 "chosen": true,
6491 "evaluating_constant_where_conditions": [
6492 ] /* evaluating_constant_where_conditions */,
6493 "evaluating_constant_having_conditions": [
6494 ] /* evaluating_constant_having_conditions */
6495 } /* transformation */
6496 }
6497 ] /* steps */
6498 } /* join_preparation */
6499 },
6500 {
6501 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` where <in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)"
6502 }
6503 ] /* steps */
6504 } /* join_preparation */
6505 },
6506 {
6507 "join_optimization": {
6508 "select#": 1,
6509 "steps": [
6510 {
6511 "condition_processing": {
6512 "condition": "WHERE",
6513 "original_condition": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)",
6514 "steps": [
6515 {
6516 "transformation": "equality_propagation",
6517 "subselect_evaluation": [
6518 ] /* subselect_evaluation */,
6519 "resulting_condition": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)"
6520 },
6521 {
6522 "transformation": "constant_propagation",
6523 "subselect_evaluation": [
6524 ] /* subselect_evaluation */,
6525 "resulting_condition": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)"
6526 },
6527 {
6528 "transformation": "trivial_condition_removal",
6529 "subselect_evaluation": [
6530 ] /* subselect_evaluation */,
6531 "resulting_condition": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)"
6532 }
6533 ] /* steps */
6534 } /* condition_processing */
6535 },
6536 {
6537 "substitute_generated_columns": {
6538 } /* substitute_generated_columns */
6539 },
6540 {
6541 "table_dependencies": [
6542 {
6543 "table": "`t1`",
6544 "row_may_be_null": false,
6545 "map_bit": 0,
6546 "depends_on_map_bits": [
6547 ] /* depends_on_map_bits */
6548 }
6549 ] /* table_dependencies */
6550 },
6551 {
6552 "ref_optimizer_key_uses": [
6553 ] /* ref_optimizer_key_uses */
6554 },
6555 {
6556 "rows_estimation": [
6557 {
6558 "table": "`t1`",
6559 "table_scan": {
6560 "rows": 2,
6561 "cost": 0.501099
6562 } /* table_scan */
6563 }
6564 ] /* rows_estimation */
6565 },
6566 {
6567 "considered_execution_plans": [
6568 {
6569 "plan_prefix": [
6570 ] /* plan_prefix */,
6571 "table": "`t1`",
6572 "best_access_path": {
6573 "considered_access_paths": [
6574 {
6575 "rows_to_scan": 2,
6576 "access_type": "scan",
6577 "resulting_rows": 2,
6578 "cost": 0.701099,
6579 "chosen": true
6580 }
6581 ] /* considered_access_paths */
6582 } /* best_access_path */,
6583 "condition_filtering_pct": 100,
6584 "rows_for_plan": 2,
6585 "cost_for_plan": 0.701099,
6586 "chosen": true
6587 }
6588 ] /* considered_execution_plans */
6589 },
6590 {
6591 "attaching_conditions_to_tables": {
6592 "original_condition": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)",
6593 "attached_conditions_computation": [
6594 ] /* attached_conditions_computation */,
6595 "attached_conditions_summary": [
6596 {
6597 "table": "`t1`",
6598 "attached": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)"
6599 }
6600 ] /* attached_conditions_summary */
6601 } /* attaching_conditions_to_tables */
6602 },
6603 {
6604 "finalizing_table_conditions": [
6605 {
6606 "table": "`t1`",
6607 "original_table_condition": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)",
6608 "final_table_condition ": "<in_optimizer>((`t1`.`a`,`t1`.`b`),<exists>(/* select#2 */ select `t2`.`c`,`t2`.`d` from `t2` where ((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true)) having (<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))) is false)"
6609 }
6610 ] /* finalizing_table_conditions */
6611 },
6612 {
6613 "refine_plan": [
6614 {
6615 "table": "`t1`"
6616 }
6617 ] /* refine_plan */
6618 }
6619 ] /* steps */
6620 } /* join_optimization */
6621 },
6622 {
6623 "join_optimization": {
6624 "select#": 2,
6625 "steps": [
6626 {
6627 "condition_processing": {
6628 "condition": "WHERE",
6629 "original_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))",
6630 "steps": [
6631 {
6632 "transformation": "equality_propagation",
6633 "resulting_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))"
6634 },
6635 {
6636 "transformation": "constant_propagation",
6637 "resulting_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))"
6638 },
6639 {
6640 "transformation": "trivial_condition_removal",
6641 "resulting_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))"
6642 }
6643 ] /* steps */
6644 } /* condition_processing */
6645 },
6646 {
6647 "condition_processing": {
6648 "condition": "HAVING",
6649 "original_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))",
6650 "steps": [
6651 {
6652 "transformation": "constant_propagation",
6653 "resulting_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))"
6654 },
6655 {
6656 "transformation": "trivial_condition_removal",
6657 "resulting_condition": "(<if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`c`), true) and <if>(outer_field_is_not_null, <is_not_null_test>(`t2`.`d`), true))"
6658 }
6659 ] /* steps */
6660 } /* condition_processing */
6661 },
6662 {
6663 "substitute_generated_columns": {
6664 } /* substitute_generated_columns */
6665 },
6666 {
6667 "table_dependencies": [
6668 {
6669 "table": "`t2`",
6670 "row_may_be_null": false,
6671 "map_bit": 0,
6672 "depends_on_map_bits": [
6673 ] /* depends_on_map_bits */
6674 }
6675 ] /* table_dependencies */
6676 },
6677 {
6678 "ref_optimizer_key_uses": [
6679 ] /* ref_optimizer_key_uses */
6680 },
6681 {
6682 "rows_estimation": [
6683 {
6684 "table": "`t2`",
6685 "table_scan": {
6686 "rows": 2,
6687 "cost": 0.501099
6688 } /* table_scan */
6689 }
6690 ] /* rows_estimation */
6691 },
6692 {
6693 "considered_execution_plans": [
6694 {
6695 "plan_prefix": [
6696 ] /* plan_prefix */,
6697 "table": "`t2`",
6698 "best_access_path": {
6699 "considered_access_paths": [
6700 {
6701 "rows_to_scan": 2,
6702 "filtering_effect": [
6703 ] /* filtering_effect */,
6704 "final_filtering_effect": 0.5,
6705 "access_type": "scan",
6706 "resulting_rows": 1,
6707 "cost": 0.701099,
6708 "chosen": true
6709 }
6710 ] /* considered_access_paths */
6711 } /* best_access_path */,
6712 "condition_filtering_pct": 100,
6713 "rows_for_plan": 1,
6714 "cost_for_plan": 0.701099,
6715 "chosen": true
6716 }
6717 ] /* considered_execution_plans */
6718 },
6719 {
6720 "transformation": {
6721 "select#": 2,
6722 "from": "IN (SELECT)",
6723 "to": "materialization",
6724 "has_nullable_expressions": true,
6725 "treat_UNKNOWN_as_FALSE": false,
6726 "possible": false,
6727 "cause": "cannot_handle_partial_matches"
6728 } /* transformation */
6729 },
6730 {
6731 "attaching_conditions_to_tables": {
6732 "original_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))",
6733 "attached_conditions_computation": [
6734 ] /* attached_conditions_computation */,
6735 "attached_conditions_summary": [
6736 {
6737 "table": "`t2`",
6738 "attached": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))"
6739 }
6740 ] /* attached_conditions_summary */
6741 } /* attaching_conditions_to_tables */
6742 },
6743 {
6744 "finalizing_table_conditions": [
6745 {
6746 "table": "`t2`",
6747 "original_table_condition": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))",
6748 "final_table_condition ": "((`t2`.`c` > 0) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`a`) = `t2`.`c`) or (`t2`.`c` is null)), true) and <if>(outer_field_is_not_null, ((<cache>(`t1`.`b`) = `t2`.`d`) or (`t2`.`d` is null)), true))"
6749 }
6750 ] /* finalizing_table_conditions */
6751 },
6752 {
6753 "refine_plan": [
6754 {
6755 "table": "`t2`"
6756 }
6757 ] /* refine_plan */
6758 }
6759 ] /* steps */
6760 } /* join_optimization */
6761 },
6762 {
6763 "join_execution": {
6764 "select#": 1,
6765 "steps": [
6766 {
6767 "subselect_execution": {
6768 "select#": 2,
6769 "steps": [
6770 {
6771 "join_execution": {
6772 "select#": 2,
6773 "steps": [
6774 ] /* steps */
6775 } /* join_execution */
6776 }
6777 ] /* steps */
6778 } /* subselect_execution */
6779 },
6780 {
6781 "subselect_execution": {
6782 "select#": 2,
6783 "steps": [
6784 {
6785 "join_execution": {
6786 "select#": 2,
6787 "steps": [
6788 ] /* steps */
6789 } /* join_execution */
6790 }
6791 ] /* steps */
6792 } /* subselect_execution */
6793 }
6794 ] /* steps */
6795 } /* join_execution */
6796 }
6797 ] /* steps */
6798 } 0 0
6799 select t1.a,avg(t2.c) as moyenne from t1, t2 where t2.c>-1
6800 group by t1.a having moyenne<>0;
6801 a moyenne
6802 1 1.5000
6803 NULL 1.5000
6804 select trace from information_schema.OPTIMIZER_TRACE;
6805 trace
6806 {
6807 "steps": [
6808 {
6809 "join_preparation": {
6810 "select#": 1,
6811 "steps": [
6812 {
6813 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,avg(`t2`.`c`) AS `moyenne` from `t1` join `t2` where (`t2`.`c` > -(1)) group by `t1`.`a` having (`moyenne` <> 0)"
6814 }
6815 ] /* steps */
6816 } /* join_preparation */
6817 },
6818 {
6819 "join_optimization": {
6820 "select#": 1,
6821 "steps": [
6822 {
6823 "condition_processing": {
6824 "condition": "WHERE",
6825 "original_condition": "(`t2`.`c` > -(1))",
6826 "steps": [
6827 {
6828 "transformation": "equality_propagation",
6829 "resulting_condition": "(`t2`.`c` > -(1))"
6830 },
6831 {
6832 "transformation": "constant_propagation",
6833 "resulting_condition": "(`t2`.`c` > -(1))"
6834 },
6835 {
6836 "transformation": "trivial_condition_removal",
6837 "resulting_condition": "(`t2`.`c` > -(1))"
6838 }
6839 ] /* steps */
6840 } /* condition_processing */
6841 },
6842 {
6843 "condition_processing": {
6844 "condition": "HAVING",
6845 "original_condition": "(`moyenne` <> 0)",
6846 "steps": [
6847 {
6848 "transformation": "constant_propagation",
6849 "resulting_condition": "(`moyenne` <> 0)"
6850 },
6851 {
6852 "transformation": "trivial_condition_removal",
6853 "resulting_condition": "(`moyenne` <> 0)"
6854 }
6855 ] /* steps */
6856 } /* condition_processing */
6857 },
6858 {
6859 "substitute_generated_columns": {
6860 } /* substitute_generated_columns */
6861 },
6862 {
6863 "table_dependencies": [
6864 {
6865 "table": "`t1`",
6866 "row_may_be_null": false,
6867 "map_bit": 0,
6868 "depends_on_map_bits": [
6869 ] /* depends_on_map_bits */
6870 },
6871 {
6872 "table": "`t2`",
6873 "row_may_be_null": false,
6874 "map_bit": 1,
6875 "depends_on_map_bits": [
6876 ] /* depends_on_map_bits */
6877 }
6878 ] /* table_dependencies */
6879 },
6880 {
6881 "ref_optimizer_key_uses": [
6882 ] /* ref_optimizer_key_uses */
6883 },
6884 {
6885 "rows_estimation": [
6886 {
6887 "table": "`t1`",
6888 "table_scan": {
6889 "rows": 2,
6890 "cost": 0.501099
6891 } /* table_scan */
6892 },
6893 {
6894 "table": "`t2`",
6895 "table_scan": {
6896 "rows": 2,
6897 "cost": 0.501099
6898 } /* table_scan */
6899 }
6900 ] /* rows_estimation */
6901 },
6902 {
6903 "considered_execution_plans": [
6904 {
6905 "plan_prefix": [
6906 ] /* plan_prefix */,
6907 "table": "`t1`",
6908 "best_access_path": {
6909 "considered_access_paths": [
6910 {
6911 "rows_to_scan": 2,
6912 "access_type": "scan",
6913 "resulting_rows": 2,
6914 "cost": 0.701099,
6915 "chosen": true,
6916 "use_tmp_table": true
6917 }
6918 ] /* considered_access_paths */
6919 } /* best_access_path */,
6920 "condition_filtering_pct": 100,
6921 "rows_for_plan": 2,
6922 "cost_for_plan": 0.701099,
6923 "rest_of_plan": [
6924 {
6925 "plan_prefix": [
6926 "`t1`"
6927 ] /* plan_prefix */,
6928 "table": "`t2`",
6929 "best_access_path": {
6930 "considered_access_paths": [
6931 {
6932 "rows_to_scan": 2,
6933 "filtering_effect": [
6934 ] /* filtering_effect */,
6935 "final_filtering_effect": 0.5,
6936 "access_type": "scan",
6937 "using_join_cache": true,
6938 "buffers_needed": 1,
6939 "resulting_rows": 1,
6940 "cost": 0.801122,
6941 "chosen": true
6942 }
6943 ] /* considered_access_paths */
6944 } /* best_access_path */,
6945 "condition_filtering_pct": 100,
6946 "rows_for_plan": 2,
6947 "cost_for_plan": 1.50222,
6948 "sort_cost": 2,
6949 "new_cost_for_plan": 3.50222,
6950 "chosen": true
6951 }
6952 ] /* rest_of_plan */
6953 },
6954 {
6955 "plan_prefix": [
6956 ] /* plan_prefix */,
6957 "table": "`t2`",
6958 "best_access_path": {
6959 "considered_access_paths": [
6960 {
6961 "rows_to_scan": 2,
6962 "filtering_effect": [
6963 ] /* filtering_effect */,
6964 "final_filtering_effect": 0.5,
6965 "access_type": "scan",
6966 "resulting_rows": 1,
6967 "cost": 0.701099,
6968 "chosen": true
6969 }
6970 ] /* considered_access_paths */
6971 } /* best_access_path */,
6972 "condition_filtering_pct": 100,
6973 "rows_for_plan": 1,
6974 "cost_for_plan": 0.701099,
6975 "rest_of_plan": [
6976 {
6977 "plan_prefix": [
6978 "`t2`"
6979 ] /* plan_prefix */,
6980 "table": "`t1`",
6981 "best_access_path": {
6982 "considered_access_paths": [
6983 {
6984 "rows_to_scan": 2,
6985 "access_type": "scan",
6986 "using_join_cache": true,
6987 "buffers_needed": 1,
6988 "resulting_rows": 2,
6989 "cost": 0.701108,
6990 "chosen": true
6991 }
6992 ] /* considered_access_paths */
6993 } /* best_access_path */,
6994 "condition_filtering_pct": 100,
6995 "rows_for_plan": 2,
6996 "cost_for_plan": 1.40221,
6997 "sort_cost": 2,
6998 "new_cost_for_plan": 3.40221,
6999 "chosen": true
7000 }
7001 ] /* rest_of_plan */
7002 }
7003 ] /* considered_execution_plans */
7004 },
7005 {
7006 "attaching_conditions_to_tables": {
7007 "original_condition": "(`t2`.`c` > -(1))",
7008 "attached_conditions_computation": [
7009 ] /* attached_conditions_computation */,
7010 "attached_conditions_summary": [
7011 {
7012 "table": "`t2`",
7013 "attached": "(`t2`.`c` > -(1))"
7014 },
7015 {
7016 "table": "`t1`",
7017 "attached": null
7018 }
7019 ] /* attached_conditions_summary */
7020 } /* attaching_conditions_to_tables */
7021 },
7022 {
7023 "optimizing_distinct_group_by_order_by": {
7024 "simplifying_group_by": {
7025 "original_clause": "`t1`.`a`",
7026 "items": [
7027 {
7028 "item": "`t1`.`a`"
7029 }
7030 ] /* items */,
7031 "resulting_clause_is_simple": false,
7032 "resulting_clause": "`t1`.`a`"
7033 } /* simplifying_group_by */
7034 } /* optimizing_distinct_group_by_order_by */
7035 },
7036 {
7037 "finalizing_table_conditions": [
7038 {
7039 "table": "`t2`",
7040 "original_table_condition": "(`t2`.`c` > -(1))",
7041 "final_table_condition ": "(`t2`.`c` > <cache>(-(1)))"
7042 }
7043 ] /* finalizing_table_conditions */
7044 },
7045 {
7046 "refine_plan": [
7047 {
7048 "table": "`t2`"
7049 },
7050 {
7051 "table": "`t1`"
7052 }
7053 ] /* refine_plan */
7054 },
7055 {
7056 "considering_tmp_tables": [
7057 {
7058 "adding_tmp_table_in_plan_at_position": 2,
7059 "write_method": "continuously_update_group_row"
7060 }
7061 ] /* considering_tmp_tables */
7062 }
7063 ] /* steps */
7064 } /* join_optimization */
7065 },
7066 {
7067 "join_execution": {
7068 "select#": 1,
7069 "steps": [
7070 {
7071 "temp_table_aggregate": {
7072 "select#": 1,
7073 "steps": [
7074 {
7075 "creating_tmp_table": {
7076 "tmp_table_info": {
7077 "table": "<temporary>",
7078 "in_plan_at_position": 2,
7079 "columns": 2,
7080 "row_length": 30,
7081 "key_length": 5,
7082 "unique_constraint": false,
7083 "makes_grouped_rows": true,
7084 "cannot_insert_duplicates": false,
7085 "location": "TempTable"
7086 } /* tmp_table_info */
7087 } /* creating_tmp_table */
7088 }
7089 ] /* steps */
7090 } /* temp_table_aggregate */
7091 }
7092 ] /* steps */
7093 } /* join_execution */
7094 }
7095 ] /* steps */
7096 }
7097 select t1.a,avg(t2.c) as moyenne from t1, t2 where t2.c>-1
7098 group by t1.a having 4=5;
7099 a moyenne
7100 select trace from information_schema.OPTIMIZER_TRACE;
7101 trace
7102 {
7103 "steps": [
7104 {
7105 "join_preparation": {
7106 "select#": 1,
7107 "steps": [
7108 {
7109 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,avg(`t2`.`c`) AS `moyenne` from `t1` join `t2` where (`t2`.`c` > -(1)) group by `t1`.`a` having false"
7110 }
7111 ] /* steps */
7112 } /* join_preparation */
7113 },
7114 {
7115 "join_optimization": {
7116 "select#": 1,
7117 "steps": [
7118 {
7119 "condition_processing": {
7120 "condition": "WHERE",
7121 "original_condition": "(`t2`.`c` > -(1))",
7122 "steps": [
7123 {
7124 "transformation": "equality_propagation",
7125 "resulting_condition": "(`t2`.`c` > -(1))"
7126 },
7127 {
7128 "transformation": "constant_propagation",
7129 "resulting_condition": "(`t2`.`c` > -(1))"
7130 },
7131 {
7132 "transformation": "trivial_condition_removal",
7133 "resulting_condition": "(`t2`.`c` > -(1))"
7134 }
7135 ] /* steps */
7136 } /* condition_processing */
7137 },
7138 {
7139 "condition_processing": {
7140 "condition": "HAVING",
7141 "original_condition": "false",
7142 "steps": [
7143 {
7144 "transformation": "constant_propagation",
7145 "resulting_condition": "false"
7146 },
7147 {
7148 "transformation": "trivial_condition_removal",
7149 "resulting_condition": null
7150 }
7151 ] /* steps */
7152 } /* condition_processing */
7153 }
7154 ] /* steps */,
7155 "empty_result": {
7156 "cause": "Impossible HAVING"
7157 } /* empty_result */
7158 } /* join_optimization */
7159 },
7160 {
7161 "join_execution": {
7162 "select#": 1,
7163 "steps": [
7164 ] /* steps */
7165 } /* join_execution */
7166 }
7167 ] /* steps */
7168 }
7169 drop table t1,t2;
7170 update t6 set d=5 where d is NULL;
7171 select * from information_schema.OPTIMIZER_TRACE;
7172 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7173 update t6 set d=5 where d is NULL {
7174 "steps": [
7175 {
7176 "update_preparation": {
7177 "select#": 1,
7178 "steps": [
7179 "update `t6` set `t6`.`d` = 5 where (`t6`.`d` is null)"
7180 ] /* steps */
7181 } /* update_preparation */
7182 },
7183 {
7184 "substitute_generated_columns": {
7185 } /* substitute_generated_columns */
7186 },
7187 {
7188 "condition_processing": {
7189 "condition": "WHERE",
7190 "original_condition": "(`t6`.`d` is null)",
7191 "steps": [
7192 {
7193 "transformation": "equality_propagation",
7194 "resulting_condition": "(`t6`.`d` is null)"
7195 },
7196 {
7197 "transformation": "constant_propagation",
7198 "resulting_condition": "(`t6`.`d` is null)"
7199 },
7200 {
7201 "transformation": "trivial_condition_removal",
7202 "resulting_condition": "(`t6`.`d` is null)"
7203 }
7204 ] /* steps */
7205 } /* condition_processing */
7206 },
7207 {
7208 "table": "`t6`",
7209 "range_analysis": {
7210 "table_scan": {
7211 "rows": 2,
7212 "cost": 2.80085
7213 } /* table_scan */,
7214 "potential_range_indexes": [
7215 {
7216 "index": "d",
7217 "usable": true,
7218 "key_parts": [
7219 "d"
7220 ] /* key_parts */
7221 }
7222 ] /* potential_range_indexes */,
7223 "setup_range_conditions": [
7224 ] /* setup_range_conditions */,
7225 "group_index_range": {
7226 "chosen": false,
7227 "cause": "no_join"
7228 } /* group_index_range */,
7229 "skip_scan_range": {
7230 "chosen": false,
7231 "cause": "no_join"
7232 } /* skip_scan_range */,
7233 "analyzing_range_alternatives": {
7234 "range_scan_alternatives": [
7235 {
7236 "index": "d",
7237 "ranges": [
7238 "d = NULL"
7239 ] /* ranges */,
7240 "index_dives_for_eq_ranges": true,
7241 "rowid_ordered": true,
7242 "using_mrr": false,
7243 "index_only": false,
7244 "in_memory": -1,
7245 "rows": 1,
7246 "cost": 0.61,
7247 "chosen": true
7248 }
7249 ] /* range_scan_alternatives */,
7250 "analyzing_roworder_intersect": {
7251 "usable": false,
7252 "cause": "too_few_roworder_scans"
7253 } /* analyzing_roworder_intersect */
7254 } /* analyzing_range_alternatives */,
7255 "chosen_range_access_summary": {
7256 "range_access_plan": {
7257 "type": "range_scan",
7258 "index": "d",
7259 "rows": 1,
7260 "ranges": [
7261 "d = NULL"
7262 ] /* ranges */
7263 } /* range_access_plan */,
7264 "rows_for_plan": 1,
7265 "cost_for_plan": 0.61,
7266 "chosen": true
7267 } /* chosen_range_access_summary */
7268 } /* range_analysis */
7269 }
7270 ] /* steps */
7271 } 0 0
7272 delete from t6 where d=5;
7273 select * from information_schema.OPTIMIZER_TRACE;
7274 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7275 delete from t6 where d=5 {
7276 "steps": [
7277 {
7278 "delete_preparation": {
7279 "select#": 1,
7280 "steps": [
7281 "delete from `t6` where (`t6`.`d` = 5)"
7282 ] /* steps */
7283 } /* delete_preparation */
7284 },
7285 {
7286 "substitute_generated_columns": {
7287 } /* substitute_generated_columns */
7288 },
7289 {
7290 "condition_processing": {
7291 "condition": "WHERE",
7292 "original_condition": "(`t6`.`d` = 5)",
7293 "steps": [
7294 {
7295 "transformation": "equality_propagation",
7296 "resulting_condition": "multiple equal(5, `t6`.`d`)"
7297 },
7298 {
7299 "transformation": "constant_propagation",
7300 "resulting_condition": "multiple equal(5, `t6`.`d`)"
7301 },
7302 {
7303 "transformation": "trivial_condition_removal",
7304 "resulting_condition": "multiple equal(5, `t6`.`d`)"
7305 }
7306 ] /* steps */
7307 } /* condition_processing */
7308 },
7309 {
7310 "table": "`t6`",
7311 "range_analysis": {
7312 "table_scan": {
7313 "rows": 2,
7314 "cost": 2.80085
7315 } /* table_scan */,
7316 "potential_range_indexes": [
7317 {
7318 "index": "d",
7319 "usable": true,
7320 "key_parts": [
7321 "d"
7322 ] /* key_parts */
7323 }
7324 ] /* potential_range_indexes */,
7325 "setup_range_conditions": [
7326 ] /* setup_range_conditions */,
7327 "group_index_range": {
7328 "chosen": false,
7329 "cause": "no_join"
7330 } /* group_index_range */,
7331 "skip_scan_range": {
7332 "chosen": false,
7333 "cause": "no_join"
7334 } /* skip_scan_range */,
7335 "analyzing_range_alternatives": {
7336 "range_scan_alternatives": [
7337 {
7338 "index": "d",
7339 "ranges": [
7340 "d = 5"
7341 ] /* ranges */,
7342 "index_dives_for_eq_ranges": true,
7343 "rowid_ordered": true,
7344 "using_mrr": false,
7345 "index_only": false,
7346 "in_memory": -1,
7347 "rows": 1,
7348 "cost": 0.61,
7349 "chosen": true
7350 }
7351 ] /* range_scan_alternatives */
7352 } /* analyzing_range_alternatives */,
7353 "chosen_range_access_summary": {
7354 "range_access_plan": {
7355 "type": "range_scan",
7356 "index": "d",
7357 "rows": 1,
7358 "ranges": [
7359 "d = 5"
7360 ] /* ranges */
7361 } /* range_access_plan */,
7362 "rows_for_plan": 1,
7363 "cost_for_plan": 0.61,
7364 "chosen": true
7365 } /* chosen_range_access_summary */
7366 } /* range_analysis */
7367 }
7368 ] /* steps */
7369 } 0 0
7370 insert into t6 values(6),(7),(8);
7371 select * from information_schema.OPTIMIZER_TRACE;
7372 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7373 insert into t6 values(6),(7),(8) {
7374 "steps": [
7375 ] /* steps */
7376 } 0 0
7377 insert into t6 select * from t6 where d>7;
7378 select * from information_schema.OPTIMIZER_TRACE;
7379 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7380 insert into t6 select * from t6 where d>7 {
7381 "steps": [
7382 {
7383 "join_preparation": {
7384 "select#": 1,
7385 "steps": [
7386 {
7387 "expanded_query": "insert into `t6` /* select#1 */ select sql_buffer_result `t6`.`d` AS `d` from `t6` where (`t6`.`d` > 7)"
7388 }
7389 ] /* steps */
7390 } /* join_preparation */
7391 },
7392 {
7393 "join_optimization": {
7394 "select#": 1,
7395 "steps": [
7396 {
7397 "condition_processing": {
7398 "condition": "WHERE",
7399 "original_condition": "(`t6`.`d` > 7)",
7400 "steps": [
7401 {
7402 "transformation": "equality_propagation",
7403 "resulting_condition": "(`t6`.`d` > 7)"
7404 },
7405 {
7406 "transformation": "constant_propagation",
7407 "resulting_condition": "(`t6`.`d` > 7)"
7408 },
7409 {
7410 "transformation": "trivial_condition_removal",
7411 "resulting_condition": "(`t6`.`d` > 7)"
7412 }
7413 ] /* steps */
7414 } /* condition_processing */
7415 },
7416 {
7417 "substitute_generated_columns": {
7418 } /* substitute_generated_columns */
7419 },
7420 {
7421 "table_dependencies": [
7422 {
7423 "table": "`t6`",
7424 "row_may_be_null": false,
7425 "map_bit": 0,
7426 "depends_on_map_bits": [
7427 ] /* depends_on_map_bits */
7428 }
7429 ] /* table_dependencies */
7430 },
7431 {
7432 "ref_optimizer_key_uses": [
7433 ] /* ref_optimizer_key_uses */
7434 },
7435 {
7436 "rows_estimation": [
7437 {
7438 "table": "`t6`",
7439 "range_analysis": {
7440 "table_scan": {
7441 "rows": 3,
7442 "cost": 2.90128
7443 } /* table_scan */,
7444 "potential_range_indexes": [
7445 {
7446 "index": "d",
7447 "usable": true,
7448 "key_parts": [
7449 "d"
7450 ] /* key_parts */
7451 }
7452 ] /* potential_range_indexes */,
7453 "best_covering_index_scan": {
7454 "index": "d",
7455 "cost": 0.561628,
7456 "chosen": true
7457 } /* best_covering_index_scan */,
7458 "setup_range_conditions": [
7459 ] /* setup_range_conditions */,
7460 "group_index_range": {
7461 "chosen": false,
7462 "cause": "not_group_by_or_distinct"
7463 } /* group_index_range */,
7464 "skip_scan_range": {
7465 "potential_skip_scan_indexes": [
7466 {
7467 "index": "d",
7468 "usable": false,
7469 "cause": "prefix_not_const_equality"
7470 }
7471 ] /* potential_skip_scan_indexes */
7472 } /* skip_scan_range */,
7473 "analyzing_range_alternatives": {
7474 "range_scan_alternatives": [
7475 {
7476 "index": "d",
7477 "ranges": [
7478 "7 < d"
7479 ] /* ranges */,
7480 "index_dives_for_eq_ranges": true,
7481 "rowid_ordered": false,
7482 "using_mrr": false,
7483 "index_only": true,
7484 "in_memory": -1,
7485 "rows": 2,
7486 "cost": 0.465814,
7487 "chosen": true
7488 }
7489 ] /* range_scan_alternatives */,
7490 "analyzing_roworder_intersect": {
7491 "usable": false,
7492 "cause": "too_few_roworder_scans"
7493 } /* analyzing_roworder_intersect */
7494 } /* analyzing_range_alternatives */,
7495 "chosen_range_access_summary": {
7496 "range_access_plan": {
7497 "type": "range_scan",
7498 "index": "d",
7499 "rows": 2,
7500 "ranges": [
7501 "7 < d"
7502 ] /* ranges */
7503 } /* range_access_plan */,
7504 "rows_for_plan": 2,
7505 "cost_for_plan": 0.465814,
7506 "chosen": true
7507 } /* chosen_range_access_summary */
7508 } /* range_analysis */
7509 }
7510 ] /* rows_estimation */
7511 },
7512 {
7513 "considered_execution_plans": [
7514 {
7515 "plan_prefix": [
7516 ] /* plan_prefix */,
7517 "table": "`t6`",
7518 "best_access_path": {
7519 "considered_access_paths": [
7520 {
7521 "rows_to_scan": 2,
7522 "access_type": "range",
7523 "range_details": {
7524 "used_index": "d"
7525 } /* range_details */,
7526 "resulting_rows": 2,
7527 "cost": 0.665814,
7528 "chosen": true
7529 }
7530 ] /* considered_access_paths */
7531 } /* best_access_path */,
7532 "condition_filtering_pct": 100,
7533 "rows_for_plan": 2,
7534 "cost_for_plan": 0.665814,
7535 "chosen": true
7536 }
7537 ] /* considered_execution_plans */
7538 },
7539 {
7540 "attaching_conditions_to_tables": {
7541 "original_condition": "(`t6`.`d` > 7)",
7542 "attached_conditions_computation": [
7543 ] /* attached_conditions_computation */,
7544 "attached_conditions_summary": [
7545 {
7546 "table": "`t6`",
7547 "attached": "(`t6`.`d` > 7)"
7548 }
7549 ] /* attached_conditions_summary */
7550 } /* attaching_conditions_to_tables */
7551 },
7552 {
7553 "finalizing_table_conditions": [
7554 {
7555 "table": "`t6`",
7556 "original_table_condition": "(`t6`.`d` > 7)",
7557 "final_table_condition ": "(`t6`.`d` > 7)"
7558 }
7559 ] /* finalizing_table_conditions */
7560 },
7561 {
7562 "refine_plan": [
7563 {
7564 "table": "`t6`"
7565 }
7566 ] /* refine_plan */
7567 },
7568 {
7569 "considering_tmp_tables": [
7570 {
7571 "adding_tmp_table_in_plan_at_position": 1,
7572 "write_method": "write_all_rows"
7573 }
7574 ] /* considering_tmp_tables */
7575 }
7576 ] /* steps */
7577 } /* join_optimization */
7578 },
7579 {
7580 "join_execution": {
7581 "select#": 1,
7582 "steps": [
7583 {
7584 "creating_tmp_table": {
7585 "tmp_table_info": {
7586 "table": "<temporary>",
7587 "in_plan_at_position": 1,
7588 "columns": 1,
7589 "row_length": 5,
7590 "key_length": 0,
7591 "unique_constraint": false,
7592 "makes_grouped_rows": false,
7593 "cannot_insert_duplicates": false,
7594 "location": "TempTable"
7595 } /* tmp_table_info */
7596 } /* creating_tmp_table */
7597 },
7598 {
7599 "materialize": {
7600 "select#": 1,
7601 "steps": [
7602 ] /* steps */
7603 } /* materialize */
7604 }
7605 ] /* steps */
7606 } /* join_execution */
7607 }
7608 ] /* steps */
7609 } 0 0
7610 update t5, t6 set t6.d=t6.d+t5.c+4-t5.c-4 where d>7000;
7611 select * from information_schema.OPTIMIZER_TRACE;
7612 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7613 update t5, t6 set t6.d=t6.d+t5.c+4-t5.c-4 where d>7000 {
7614 "steps": [
7615 {
7616 "update_preparation": {
7617 "select#": 1,
7618 "steps": [
7619 "update `t5` join `t6` set `t6`.`d` = ((((`t6`.`d` + `t5`.`c`) + 4) - `t5`.`c`) - 4) where (`t6`.`d` > 7000)"
7620 ] /* steps */
7621 } /* update_preparation */
7622 },
7623 {
7624 "join_optimization": {
7625 "select#": 1,
7626 "steps": [
7627 {
7628 "condition_processing": {
7629 "condition": "WHERE",
7630 "original_condition": "(`t6`.`d` > 7000)",
7631 "steps": [
7632 {
7633 "transformation": "equality_propagation",
7634 "resulting_condition": "(`t6`.`d` > 7000)"
7635 },
7636 {
7637 "transformation": "constant_propagation",
7638 "resulting_condition": "(`t6`.`d` > 7000)"
7639 },
7640 {
7641 "transformation": "trivial_condition_removal",
7642 "resulting_condition": "(`t6`.`d` > 7000)"
7643 }
7644 ] /* steps */
7645 } /* condition_processing */
7646 },
7647 {
7648 "substitute_generated_columns": {
7649 } /* substitute_generated_columns */
7650 },
7651 {
7652 "table_dependencies": [
7653 {
7654 "table": "`t5`",
7655 "row_may_be_null": false,
7656 "map_bit": 0,
7657 "depends_on_map_bits": [
7658 ] /* depends_on_map_bits */
7659 },
7660 {
7661 "table": "`t6`",
7662 "row_may_be_null": false,
7663 "map_bit": 1,
7664 "depends_on_map_bits": [
7665 ] /* depends_on_map_bits */
7666 }
7667 ] /* table_dependencies */
7668 },
7669 {
7670 "ref_optimizer_key_uses": [
7671 ] /* ref_optimizer_key_uses */
7672 },
7673 {
7674 "rows_estimation": [
7675 {
7676 "table": "`t5`",
7677 "rows": 1,
7678 "cost": 1,
7679 "table_type": "system",
7680 "empty": false
7681 },
7682 {
7683 "table": "`t6`",
7684 "range_analysis": {
7685 "table_scan": {
7686 "rows": 4,
7687 "cost": 3.00171
7688 } /* table_scan */,
7689 "potential_range_indexes": [
7690 {
7691 "index": "d",
7692 "usable": true,
7693 "key_parts": [
7694 "d"
7695 ] /* key_parts */
7696 }
7697 ] /* potential_range_indexes */,
7698 "setup_range_conditions": [
7699 ] /* setup_range_conditions */,
7700 "group_index_range": {
7701 "chosen": false,
7702 "cause": "not_single_table"
7703 } /* group_index_range */,
7704 "skip_scan_range": {
7705 "chosen": false,
7706 "cause": "not_single_table"
7707 } /* skip_scan_range */,
7708 "analyzing_range_alternatives": {
7709 "range_scan_alternatives": [
7710 {
7711 "index": "d",
7712 "ranges": [
7713 "7000 < d"
7714 ] /* ranges */,
7715 "index_dives_for_eq_ranges": true,
7716 "rowid_ordered": false,
7717 "using_mrr": false,
7718 "index_only": false,
7719 "in_memory": -1,
7720 "rows": 1,
7721 "cost": 0.61,
7722 "chosen": true
7723 }
7724 ] /* range_scan_alternatives */,
7725 "analyzing_roworder_intersect": {
7726 "usable": false,
7727 "cause": "too_few_roworder_scans"
7728 } /* analyzing_roworder_intersect */
7729 } /* analyzing_range_alternatives */,
7730 "chosen_range_access_summary": {
7731 "range_access_plan": {
7732 "type": "range_scan",
7733 "index": "d",
7734 "rows": 1,
7735 "ranges": [
7736 "7000 < d"
7737 ] /* ranges */
7738 } /* range_access_plan */,
7739 "rows_for_plan": 1,
7740 "cost_for_plan": 0.61,
7741 "chosen": true
7742 } /* chosen_range_access_summary */
7743 } /* range_analysis */
7744 }
7745 ] /* rows_estimation */
7746 },
7747 {
7748 "considered_execution_plans": [
7749 {
7750 "plan_prefix": [
7751 "`t5`"
7752 ] /* plan_prefix */,
7753 "table": "`t6`",
7754 "best_access_path": {
7755 "considered_access_paths": [
7756 {
7757 "rows_to_scan": 1,
7758 "filtering_effect": [
7759 ] /* filtering_effect */,
7760 "final_filtering_effect": 1,
7761 "access_type": "range",
7762 "range_details": {
7763 "used_index": "d"
7764 } /* range_details */,
7765 "resulting_rows": 1,
7766 "cost": 0.71,
7767 "chosen": true
7768 }
7769 ] /* considered_access_paths */
7770 } /* best_access_path */,
7771 "condition_filtering_pct": 100,
7772 "rows_for_plan": 1,
7773 "cost_for_plan": 0.71,
7774 "chosen": true
7775 }
7776 ] /* considered_execution_plans */
7777 },
7778 {
7779 "attaching_conditions_to_tables": {
7780 "original_condition": "(`t6`.`d` > 7000)",
7781 "attached_conditions_computation": [
7782 ] /* attached_conditions_computation */,
7783 "attached_conditions_summary": [
7784 {
7785 "table": "`t6`",
7786 "attached": "(`t6`.`d` > 7000)"
7787 }
7788 ] /* attached_conditions_summary */
7789 } /* attaching_conditions_to_tables */
7790 },
7791 {
7792 "finalizing_table_conditions": [
7793 {
7794 "table": "`t6`",
7795 "original_table_condition": "(`t6`.`d` > 7000)",
7796 "final_table_condition ": "(`t6`.`d` > 7000)"
7797 }
7798 ] /* finalizing_table_conditions */
7799 },
7800 {
7801 "refine_plan": [
7802 {
7803 "table": "`t6`"
7804 }
7805 ] /* refine_plan */
7806 }
7807 ] /* steps */
7808 } /* join_optimization */
7809 },
7810 {
7811 "creating_tmp_table": {
7812 "tmp_table_info": {
7813 "table": "intermediate_tmp_table",
7814 "columns": 2,
7815 "row_length": 13,
7816 "key_length": 9,
7817 "unique_constraint": false,
7818 "makes_grouped_rows": true,
7819 "cannot_insert_duplicates": false,
7820 "location": "TempTable"
7821 } /* tmp_table_info */
7822 } /* creating_tmp_table */
7823 },
7824 {
7825 "join_execution": {
7826 "select#": 1,
7827 "steps": [
7828 ] /* steps */
7829 } /* join_execution */
7830 }
7831 ] /* steps */
7832 } 0 0
7833 delete t6 from t5, t6 where d>7000;
7834 select * from information_schema.OPTIMIZER_TRACE;
7835 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7836 delete t6 from t5, t6 where d>7000 {
7837 "steps": [
7838 {
7839 "delete_preparation": {
7840 "select#": 1,
7841 "steps": [
7842 "delete `t6` from `t5` join `t6` where (`t6`.`d` > 7000)"
7843 ] /* steps */
7844 } /* delete_preparation */
7845 },
7846 {
7847 "join_optimization": {
7848 "select#": 1,
7849 "steps": [
7850 {
7851 "condition_processing": {
7852 "condition": "WHERE",
7853 "original_condition": "(`t6`.`d` > 7000)",
7854 "steps": [
7855 {
7856 "transformation": "equality_propagation",
7857 "resulting_condition": "(`t6`.`d` > 7000)"
7858 },
7859 {
7860 "transformation": "constant_propagation",
7861 "resulting_condition": "(`t6`.`d` > 7000)"
7862 },
7863 {
7864 "transformation": "trivial_condition_removal",
7865 "resulting_condition": "(`t6`.`d` > 7000)"
7866 }
7867 ] /* steps */
7868 } /* condition_processing */
7869 },
7870 {
7871 "substitute_generated_columns": {
7872 } /* substitute_generated_columns */
7873 },
7874 {
7875 "table_dependencies": [
7876 {
7877 "table": "`t5`",
7878 "row_may_be_null": false,
7879 "map_bit": 0,
7880 "depends_on_map_bits": [
7881 ] /* depends_on_map_bits */
7882 },
7883 {
7884 "table": "`t6`",
7885 "row_may_be_null": false,
7886 "map_bit": 1,
7887 "depends_on_map_bits": [
7888 ] /* depends_on_map_bits */
7889 }
7890 ] /* table_dependencies */
7891 },
7892 {
7893 "ref_optimizer_key_uses": [
7894 ] /* ref_optimizer_key_uses */
7895 },
7896 {
7897 "rows_estimation": [
7898 {
7899 "table": "`t5`",
7900 "rows": 1,
7901 "cost": 1,
7902 "table_type": "system",
7903 "empty": false
7904 },
7905 {
7906 "table": "`t6`",
7907 "range_analysis": {
7908 "table_scan": {
7909 "rows": 4,
7910 "cost": 3.00171
7911 } /* table_scan */,
7912 "potential_range_indexes": [
7913 {
7914 "index": "d",
7915 "usable": true,
7916 "key_parts": [
7917 "d"
7918 ] /* key_parts */
7919 }
7920 ] /* potential_range_indexes */,
7921 "best_covering_index_scan": {
7922 "index": "d",
7923 "cost": 0.667442,
7924 "chosen": true
7925 } /* best_covering_index_scan */,
7926 "setup_range_conditions": [
7927 ] /* setup_range_conditions */,
7928 "group_index_range": {
7929 "chosen": false,
7930 "cause": "not_single_table"
7931 } /* group_index_range */,
7932 "skip_scan_range": {
7933 "chosen": false,
7934 "cause": "not_single_table"
7935 } /* skip_scan_range */,
7936 "analyzing_range_alternatives": {
7937 "range_scan_alternatives": [
7938 {
7939 "index": "d",
7940 "ranges": [
7941 "7000 < d"
7942 ] /* ranges */,
7943 "index_dives_for_eq_ranges": true,
7944 "rowid_ordered": false,
7945 "using_mrr": false,
7946 "index_only": true,
7947 "in_memory": -1,
7948 "rows": 1,
7949 "cost": 0.36,
7950 "chosen": true
7951 }
7952 ] /* range_scan_alternatives */,
7953 "analyzing_roworder_intersect": {
7954 "usable": false,
7955 "cause": "too_few_roworder_scans"
7956 } /* analyzing_roworder_intersect */
7957 } /* analyzing_range_alternatives */,
7958 "chosen_range_access_summary": {
7959 "range_access_plan": {
7960 "type": "range_scan",
7961 "index": "d",
7962 "rows": 1,
7963 "ranges": [
7964 "7000 < d"
7965 ] /* ranges */
7966 } /* range_access_plan */,
7967 "rows_for_plan": 1,
7968 "cost_for_plan": 0.36,
7969 "chosen": true
7970 } /* chosen_range_access_summary */
7971 } /* range_analysis */
7972 }
7973 ] /* rows_estimation */
7974 },
7975 {
7976 "considered_execution_plans": [
7977 {
7978 "plan_prefix": [
7979 "`t5`"
7980 ] /* plan_prefix */,
7981 "table": "`t6`",
7982 "best_access_path": {
7983 "considered_access_paths": [
7984 {
7985 "rows_to_scan": 1,
7986 "filtering_effect": [
7987 ] /* filtering_effect */,
7988 "final_filtering_effect": 1,
7989 "access_type": "range",
7990 "range_details": {
7991 "used_index": "d"
7992 } /* range_details */,
7993 "resulting_rows": 1,
7994 "cost": 0.46,
7995 "chosen": true
7996 }
7997 ] /* considered_access_paths */
7998 } /* best_access_path */,
7999 "condition_filtering_pct": 100,
8000 "rows_for_plan": 1,
8001 "cost_for_plan": 0.46,
8002 "chosen": true
8003 }
8004 ] /* considered_execution_plans */
8005 },
8006 {
8007 "attaching_conditions_to_tables": {
8008 "original_condition": "(`t6`.`d` > 7000)",
8009 "attached_conditions_computation": [
8010 ] /* attached_conditions_computation */,
8011 "attached_conditions_summary": [
8012 {
8013 "table": "`t6`",
8014 "attached": "(`t6`.`d` > 7000)"
8015 }
8016 ] /* attached_conditions_summary */
8017 } /* attaching_conditions_to_tables */
8018 },
8019 {
8020 "finalizing_table_conditions": [
8021 {
8022 "table": "`t6`",
8023 "original_table_condition": "(`t6`.`d` > 7000)",
8024 "final_table_condition ": "(`t6`.`d` > 7000)"
8025 }
8026 ] /* finalizing_table_conditions */
8027 },
8028 {
8029 "refine_plan": [
8030 {
8031 "table": "`t6`"
8032 }
8033 ] /* refine_plan */
8034 }
8035 ] /* steps */
8036 } /* join_optimization */
8037 },
8038 {
8039 "join_execution": {
8040 "select#": 1,
8041 "steps": [
8042 ] /* steps */
8043 } /* join_execution */
8044 }
8045 ] /* steps */
8046 } 0 0
8047 set optimizer_trace_offset=2,optimizer_trace_limit=2;
8048 select * from information_schema.OPTIMIZER_TRACE;
8049 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8050 select 1;
8051 1
8052 1
8053 select 2;
8054 2
8055 2
8056 select 3;
8057 3
8058 3
8059 select 4;
8060 4
8061 4
8062 select 5;
8063 5
8064 5
8065 select * from information_schema.OPTIMIZER_TRACE;
8066 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8067 select 3 {
8068 "steps": [
8069 {
8070 "join_preparation": {
8071 "select#": 1,
8072 "steps": [
8073 {
8074 "expanded_query": "/* select#1 */ select 3 AS `3`"
8075 }
8076 ] /* steps */
8077 } /* join_preparation */
8078 },
8079 {
8080 "join_optimization": {
8081 "select#": 1,
8082 "steps": [
8083 ] /* steps */
8084 } /* join_optimization */
8085 },
8086 {
8087 "join_execution": {
8088 "select#": 1,
8089 "steps": [
8090 ] /* steps */
8091 } /* join_execution */
8092 }
8093 ] /* steps */
8094 } 0 0
8095 select 4 {
8096 "steps": [
8097 {
8098 "join_preparation": {
8099 "select#": 1,
8100 "steps": [
8101 {
8102 "expanded_query": "/* select#1 */ select 4 AS `4`"
8103 }
8104 ] /* steps */
8105 } /* join_preparation */
8106 },
8107 {
8108 "join_optimization": {
8109 "select#": 1,
8110 "steps": [
8111 ] /* steps */
8112 } /* join_optimization */
8113 },
8114 {
8115 "join_execution": {
8116 "select#": 1,
8117 "steps": [
8118 ] /* steps */
8119 } /* join_execution */
8120 }
8121 ] /* steps */
8122 } 0 0
8123 set optimizer_trace_offset=-2,optimizer_trace_limit=2;
8124 select * from information_schema.OPTIMIZER_TRACE;
8125 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8126 select 1;
8127 1
8128 1
8129 select 2;
8130 2
8131 2
8132 select 3;
8133 3
8134 3
8135 select 4;
8136 4
8137 4
8138 select 5;
8139 5
8140 5
8141 select * from information_schema.OPTIMIZER_TRACE;
8142 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8143 select 4 {
8144 "steps": [
8145 {
8146 "join_preparation": {
8147 "select#": 1,
8148 "steps": [
8149 {
8150 "expanded_query": "/* select#1 */ select 4 AS `4`"
8151 }
8152 ] /* steps */
8153 } /* join_preparation */
8154 },
8155 {
8156 "join_optimization": {
8157 "select#": 1,
8158 "steps": [
8159 ] /* steps */
8160 } /* join_optimization */
8161 },
8162 {
8163 "join_execution": {
8164 "select#": 1,
8165 "steps": [
8166 ] /* steps */
8167 } /* join_execution */
8168 }
8169 ] /* steps */
8170 } 0 0
8171 select 5 {
8172 "steps": [
8173 {
8174 "join_preparation": {
8175 "select#": 1,
8176 "steps": [
8177 {
8178 "expanded_query": "/* select#1 */ select 5 AS `5`"
8179 }
8180 ] /* steps */
8181 } /* join_preparation */
8182 },
8183 {
8184 "join_optimization": {
8185 "select#": 1,
8186 "steps": [
8187 ] /* steps */
8188 } /* join_optimization */
8189 },
8190 {
8191 "join_execution": {
8192 "select#": 1,
8193 "steps": [
8194 ] /* steps */
8195 } /* join_execution */
8196 }
8197 ] /* steps */
8198 } 0 0
8199 set optimizer_trace_offset=default,optimizer_trace_limit=default;
8200 select * from information_schema.OPTIMIZER_TRACE;
8201 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8202 create table t1 (
8203 id char(16) not null default '',
8204 data int not null
8205 ) charset utf8mb4;
8206 create table t2 (
8207 s char(16),
8208 i int,
8209 d double
8210 ) charset utf8mb4;
8211 insert into t1 values ("a", 1), ("b", 2) |
8212 insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0), ("d", 4, 4.0) |
8213 create function f1() returns int
8214 begin
8215 declare ret int;
8216 insert into t1 values("z",0);
8217 delete from t1 where id="z";
8218 select sum(data) into ret from t1;
8219 return ret;
8220 end|
8221 select f1()|
8222 f1()
8223 3
8224 select * from information_schema.OPTIMIZER_TRACE|
8225 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8226 freturn 3 ret@0 {
8227 "steps": [
8228 ] /* steps */
8229 } 0 0
8230 select s, f1() from t2 order by s desc|
8231 s f1()
8232 d 3
8233 c 3
8234 b 3
8235 a 3
8236 select * from information_schema.OPTIMIZER_TRACE|
8237 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8238 freturn 3 ret@0 {
8239 "steps": [
8240 ] /* steps */
8241 } 0 0
8242 select * from t6 where d in (select f1() from t2 where s="c")|
8243 d
8244 select * from information_schema.OPTIMIZER_TRACE|
8245 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8246 freturn 3 ret@0 {
8247 "steps": [
8248 ] /* steps */
8249 } 0 0
8250 set @old_opt_switch=@@optimizer_switch;
8251 # Test was created when sj-mat-scan could not handle this query...
8252 set optimizer_switch="materialization=off";
8253 set optimizer_trace_offset=-60, optimizer_trace_limit=60|
8254 select * from t6 where d in (select f1() from t2 where s="c")|
8255 d
8256 select * from information_schema.OPTIMIZER_TRACE|
8257 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8258 select * from t6 where d in (select f1() from t2 where s="c") {
8259 "steps": [
8260 {
8261 "join_preparation": {
8262 "select#": 1,
8263 "steps": [
8264 {
8265 "join_preparation": {
8266 "select#": 2,
8267 "steps": [
8268 {
8269 "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = 'c')"
8270 }
8271 ] /* steps */
8272 } /* join_preparation */
8273 },
8274 {
8275 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where `t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = 'c'))"
8276 },
8277 {
8278 "transformation": {
8279 "select#": 2,
8280 "from": "IN (SELECT)",
8281 "to": "semijoin",
8282 "chosen": true,
8283 "transformation_to_semi_join": {
8284 "subquery_predicate": "`t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = 'c'))",
8285 "embedded in": "WHERE",
8286 "evaluating_constant_semijoin_conditions": [
8287 ] /* evaluating_constant_semijoin_conditions */,
8288 "semi-join condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
8289 "decorrelated_predicates": [
8290 {
8291 "outer": "`t6`.`d`",
8292 "inner": "`f1`()"
8293 }
8294 ] /* decorrelated_predicates */
8295 } /* transformation_to_semi_join */
8296 } /* transformation */
8297 },
8298 {
8299 "transformations_to_nested_joins": {
8300 "transformations": [
8301 "semijoin"
8302 ] /* transformations */,
8303 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` semi join (`t2`) where ((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
8304 } /* transformations_to_nested_joins */
8305 }
8306 ] /* steps */
8307 } /* join_preparation */
8308 },
8309 {
8310 "join_optimization": {
8311 "select#": 1,
8312 "steps": [
8313 {
8314 "condition_processing": {
8315 "condition": "WHERE",
8316 "original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
8317 "steps": [
8318 {
8319 "transformation": "equality_propagation",
8320 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal('c', `t2`.`s`))"
8321 },
8322 {
8323 "transformation": "constant_propagation",
8324 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal('c', `t2`.`s`))"
8325 },
8326 {
8327 "transformation": "trivial_condition_removal",
8328 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal('c', `t2`.`s`))"
8329 }
8330 ] /* steps */
8331 } /* condition_processing */
8332 },
8333 {
8334 "substitute_generated_columns": {
8335 } /* substitute_generated_columns */
8336 },
8337 {
8338 "table_dependencies": [
8339 {
8340 "table": "`t6`",
8341 "row_may_be_null": false,
8342 "map_bit": 0,
8343 "depends_on_map_bits": [
8344 ] /* depends_on_map_bits */
8345 },
8346 {
8347 "table": "`t2`",
8348 "row_may_be_null": false,
8349 "map_bit": 1,
8350 "depends_on_map_bits": [
8351 ] /* depends_on_map_bits */
8352 }
8353 ] /* table_dependencies */
8354 },
8355 {
8356 "ref_optimizer_key_uses": [
8357 ] /* ref_optimizer_key_uses */
8358 },
8359 {
8360 "pulled_out_semijoin_tables": [
8361 ] /* pulled_out_semijoin_tables */
8362 },
8363 {
8364 "rows_estimation": [
8365 {
8366 "table": "`t6`",
8367 "table_scan": {
8368 "rows": 4,
8369 "cost": 0.501709
8370 } /* table_scan */
8371 },
8372 {
8373 "table": "`t2`",
8374 "table_scan": {
8375 "rows": 4,
8376 "cost": 0.518799
8377 } /* table_scan */
8378 }
8379 ] /* rows_estimation */
8380 },
8381 {
8382 "considered_execution_plans": [
8383 {
8384 "plan_prefix": [
8385 ] /* plan_prefix */,
8386 "table": "`t6`",
8387 "best_access_path": {
8388 "considered_access_paths": [
8389 {
8390 "rows_to_scan": 4,
8391 "filtering_effect": [
8392 ] /* filtering_effect */,
8393 "final_filtering_effect": 1,
8394 "access_type": "scan",
8395 "resulting_rows": 4,
8396 "cost": 0.901709,
8397 "chosen": true
8398 }
8399 ] /* considered_access_paths */
8400 } /* best_access_path */,
8401 "condition_filtering_pct": 25,
8402 "rows_for_plan": 1,
8403 "cost_for_plan": 0.901709,
8404 "semijoin_strategy_choice": [
8405 ] /* semijoin_strategy_choice */,
8406 "rest_of_plan": [
8407 {
8408 "plan_prefix": [
8409 "`t6`"
8410 ] /* plan_prefix */,
8411 "table": "`t2`",
8412 "best_access_path": {
8413 "considered_access_paths": [
8414 {
8415 "rows_to_scan": 4,
8416 "filtering_effect": [
8417 ] /* filtering_effect */,
8418 "final_filtering_effect": 0.25,
8419 "access_type": "scan",
8420 "using_join_cache": true,
8421 "buffers_needed": 1,
8422 "resulting_rows": 1,
8423 "cost": 0.918814,
8424 "chosen": true
8425 }
8426 ] /* considered_access_paths */
8427 } /* best_access_path */,
8428 "condition_filtering_pct": 100,
8429 "rows_for_plan": 1,
8430 "cost_for_plan": 1.82052,
8431 "semijoin_strategy_choice": [
8432 {
8433 "strategy": "FirstMatch",
8434 "recalculate_access_paths_and_cost": {
8435 "tables": [
8436 {
8437 "table": "`t2`",
8438 "best_access_path": {
8439 "considered_access_paths": [
8440 {
8441 "rows_to_scan": 4,
8442 "filtering_effect": [
8443 ] /* filtering_effect */,
8444 "final_filtering_effect": 0.25,
8445 "access_type": "scan",
8446 "using_join_cache": true,
8447 "buffers_needed": 1,
8448 "resulting_rows": 1,
8449 "cost": 0.918814,
8450 "chosen": true
8451 }
8452 ] /* considered_access_paths */
8453 } /* best_access_path */
8454 }
8455 ] /* tables */
8456 } /* recalculate_access_paths_and_cost */,
8457 "cost": 1.82052,
8458 "rows": 1,
8459 "chosen": true
8460 },
8461 {
8462 "strategy": "DuplicatesWeedout",
8463 "cost": 3.02052,
8464 "rows": 1,
8465 "duplicate_tables_left": false,
8466 "chosen": false
8467 }
8468 ] /* semijoin_strategy_choice */,
8469 "chosen": true
8470 }
8471 ] /* rest_of_plan */
8472 },
8473 {
8474 "plan_prefix": [
8475 ] /* plan_prefix */,
8476 "table": "`t2`",
8477 "best_access_path": {
8478 "considered_access_paths": [
8479 {
8480 "rows_to_scan": 4,
8481 "filtering_effect": [
8482 ] /* filtering_effect */,
8483 "final_filtering_effect": 0.25,
8484 "access_type": "scan",
8485 "resulting_rows": 1,
8486 "cost": 0.918799,
8487 "chosen": true
8488 }
8489 ] /* considered_access_paths */
8490 } /* best_access_path */,
8491 "condition_filtering_pct": 100,
8492 "rows_for_plan": 1,
8493 "cost_for_plan": 0.918799,
8494 "semijoin_strategy_choice": [
8495 ] /* semijoin_strategy_choice */,
8496 "pruned_by_heuristic": true
8497 },
8498 {
8499 "final_semijoin_strategy": "FirstMatch",
8500 "recalculate_access_paths_and_cost": {
8501 "tables": [
8502 {
8503 "table": "`t2`",
8504 "best_access_path": {
8505 "considered_access_paths": [
8506 {
8507 "rows_to_scan": 4,
8508 "filtering_effect": [
8509 ] /* filtering_effect */,
8510 "final_filtering_effect": 0.25,
8511 "access_type": "scan",
8512 "using_join_cache": true,
8513 "buffers_needed": 1,
8514 "resulting_rows": 1,
8515 "cost": 0.918814,
8516 "chosen": true
8517 }
8518 ] /* considered_access_paths */
8519 } /* best_access_path */
8520 }
8521 ] /* tables */
8522 } /* recalculate_access_paths_and_cost */
8523 }
8524 ] /* considered_execution_plans */
8525 },
8526 {
8527 "attaching_conditions_to_tables": {
8528 "original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
8529 "attached_conditions_computation": [
8530 ] /* attached_conditions_computation */,
8531 "attached_conditions_summary": [
8532 {
8533 "table": "`t6`",
8534 "attached": null
8535 },
8536 {
8537 "table": "`t2`",
8538 "attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
8539 }
8540 ] /* attached_conditions_summary */
8541 } /* attaching_conditions_to_tables */
8542 },
8543 {
8544 "finalizing_table_conditions": [
8545 {
8546 "table": "`t2`",
8547 "original_table_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
8548 "final_table_condition ": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
8549 }
8550 ] /* finalizing_table_conditions */
8551 },
8552 {
8553 "refine_plan": [
8554 {
8555 "table": "`t6`"
8556 },
8557 {
8558 "table": "`t2`"
8559 }
8560 ] /* refine_plan */
8561 }
8562 ] /* steps */
8563 } /* join_optimization */
8564 },
8565 {
8566 "join_execution": {
8567 "select#": 1,
8568 "steps": [
8569 ] /* steps */
8570 } /* join_execution */
8571 }
8572 ] /* steps */
8573 } 0 0
8574 set ret@0 NULL {
8575 "steps": [
8576 ] /* steps */
8577 } 0 0
8578 insert into t1 values("z",0) {
8579 "steps": [
8580 ] /* steps */
8581 } 0 0
8582 delete from t1 where id="z" {
8583 "steps": [
8584 {
8585 "substitute_generated_columns": {
8586 } /* substitute_generated_columns */
8587 },
8588 {
8589 "condition_processing": {
8590 "condition": "WHERE",
8591 "original_condition": "(`t1`.`id` = 'z')",
8592 "steps": [
8593 {
8594 "transformation": "equality_propagation",
8595 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8596 },
8597 {
8598 "transformation": "constant_propagation",
8599 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8600 },
8601 {
8602 "transformation": "trivial_condition_removal",
8603 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8604 }
8605 ] /* steps */
8606 } /* condition_processing */
8607 },
8608 {
8609 "table": "`t1`",
8610 "range_analysis": {
8611 "table_scan": {
8612 "rows": 3,
8613 "cost": 2.91263
8614 } /* table_scan */
8615 } /* range_analysis */
8616 }
8617 ] /* steps */
8618 } 0 0
8619 select sum(data) into ret from t1 {
8620 "steps": [
8621 {
8622 "join_optimization": {
8623 "select#": 1,
8624 "steps": [
8625 {
8626 "table_dependencies": [
8627 {
8628 "table": "`t1`",
8629 "row_may_be_null": false,
8630 "map_bit": 0,
8631 "depends_on_map_bits": [
8632 ] /* depends_on_map_bits */
8633 }
8634 ] /* table_dependencies */
8635 },
8636 {
8637 "rows_estimation": [
8638 {
8639 "table": "`t1`",
8640 "table_scan": {
8641 "rows": 2,
8642 "cost": 0.512634
8643 } /* table_scan */
8644 }
8645 ] /* rows_estimation */
8646 },
8647 {
8648 "considered_execution_plans": [
8649 {
8650 "plan_prefix": [
8651 ] /* plan_prefix */,
8652 "table": "`t1`",
8653 "best_access_path": {
8654 "considered_access_paths": [
8655 {
8656 "rows_to_scan": 2,
8657 "access_type": "scan",
8658 "resulting_rows": 2,
8659 "cost": 0.712634,
8660 "chosen": true
8661 }
8662 ] /* considered_access_paths */
8663 } /* best_access_path */,
8664 "condition_filtering_pct": 100,
8665 "rows_for_plan": 2,
8666 "cost_for_plan": 0.712634,
8667 "chosen": true
8668 }
8669 ] /* considered_execution_plans */
8670 },
8671 {
8672 "attaching_conditions_to_tables": {
8673 "original_condition": null,
8674 "attached_conditions_computation": [
8675 ] /* attached_conditions_computation */,
8676 "attached_conditions_summary": [
8677 {
8678 "table": "`t1`",
8679 "attached": null
8680 }
8681 ] /* attached_conditions_summary */
8682 } /* attaching_conditions_to_tables */
8683 },
8684 {
8685 "optimizing_distinct_group_by_order_by": {
8686 } /* optimizing_distinct_group_by_order_by */
8687 },
8688 {
8689 "finalizing_table_conditions": [
8690 ] /* finalizing_table_conditions */
8691 },
8692 {
8693 "refine_plan": [
8694 {
8695 "table": "`t1`"
8696 }
8697 ] /* refine_plan */
8698 },
8699 {
8700 "considering_tmp_tables": [
8701 ] /* considering_tmp_tables */
8702 }
8703 ] /* steps */
8704 } /* join_optimization */
8705 },
8706 {
8707 "join_execution": {
8708 "select#": 1,
8709 "steps": [
8710 ] /* steps */
8711 } /* join_execution */
8712 }
8713 ] /* steps */
8714 } 0 0
8715 freturn 3 ret@0 {
8716 "steps": [
8717 ] /* steps */
8718 } 0 0
8719 set ret@0 NULL {
8720 "steps": [
8721 ] /* steps */
8722 } 0 0
8723 insert into t1 values("z",0) {
8724 "steps": [
8725 ] /* steps */
8726 } 0 0
8727 delete from t1 where id="z" {
8728 "steps": [
8729 {
8730 "substitute_generated_columns": {
8731 } /* substitute_generated_columns */
8732 },
8733 {
8734 "condition_processing": {
8735 "condition": "WHERE",
8736 "original_condition": "(`t1`.`id` = 'z')",
8737 "steps": [
8738 {
8739 "transformation": "equality_propagation",
8740 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8741 },
8742 {
8743 "transformation": "constant_propagation",
8744 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8745 },
8746 {
8747 "transformation": "trivial_condition_removal",
8748 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8749 }
8750 ] /* steps */
8751 } /* condition_processing */
8752 },
8753 {
8754 "table": "`t1`",
8755 "range_analysis": {
8756 "table_scan": {
8757 "rows": 3,
8758 "cost": 2.91263
8759 } /* table_scan */
8760 } /* range_analysis */
8761 }
8762 ] /* steps */
8763 } 0 0
8764 select sum(data) into ret from t1 {
8765 "steps": [
8766 {
8767 "join_optimization": {
8768 "select#": 1,
8769 "steps": [
8770 {
8771 "table_dependencies": [
8772 {
8773 "table": "`t1`",
8774 "row_may_be_null": false,
8775 "map_bit": 0,
8776 "depends_on_map_bits": [
8777 ] /* depends_on_map_bits */
8778 }
8779 ] /* table_dependencies */
8780 },
8781 {
8782 "rows_estimation": [
8783 {
8784 "table": "`t1`",
8785 "table_scan": {
8786 "rows": 2,
8787 "cost": 0.512634
8788 } /* table_scan */
8789 }
8790 ] /* rows_estimation */
8791 },
8792 {
8793 "considered_execution_plans": [
8794 {
8795 "plan_prefix": [
8796 ] /* plan_prefix */,
8797 "table": "`t1`",
8798 "best_access_path": {
8799 "considered_access_paths": [
8800 {
8801 "rows_to_scan": 2,
8802 "access_type": "scan",
8803 "resulting_rows": 2,
8804 "cost": 0.712634,
8805 "chosen": true
8806 }
8807 ] /* considered_access_paths */
8808 } /* best_access_path */,
8809 "condition_filtering_pct": 100,
8810 "rows_for_plan": 2,
8811 "cost_for_plan": 0.712634,
8812 "chosen": true
8813 }
8814 ] /* considered_execution_plans */
8815 },
8816 {
8817 "attaching_conditions_to_tables": {
8818 "original_condition": null,
8819 "attached_conditions_computation": [
8820 ] /* attached_conditions_computation */,
8821 "attached_conditions_summary": [
8822 {
8823 "table": "`t1`",
8824 "attached": null
8825 }
8826 ] /* attached_conditions_summary */
8827 } /* attaching_conditions_to_tables */
8828 },
8829 {
8830 "optimizing_distinct_group_by_order_by": {
8831 } /* optimizing_distinct_group_by_order_by */
8832 },
8833 {
8834 "finalizing_table_conditions": [
8835 ] /* finalizing_table_conditions */
8836 },
8837 {
8838 "refine_plan": [
8839 {
8840 "table": "`t1`"
8841 }
8842 ] /* refine_plan */
8843 },
8844 {
8845 "considering_tmp_tables": [
8846 ] /* considering_tmp_tables */
8847 }
8848 ] /* steps */
8849 } /* join_optimization */
8850 },
8851 {
8852 "join_execution": {
8853 "select#": 1,
8854 "steps": [
8855 ] /* steps */
8856 } /* join_execution */
8857 }
8858 ] /* steps */
8859 } 0 0
8860 freturn 3 ret@0 {
8861 "steps": [
8862 ] /* steps */
8863 } 0 0
8864 set ret@0 NULL {
8865 "steps": [
8866 ] /* steps */
8867 } 0 0
8868 insert into t1 values("z",0) {
8869 "steps": [
8870 ] /* steps */
8871 } 0 0
8872 delete from t1 where id="z" {
8873 "steps": [
8874 {
8875 "substitute_generated_columns": {
8876 } /* substitute_generated_columns */
8877 },
8878 {
8879 "condition_processing": {
8880 "condition": "WHERE",
8881 "original_condition": "(`t1`.`id` = 'z')",
8882 "steps": [
8883 {
8884 "transformation": "equality_propagation",
8885 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8886 },
8887 {
8888 "transformation": "constant_propagation",
8889 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8890 },
8891 {
8892 "transformation": "trivial_condition_removal",
8893 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8894 }
8895 ] /* steps */
8896 } /* condition_processing */
8897 },
8898 {
8899 "table": "`t1`",
8900 "range_analysis": {
8901 "table_scan": {
8902 "rows": 3,
8903 "cost": 2.91263
8904 } /* table_scan */
8905 } /* range_analysis */
8906 }
8907 ] /* steps */
8908 } 0 0
8909 select sum(data) into ret from t1 {
8910 "steps": [
8911 {
8912 "join_optimization": {
8913 "select#": 1,
8914 "steps": [
8915 {
8916 "table_dependencies": [
8917 {
8918 "table": "`t1`",
8919 "row_may_be_null": false,
8920 "map_bit": 0,
8921 "depends_on_map_bits": [
8922 ] /* depends_on_map_bits */
8923 }
8924 ] /* table_dependencies */
8925 },
8926 {
8927 "rows_estimation": [
8928 {
8929 "table": "`t1`",
8930 "table_scan": {
8931 "rows": 2,
8932 "cost": 0.512634
8933 } /* table_scan */
8934 }
8935 ] /* rows_estimation */
8936 },
8937 {
8938 "considered_execution_plans": [
8939 {
8940 "plan_prefix": [
8941 ] /* plan_prefix */,
8942 "table": "`t1`",
8943 "best_access_path": {
8944 "considered_access_paths": [
8945 {
8946 "rows_to_scan": 2,
8947 "access_type": "scan",
8948 "resulting_rows": 2,
8949 "cost": 0.712634,
8950 "chosen": true
8951 }
8952 ] /* considered_access_paths */
8953 } /* best_access_path */,
8954 "condition_filtering_pct": 100,
8955 "rows_for_plan": 2,
8956 "cost_for_plan": 0.712634,
8957 "chosen": true
8958 }
8959 ] /* considered_execution_plans */
8960 },
8961 {
8962 "attaching_conditions_to_tables": {
8963 "original_condition": null,
8964 "attached_conditions_computation": [
8965 ] /* attached_conditions_computation */,
8966 "attached_conditions_summary": [
8967 {
8968 "table": "`t1`",
8969 "attached": null
8970 }
8971 ] /* attached_conditions_summary */
8972 } /* attaching_conditions_to_tables */
8973 },
8974 {
8975 "optimizing_distinct_group_by_order_by": {
8976 } /* optimizing_distinct_group_by_order_by */
8977 },
8978 {
8979 "finalizing_table_conditions": [
8980 ] /* finalizing_table_conditions */
8981 },
8982 {
8983 "refine_plan": [
8984 {
8985 "table": "`t1`"
8986 }
8987 ] /* refine_plan */
8988 },
8989 {
8990 "considering_tmp_tables": [
8991 ] /* considering_tmp_tables */
8992 }
8993 ] /* steps */
8994 } /* join_optimization */
8995 },
8996 {
8997 "join_execution": {
8998 "select#": 1,
8999 "steps": [
9000 ] /* steps */
9001 } /* join_execution */
9002 }
9003 ] /* steps */
9004 } 0 0
9005 freturn 3 ret@0 {
9006 "steps": [
9007 ] /* steps */
9008 } 0 0
9009 set ret@0 NULL {
9010 "steps": [
9011 ] /* steps */
9012 } 0 0
9013 insert into t1 values("z",0) {
9014 "steps": [
9015 ] /* steps */
9016 } 0 0
9017 delete from t1 where id="z" {
9018 "steps": [
9019 {
9020 "substitute_generated_columns": {
9021 } /* substitute_generated_columns */
9022 },
9023 {
9024 "condition_processing": {
9025 "condition": "WHERE",
9026 "original_condition": "(`t1`.`id` = 'z')",
9027 "steps": [
9028 {
9029 "transformation": "equality_propagation",
9030 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9031 },
9032 {
9033 "transformation": "constant_propagation",
9034 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9035 },
9036 {
9037 "transformation": "trivial_condition_removal",
9038 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9039 }
9040 ] /* steps */
9041 } /* condition_processing */
9042 },
9043 {
9044 "table": "`t1`",
9045 "range_analysis": {
9046 "table_scan": {
9047 "rows": 3,
9048 "cost": 2.91263
9049 } /* table_scan */
9050 } /* range_analysis */
9051 }
9052 ] /* steps */
9053 } 0 0
9054 select sum(data) into ret from t1 {
9055 "steps": [
9056 {
9057 "join_optimization": {
9058 "select#": 1,
9059 "steps": [
9060 {
9061 "table_dependencies": [
9062 {
9063 "table": "`t1`",
9064 "row_may_be_null": false,
9065 "map_bit": 0,
9066 "depends_on_map_bits": [
9067 ] /* depends_on_map_bits */
9068 }
9069 ] /* table_dependencies */
9070 },
9071 {
9072 "rows_estimation": [
9073 {
9074 "table": "`t1`",
9075 "table_scan": {
9076 "rows": 2,
9077 "cost": 0.512634
9078 } /* table_scan */
9079 }
9080 ] /* rows_estimation */
9081 },
9082 {
9083 "considered_execution_plans": [
9084 {
9085 "plan_prefix": [
9086 ] /* plan_prefix */,
9087 "table": "`t1`",
9088 "best_access_path": {
9089 "considered_access_paths": [
9090 {
9091 "rows_to_scan": 2,
9092 "access_type": "scan",
9093 "resulting_rows": 2,
9094 "cost": 0.712634,
9095 "chosen": true
9096 }
9097 ] /* considered_access_paths */
9098 } /* best_access_path */,
9099 "condition_filtering_pct": 100,
9100 "rows_for_plan": 2,
9101 "cost_for_plan": 0.712634,
9102 "chosen": true
9103 }
9104 ] /* considered_execution_plans */
9105 },
9106 {
9107 "attaching_conditions_to_tables": {
9108 "original_condition": null,
9109 "attached_conditions_computation": [
9110 ] /* attached_conditions_computation */,
9111 "attached_conditions_summary": [
9112 {
9113 "table": "`t1`",
9114 "attached": null
9115 }
9116 ] /* attached_conditions_summary */
9117 } /* attaching_conditions_to_tables */
9118 },
9119 {
9120 "optimizing_distinct_group_by_order_by": {
9121 } /* optimizing_distinct_group_by_order_by */
9122 },
9123 {
9124 "finalizing_table_conditions": [
9125 ] /* finalizing_table_conditions */
9126 },
9127 {
9128 "refine_plan": [
9129 {
9130 "table": "`t1`"
9131 }
9132 ] /* refine_plan */
9133 },
9134 {
9135 "considering_tmp_tables": [
9136 ] /* considering_tmp_tables */
9137 }
9138 ] /* steps */
9139 } /* join_optimization */
9140 },
9141 {
9142 "join_execution": {
9143 "select#": 1,
9144 "steps": [
9145 ] /* steps */
9146 } /* join_execution */
9147 }
9148 ] /* steps */
9149 } 0 0
9150 freturn 3 ret@0 {
9151 "steps": [
9152 ] /* steps */
9153 } 0 0
9154 select count(*) from information_schema.OPTIMIZER_TRACE|
9155 count(*)
9156 21
9157 set optimizer_trace_offset=3, optimizer_trace_limit=1|
9158 select * from t6 where d in (select f1() from t2 where s="c")|
9159 d
9160 select * from information_schema.OPTIMIZER_TRACE|
9161 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
9162 delete from t1 where id="z" {
9163 "steps": [
9164 {
9165 "substitute_generated_columns": {
9166 } /* substitute_generated_columns */
9167 },
9168 {
9169 "condition_processing": {
9170 "condition": "WHERE",
9171 "original_condition": "(`t1`.`id` = 'z')",
9172 "steps": [
9173 {
9174 "transformation": "equality_propagation",
9175 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9176 },
9177 {
9178 "transformation": "constant_propagation",
9179 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9180 },
9181 {
9182 "transformation": "trivial_condition_removal",
9183 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9184 }
9185 ] /* steps */
9186 } /* condition_processing */
9187 },
9188 {
9189 "table": "`t1`",
9190 "range_analysis": {
9191 "table_scan": {
9192 "rows": 3,
9193 "cost": 2.91263
9194 } /* table_scan */
9195 } /* range_analysis */
9196 }
9197 ] /* steps */
9198 } 0 0
9199 set @@optimizer_switch=@old_opt_switch;
9200 # Stored procedures
9201 create procedure p1(arg char(1) charset utf8mb4)
9202 begin
9203 declare res int;
9204 select d into res from t6 where d in (select f1() from t2 where s=arg);
9205 select d+1 into res from t6 where d=res+1;
9206 end|
9207 set @old_opt_switch=@@optimizer_switch;
9208 # Test was created when sj-mat-scan could not handle this query...
9209 set optimizer_switch="materialization=off";
9210 set optimizer_trace_offset=0, optimizer_trace_limit=100;
9211 call p1("c")|
9212 Warnings:
9213 Warning 1329 No data - zero rows fetched, selected, or processed
9214 select * from information_schema.OPTIMIZER_TRACE|
9215 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
9216 call p1("c") {
9217 "steps": [
9218 ] /* steps */
9219 } 0 0
9220 set res@1 NULL {
9221 "steps": [
9222 ] /* steps */
9223 } 0 0
9224 select d into res from t6 where d in (select f1() from t2 where s=arg) {
9225 "steps": [
9226 {
9227 "join_preparation": {
9228 "select#": 1,
9229 "steps": [
9230 {
9231 "join_preparation": {
9232 "select#": 2,
9233 "steps": [
9234 {
9235 "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0)"
9236 }
9237 ] /* steps */
9238 } /* join_preparation */
9239 },
9240 {
9241 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where `t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0))"
9242 },
9243 {
9244 "transformation": {
9245 "select#": 2,
9246 "from": "IN (SELECT)",
9247 "to": "semijoin",
9248 "chosen": true,
9249 "transformation_to_semi_join": {
9250 "subquery_predicate": "`t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0))",
9251 "embedded in": "WHERE",
9252 "evaluating_constant_semijoin_conditions": [
9253 ] /* evaluating_constant_semijoin_conditions */,
9254 "semi-join condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
9255 "decorrelated_predicates": [
9256 {
9257 "outer": "`t6`.`d`",
9258 "inner": "`f1`()"
9259 }
9260 ] /* decorrelated_predicates */
9261 } /* transformation_to_semi_join */
9262 } /* transformation */
9263 },
9264 {
9265 "transformations_to_nested_joins": {
9266 "transformations": [
9267 "semijoin"
9268 ] /* transformations */,
9269 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` semi join (`t2`) where ((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
9270 } /* transformations_to_nested_joins */
9271 }
9272 ] /* steps */
9273 } /* join_preparation */
9274 },
9275 {
9276 "join_optimization": {
9277 "select#": 1,
9278 "steps": [
9279 {
9280 "condition_processing": {
9281 "condition": "WHERE",
9282 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
9283 "steps": [
9284 {
9285 "transformation": "equality_propagation",
9286 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
9287 },
9288 {
9289 "transformation": "constant_propagation",
9290 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
9291 },
9292 {
9293 "transformation": "trivial_condition_removal",
9294 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
9295 }
9296 ] /* steps */
9297 } /* condition_processing */
9298 },
9299 {
9300 "substitute_generated_columns": {
9301 } /* substitute_generated_columns */
9302 },
9303 {
9304 "table_dependencies": [
9305 {
9306 "table": "`t6`",
9307 "row_may_be_null": false,
9308 "map_bit": 0,
9309 "depends_on_map_bits": [
9310 ] /* depends_on_map_bits */
9311 },
9312 {
9313 "table": "`t2`",
9314 "row_may_be_null": false,
9315 "map_bit": 1,
9316 "depends_on_map_bits": [
9317 ] /* depends_on_map_bits */
9318 }
9319 ] /* table_dependencies */
9320 },
9321 {
9322 "ref_optimizer_key_uses": [
9323 ] /* ref_optimizer_key_uses */
9324 },
9325 {
9326 "pulled_out_semijoin_tables": [
9327 ] /* pulled_out_semijoin_tables */
9328 },
9329 {
9330 "rows_estimation": [
9331 {
9332 "table": "`t6`",
9333 "table_scan": {
9334 "rows": 4,
9335 "cost": 0.501709
9336 } /* table_scan */
9337 },
9338 {
9339 "table": "`t2`",
9340 "table_scan": {
9341 "rows": 4,
9342 "cost": 0.518799
9343 } /* table_scan */
9344 }
9345 ] /* rows_estimation */
9346 },
9347 {
9348 "considered_execution_plans": [
9349 {
9350 "plan_prefix": [
9351 ] /* plan_prefix */,
9352 "table": "`t6`",
9353 "best_access_path": {
9354 "considered_access_paths": [
9355 {
9356 "rows_to_scan": 4,
9357 "filtering_effect": [
9358 ] /* filtering_effect */,
9359 "final_filtering_effect": 1,
9360 "access_type": "scan",
9361 "resulting_rows": 4,
9362 "cost": 0.901709,
9363 "chosen": true
9364 }
9365 ] /* considered_access_paths */
9366 } /* best_access_path */,
9367 "condition_filtering_pct": 25,
9368 "rows_for_plan": 1,
9369 "cost_for_plan": 0.901709,
9370 "semijoin_strategy_choice": [
9371 ] /* semijoin_strategy_choice */,
9372 "rest_of_plan": [
9373 {
9374 "plan_prefix": [
9375 "`t6`"
9376 ] /* plan_prefix */,
9377 "table": "`t2`",
9378 "best_access_path": {
9379 "considered_access_paths": [
9380 {
9381 "rows_to_scan": 4,
9382 "filtering_effect": [
9383 ] /* filtering_effect */,
9384 "final_filtering_effect": 0.25,
9385 "access_type": "scan",
9386 "using_join_cache": true,
9387 "buffers_needed": 1,
9388 "resulting_rows": 1,
9389 "cost": 0.918814,
9390 "chosen": true
9391 }
9392 ] /* considered_access_paths */
9393 } /* best_access_path */,
9394 "condition_filtering_pct": 100,
9395 "rows_for_plan": 1,
9396 "cost_for_plan": 1.82052,
9397 "semijoin_strategy_choice": [
9398 {
9399 "strategy": "FirstMatch",
9400 "recalculate_access_paths_and_cost": {
9401 "tables": [
9402 {
9403 "table": "`t2`",
9404 "best_access_path": {
9405 "considered_access_paths": [
9406 {
9407 "rows_to_scan": 4,
9408 "filtering_effect": [
9409 ] /* filtering_effect */,
9410 "final_filtering_effect": 0.25,
9411 "access_type": "scan",
9412 "using_join_cache": true,
9413 "buffers_needed": 1,
9414 "resulting_rows": 1,
9415 "cost": 0.918814,
9416 "chosen": true
9417 }
9418 ] /* considered_access_paths */
9419 } /* best_access_path */
9420 }
9421 ] /* tables */
9422 } /* recalculate_access_paths_and_cost */,
9423 "cost": 1.82052,
9424 "rows": 1,
9425 "chosen": true
9426 },
9427 {
9428 "strategy": "DuplicatesWeedout",
9429 "cost": 3.02052,
9430 "rows": 1,
9431 "duplicate_tables_left": false,
9432 "chosen": false
9433 }
9434 ] /* semijoin_strategy_choice */,
9435 "chosen": true
9436 }
9437 ] /* rest_of_plan */
9438 },
9439 {
9440 "plan_prefix": [
9441 ] /* plan_prefix */,
9442 "table": "`t2`",
9443 "best_access_path": {
9444 "considered_access_paths": [
9445 {
9446 "rows_to_scan": 4,
9447 "filtering_effect": [
9448 ] /* filtering_effect */,
9449 "final_filtering_effect": 0.25,
9450 "access_type": "scan",
9451 "resulting_rows": 1,
9452 "cost": 0.918799,
9453 "chosen": true
9454 }
9455 ] /* considered_access_paths */
9456 } /* best_access_path */,
9457 "condition_filtering_pct": 100,
9458 "rows_for_plan": 1,
9459 "cost_for_plan": 0.918799,
9460 "semijoin_strategy_choice": [
9461 ] /* semijoin_strategy_choice */,
9462 "pruned_by_heuristic": true
9463 },
9464 {
9465 "final_semijoin_strategy": "FirstMatch",
9466 "recalculate_access_paths_and_cost": {
9467 "tables": [
9468 {
9469 "table": "`t2`",
9470 "best_access_path": {
9471 "considered_access_paths": [
9472 {
9473 "rows_to_scan": 4,
9474 "filtering_effect": [
9475 ] /* filtering_effect */,
9476 "final_filtering_effect": 0.25,
9477 "access_type": "scan",
9478 "using_join_cache": true,
9479 "buffers_needed": 1,
9480 "resulting_rows": 1,
9481 "cost": 0.918814,
9482 "chosen": true
9483 }
9484 ] /* considered_access_paths */
9485 } /* best_access_path */
9486 }
9487 ] /* tables */
9488 } /* recalculate_access_paths_and_cost */
9489 }
9490 ] /* considered_execution_plans */
9491 },
9492 {
9493 "attaching_conditions_to_tables": {
9494 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
9495 "attached_conditions_computation": [
9496 ] /* attached_conditions_computation */,
9497 "attached_conditions_summary": [
9498 {
9499 "table": "`t6`",
9500 "attached": null
9501 },
9502 {
9503 "table": "`t2`",
9504 "attached": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
9505 }
9506 ] /* attached_conditions_summary */
9507 } /* attaching_conditions_to_tables */
9508 },
9509 {
9510 "finalizing_table_conditions": [
9511 {
9512 "table": "`t2`",
9513 "original_table_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
9514 "final_table_condition ": "((`t2`.`s` = <cache>(arg@0)) and (`t6`.`d` = `f1`()))"
9515 }
9516 ] /* finalizing_table_conditions */
9517 },
9518 {
9519 "refine_plan": [
9520 {
9521 "table": "`t6`"
9522 },
9523 {
9524 "table": "`t2`"
9525 }
9526 ] /* refine_plan */
9527 }
9528 ] /* steps */
9529 } /* join_optimization */
9530 },
9531 {
9532 "join_execution": {
9533 "select#": 1,
9534 "steps": [
9535 ] /* steps */
9536 } /* join_execution */
9537 }
9538 ] /* steps */
9539 } 0 0
9540 set ret@0 NULL {
9541 "steps": [
9542 ] /* steps */
9543 } 0 0
9544 insert into t1 values("z",0) {
9545 "steps": [
9546 ] /* steps */
9547 } 0 0
9548 delete from t1 where id="z" {
9549 "steps": [
9550 {
9551 "delete_preparation": {
9552 "select#": 1,
9553 "steps": [
9554 "delete from `t1` where (`t1`.`id` = 'z')"
9555 ] /* steps */
9556 } /* delete_preparation */
9557 },
9558 {
9559 "substitute_generated_columns": {
9560 } /* substitute_generated_columns */
9561 },
9562 {
9563 "condition_processing": {
9564 "condition": "WHERE",
9565 "original_condition": "(`t1`.`id` = 'z')",
9566 "steps": [
9567 {
9568 "transformation": "equality_propagation",
9569 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9570 },
9571 {
9572 "transformation": "constant_propagation",
9573 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9574 },
9575 {
9576 "transformation": "trivial_condition_removal",
9577 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9578 }
9579 ] /* steps */
9580 } /* condition_processing */
9581 },
9582 {
9583 "table": "`t1`",
9584 "range_analysis": {
9585 "table_scan": {
9586 "rows": 3,
9587 "cost": 2.91263
9588 } /* table_scan */
9589 } /* range_analysis */
9590 }
9591 ] /* steps */
9592 } 0 0
9593 select sum(data) into ret from t1 {
9594 "steps": [
9595 {
9596 "join_preparation": {
9597 "select#": 1,
9598 "steps": [
9599 {
9600 "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9601 }
9602 ] /* steps */
9603 } /* join_preparation */
9604 },
9605 {
9606 "join_optimization": {
9607 "select#": 1,
9608 "steps": [
9609 {
9610 "table_dependencies": [
9611 {
9612 "table": "`t1`",
9613 "row_may_be_null": false,
9614 "map_bit": 0,
9615 "depends_on_map_bits": [
9616 ] /* depends_on_map_bits */
9617 }
9618 ] /* table_dependencies */
9619 },
9620 {
9621 "rows_estimation": [
9622 {
9623 "table": "`t1`",
9624 "table_scan": {
9625 "rows": 2,
9626 "cost": 0.512634
9627 } /* table_scan */
9628 }
9629 ] /* rows_estimation */
9630 },
9631 {
9632 "considered_execution_plans": [
9633 {
9634 "plan_prefix": [
9635 ] /* plan_prefix */,
9636 "table": "`t1`",
9637 "best_access_path": {
9638 "considered_access_paths": [
9639 {
9640 "rows_to_scan": 2,
9641 "access_type": "scan",
9642 "resulting_rows": 2,
9643 "cost": 0.712634,
9644 "chosen": true
9645 }
9646 ] /* considered_access_paths */
9647 } /* best_access_path */,
9648 "condition_filtering_pct": 100,
9649 "rows_for_plan": 2,
9650 "cost_for_plan": 0.712634,
9651 "chosen": true
9652 }
9653 ] /* considered_execution_plans */
9654 },
9655 {
9656 "attaching_conditions_to_tables": {
9657 "original_condition": null,
9658 "attached_conditions_computation": [
9659 ] /* attached_conditions_computation */,
9660 "attached_conditions_summary": [
9661 {
9662 "table": "`t1`",
9663 "attached": null
9664 }
9665 ] /* attached_conditions_summary */
9666 } /* attaching_conditions_to_tables */
9667 },
9668 {
9669 "optimizing_distinct_group_by_order_by": {
9670 } /* optimizing_distinct_group_by_order_by */
9671 },
9672 {
9673 "finalizing_table_conditions": [
9674 ] /* finalizing_table_conditions */
9675 },
9676 {
9677 "refine_plan": [
9678 {
9679 "table": "`t1`"
9680 }
9681 ] /* refine_plan */
9682 },
9683 {
9684 "considering_tmp_tables": [
9685 ] /* considering_tmp_tables */
9686 }
9687 ] /* steps */
9688 } /* join_optimization */
9689 },
9690 {
9691 "join_execution": {
9692 "select#": 1,
9693 "steps": [
9694 ] /* steps */
9695 } /* join_execution */
9696 }
9697 ] /* steps */
9698 } 0 0
9699 freturn 3 ret@0 {
9700 "steps": [
9701 ] /* steps */
9702 } 0 0
9703 set ret@0 NULL {
9704 "steps": [
9705 ] /* steps */
9706 } 0 0
9707 insert into t1 values("z",0) {
9708 "steps": [
9709 ] /* steps */
9710 } 0 0
9711 delete from t1 where id="z" {
9712 "steps": [
9713 {
9714 "substitute_generated_columns": {
9715 } /* substitute_generated_columns */
9716 },
9717 {
9718 "condition_processing": {
9719 "condition": "WHERE",
9720 "original_condition": "(`t1`.`id` = 'z')",
9721 "steps": [
9722 {
9723 "transformation": "equality_propagation",
9724 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9725 },
9726 {
9727 "transformation": "constant_propagation",
9728 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9729 },
9730 {
9731 "transformation": "trivial_condition_removal",
9732 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9733 }
9734 ] /* steps */
9735 } /* condition_processing */
9736 },
9737 {
9738 "table": "`t1`",
9739 "range_analysis": {
9740 "table_scan": {
9741 "rows": 3,
9742 "cost": 2.91263
9743 } /* table_scan */
9744 } /* range_analysis */
9745 }
9746 ] /* steps */
9747 } 0 0
9748 select sum(data) into ret from t1 {
9749 "steps": [
9750 {
9751 "join_optimization": {
9752 "select#": 1,
9753 "steps": [
9754 {
9755 "table_dependencies": [
9756 {
9757 "table": "`t1`",
9758 "row_may_be_null": false,
9759 "map_bit": 0,
9760 "depends_on_map_bits": [
9761 ] /* depends_on_map_bits */
9762 }
9763 ] /* table_dependencies */
9764 },
9765 {
9766 "rows_estimation": [
9767 {
9768 "table": "`t1`",
9769 "table_scan": {
9770 "rows": 2,
9771 "cost": 0.512634
9772 } /* table_scan */
9773 }
9774 ] /* rows_estimation */
9775 },
9776 {
9777 "considered_execution_plans": [
9778 {
9779 "plan_prefix": [
9780 ] /* plan_prefix */,
9781 "table": "`t1`",
9782 "best_access_path": {
9783 "considered_access_paths": [
9784 {
9785 "rows_to_scan": 2,
9786 "access_type": "scan",
9787 "resulting_rows": 2,
9788 "cost": 0.712634,
9789 "chosen": true
9790 }
9791 ] /* considered_access_paths */
9792 } /* best_access_path */,
9793 "condition_filtering_pct": 100,
9794 "rows_for_plan": 2,
9795 "cost_for_plan": 0.712634,
9796 "chosen": true
9797 }
9798 ] /* considered_execution_plans */
9799 },
9800 {
9801 "attaching_conditions_to_tables": {
9802 "original_condition": null,
9803 "attached_conditions_computation": [
9804 ] /* attached_conditions_computation */,
9805 "attached_conditions_summary": [
9806 {
9807 "table": "`t1`",
9808 "attached": null
9809 }
9810 ] /* attached_conditions_summary */
9811 } /* attaching_conditions_to_tables */
9812 },
9813 {
9814 "optimizing_distinct_group_by_order_by": {
9815 } /* optimizing_distinct_group_by_order_by */
9816 },
9817 {
9818 "finalizing_table_conditions": [
9819 ] /* finalizing_table_conditions */
9820 },
9821 {
9822 "refine_plan": [
9823 {
9824 "table": "`t1`"
9825 }
9826 ] /* refine_plan */
9827 },
9828 {
9829 "considering_tmp_tables": [
9830 ] /* considering_tmp_tables */
9831 }
9832 ] /* steps */
9833 } /* join_optimization */
9834 },
9835 {
9836 "join_execution": {
9837 "select#": 1,
9838 "steps": [
9839 ] /* steps */
9840 } /* join_execution */
9841 }
9842 ] /* steps */
9843 } 0 0
9844 freturn 3 ret@0 {
9845 "steps": [
9846 ] /* steps */
9847 } 0 0
9848 set ret@0 NULL {
9849 "steps": [
9850 ] /* steps */
9851 } 0 0
9852 insert into t1 values("z",0) {
9853 "steps": [
9854 ] /* steps */
9855 } 0 0
9856 delete from t1 where id="z" {
9857 "steps": [
9858 {
9859 "substitute_generated_columns": {
9860 } /* substitute_generated_columns */
9861 },
9862 {
9863 "condition_processing": {
9864 "condition": "WHERE",
9865 "original_condition": "(`t1`.`id` = 'z')",
9866 "steps": [
9867 {
9868 "transformation": "equality_propagation",
9869 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9870 },
9871 {
9872 "transformation": "constant_propagation",
9873 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9874 },
9875 {
9876 "transformation": "trivial_condition_removal",
9877 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9878 }
9879 ] /* steps */
9880 } /* condition_processing */
9881 },
9882 {
9883 "table": "`t1`",
9884 "range_analysis": {
9885 "table_scan": {
9886 "rows": 3,
9887 "cost": 2.91263
9888 } /* table_scan */
9889 } /* range_analysis */
9890 }
9891 ] /* steps */
9892 } 0 0
9893 select sum(data) into ret from t1 {
9894 "steps": [
9895 {
9896 "join_optimization": {
9897 "select#": 1,
9898 "steps": [
9899 {
9900 "table_dependencies": [
9901 {
9902 "table": "`t1`",
9903 "row_may_be_null": false,
9904 "map_bit": 0,
9905 "depends_on_map_bits": [
9906 ] /* depends_on_map_bits */
9907 }
9908 ] /* table_dependencies */
9909 },
9910 {
9911 "rows_estimation": [
9912 {
9913 "table": "`t1`",
9914 "table_scan": {
9915 "rows": 2,
9916 "cost": 0.512634
9917 } /* table_scan */
9918 }
9919 ] /* rows_estimation */
9920 },
9921 {
9922 "considered_execution_plans": [
9923 {
9924 "plan_prefix": [
9925 ] /* plan_prefix */,
9926 "table": "`t1`",
9927 "best_access_path": {
9928 "considered_access_paths": [
9929 {
9930 "rows_to_scan": 2,
9931 "access_type": "scan",
9932 "resulting_rows": 2,
9933 "cost": 0.712634,
9934 "chosen": true
9935 }
9936 ] /* considered_access_paths */
9937 } /* best_access_path */,
9938 "condition_filtering_pct": 100,
9939 "rows_for_plan": 2,
9940 "cost_for_plan": 0.712634,
9941 "chosen": true
9942 }
9943 ] /* considered_execution_plans */
9944 },
9945 {
9946 "attaching_conditions_to_tables": {
9947 "original_condition": null,
9948 "attached_conditions_computation": [
9949 ] /* attached_conditions_computation */,
9950 "attached_conditions_summary": [
9951 {
9952 "table": "`t1`",
9953 "attached": null
9954 }
9955 ] /* attached_conditions_summary */
9956 } /* attaching_conditions_to_tables */
9957 },
9958 {
9959 "optimizing_distinct_group_by_order_by": {
9960 } /* optimizing_distinct_group_by_order_by */
9961 },
9962 {
9963 "finalizing_table_conditions": [
9964 ] /* finalizing_table_conditions */
9965 },
9966 {
9967 "refine_plan": [
9968 {
9969 "table": "`t1`"
9970 }
9971 ] /* refine_plan */
9972 },
9973 {
9974 "considering_tmp_tables": [
9975 ] /* considering_tmp_tables */
9976 }
9977 ] /* steps */
9978 } /* join_optimization */
9979 },
9980 {
9981 "join_execution": {
9982 "select#": 1,
9983 "steps": [
9984 ] /* steps */
9985 } /* join_execution */
9986 }
9987 ] /* steps */
9988 } 0 0
9989 freturn 3 ret@0 {
9990 "steps": [
9991 ] /* steps */
9992 } 0 0
9993 set ret@0 NULL {
9994 "steps": [
9995 ] /* steps */
9996 } 0 0
9997 insert into t1 values("z",0) {
9998 "steps": [
9999 ] /* steps */
10000 } 0 0
10001 delete from t1 where id="z" {
10002 "steps": [
10003 {
10004 "substitute_generated_columns": {
10005 } /* substitute_generated_columns */
10006 },
10007 {
10008 "condition_processing": {
10009 "condition": "WHERE",
10010 "original_condition": "(`t1`.`id` = 'z')",
10011 "steps": [
10012 {
10013 "transformation": "equality_propagation",
10014 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10015 },
10016 {
10017 "transformation": "constant_propagation",
10018 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10019 },
10020 {
10021 "transformation": "trivial_condition_removal",
10022 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10023 }
10024 ] /* steps */
10025 } /* condition_processing */
10026 },
10027 {
10028 "table": "`t1`",
10029 "range_analysis": {
10030 "table_scan": {
10031 "rows": 3,
10032 "cost": 2.91263
10033 } /* table_scan */
10034 } /* range_analysis */
10035 }
10036 ] /* steps */
10037 } 0 0
10038 select sum(data) into ret from t1 {
10039 "steps": [
10040 {
10041 "join_optimization": {
10042 "select#": 1,
10043 "steps": [
10044 {
10045 "table_dependencies": [
10046 {
10047 "table": "`t1`",
10048 "row_may_be_null": false,
10049 "map_bit": 0,
10050 "depends_on_map_bits": [
10051 ] /* depends_on_map_bits */
10052 }
10053 ] /* table_dependencies */
10054 },
10055 {
10056 "rows_estimation": [
10057 {
10058 "table": "`t1`",
10059 "table_scan": {
10060 "rows": 2,
10061 "cost": 0.512634
10062 } /* table_scan */
10063 }
10064 ] /* rows_estimation */
10065 },
10066 {
10067 "considered_execution_plans": [
10068 {
10069 "plan_prefix": [
10070 ] /* plan_prefix */,
10071 "table": "`t1`",
10072 "best_access_path": {
10073 "considered_access_paths": [
10074 {
10075 "rows_to_scan": 2,
10076 "access_type": "scan",
10077 "resulting_rows": 2,
10078 "cost": 0.712634,
10079 "chosen": true
10080 }
10081 ] /* considered_access_paths */
10082 } /* best_access_path */,
10083 "condition_filtering_pct": 100,
10084 "rows_for_plan": 2,
10085 "cost_for_plan": 0.712634,
10086 "chosen": true
10087 }
10088 ] /* considered_execution_plans */
10089 },
10090 {
10091 "attaching_conditions_to_tables": {
10092 "original_condition": null,
10093 "attached_conditions_computation": [
10094 ] /* attached_conditions_computation */,
10095 "attached_conditions_summary": [
10096 {
10097 "table": "`t1`",
10098 "attached": null
10099 }
10100 ] /* attached_conditions_summary */
10101 } /* attaching_conditions_to_tables */
10102 },
10103 {
10104 "optimizing_distinct_group_by_order_by": {
10105 } /* optimizing_distinct_group_by_order_by */
10106 },
10107 {
10108 "finalizing_table_conditions": [
10109 ] /* finalizing_table_conditions */
10110 },
10111 {
10112 "refine_plan": [
10113 {
10114 "table": "`t1`"
10115 }
10116 ] /* refine_plan */
10117 },
10118 {
10119 "considering_tmp_tables": [
10120 ] /* considering_tmp_tables */
10121 }
10122 ] /* steps */
10123 } /* join_optimization */
10124 },
10125 {
10126 "join_execution": {
10127 "select#": 1,
10128 "steps": [
10129 ] /* steps */
10130 } /* join_execution */
10131 }
10132 ] /* steps */
10133 } 0 0
10134 freturn 3 ret@0 {
10135 "steps": [
10136 ] /* steps */
10137 } 0 0
10138 select d+1 into res from t6 where d=res+1 {
10139 "steps": [
10140 {
10141 "join_preparation": {
10142 "select#": 1,
10143 "steps": [
10144 {
10145 "expanded_query": "/* select#1 */ select (`t6`.`d` + 1) AS `d+1` from `t6` where (`t6`.`d` = (res@1 + 1))"
10146 }
10147 ] /* steps */
10148 } /* join_preparation */
10149 },
10150 {
10151 "join_optimization": {
10152 "select#": 1,
10153 "steps": [
10154 {
10155 "condition_processing": {
10156 "condition": "WHERE",
10157 "original_condition": "(`t6`.`d` = (res@1 + 1))",
10158 "steps": [
10159 {
10160 "transformation": "equality_propagation",
10161 "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
10162 },
10163 {
10164 "transformation": "constant_propagation",
10165 "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
10166 },
10167 {
10168 "transformation": "trivial_condition_removal",
10169 "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
10170 }
10171 ] /* steps */
10172 } /* condition_processing */
10173 },
10174 {
10175 "substitute_generated_columns": {
10176 } /* substitute_generated_columns */
10177 },
10178 {
10179 "table_dependencies": [
10180 {
10181 "table": "`t6`",
10182 "row_may_be_null": false,
10183 "map_bit": 0,
10184 "depends_on_map_bits": [
10185 ] /* depends_on_map_bits */
10186 }
10187 ] /* table_dependencies */
10188 },
10189 {
10190 "ref_optimizer_key_uses": [
10191 {
10192 "table": "`t6`",
10193 "field": "d",
10194 "equals": "(res@1 + 1)",
10195 "null_rejecting": true
10196 }
10197 ] /* ref_optimizer_key_uses */
10198 },
10199 {
10200 "rows_estimation": [
10201 {
10202 "table": "`t6`",
10203 "range_analysis": {
10204 "table_scan": {
10205 "rows": 4,
10206 "cost": 3.00171
10207 } /* table_scan */,
10208 "potential_range_indexes": [
10209 {
10210 "index": "d",
10211 "usable": true,
10212 "key_parts": [
10213 "d"
10214 ] /* key_parts */
10215 }
10216 ] /* potential_range_indexes */,
10217 "best_covering_index_scan": {
10218 "index": "d",
10219 "cost": 0.667442,
10220 "chosen": true
10221 } /* best_covering_index_scan */,
10222 "setup_range_conditions": [
10223 {
10224 "impossible_condition": {
10225 "cause": "comparison_with_null_always_false"
10226 } /* impossible_condition */
10227 }
10228 ] /* setup_range_conditions */,
10229 "impossible_range": true
10230 } /* range_analysis */,
10231 "rows": 0,
10232 "cause": "impossible_where_condition"
10233 }
10234 ] /* rows_estimation */
10235 }
10236 ] /* steps */,
10237 "empty_result": {
10238 "cause": "no matching row in const table"
10239 } /* empty_result */
10240 } /* join_optimization */
10241 },
10242 {
10243 "join_execution": {
10244 "select#": 1,
10245 "steps": [
10246 ] /* steps */
10247 } /* join_execution */
10248 }
10249 ] /* steps */
10250 } 0 0
10251 set @@optimizer_switch=@old_opt_switch;
10252 # Triggers
10253 create trigger trg1 before insert on t2 for each row
10254 begin
10255 set new.s=f1();
10256 end|
10257 set optimizer_trace_offset=0, optimizer_trace_limit=100|
10258 insert into t2 select d,100,200 from t6 where d is not null|
10259 select * from information_schema.OPTIMIZER_TRACE|
10260 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
10261 insert into t2 select d,100,200 from t6 where d is not null {
10262 "steps": [
10263 {
10264 "join_preparation": {
10265 "select#": 1,
10266 "steps": [
10267 {
10268 "expanded_query": "insert into `t2` /* select#1 */ select `t6`.`d` AS `d`,100 AS `100`,200 AS `200` from `t6` where (`t6`.`d` is not null)"
10269 }
10270 ] /* steps */
10271 } /* join_preparation */
10272 },
10273 {
10274 "join_optimization": {
10275 "select#": 1,
10276 "steps": [
10277 {
10278 "condition_processing": {
10279 "condition": "WHERE",
10280 "original_condition": "(`t6`.`d` is not null)",
10281 "steps": [
10282 {
10283 "transformation": "equality_propagation",
10284 "resulting_condition": "(`t6`.`d` is not null)"
10285 },
10286 {
10287 "transformation": "constant_propagation",
10288 "resulting_condition": "(`t6`.`d` is not null)"
10289 },
10290 {
10291 "transformation": "trivial_condition_removal",
10292 "resulting_condition": "(`t6`.`d` is not null)"
10293 }
10294 ] /* steps */
10295 } /* condition_processing */
10296 },
10297 {
10298 "substitute_generated_columns": {
10299 } /* substitute_generated_columns */
10300 },
10301 {
10302 "table_dependencies": [
10303 {
10304 "table": "`t6`",
10305 "row_may_be_null": false,
10306 "map_bit": 0,
10307 "depends_on_map_bits": [
10308 ] /* depends_on_map_bits */
10309 }
10310 ] /* table_dependencies */
10311 },
10312 {
10313 "ref_optimizer_key_uses": [
10314 ] /* ref_optimizer_key_uses */
10315 },
10316 {
10317 "rows_estimation": [
10318 {
10319 "table": "`t6`",
10320 "range_analysis": {
10321 "table_scan": {
10322 "rows": 4,
10323 "cost": 3.00171
10324 } /* table_scan */,
10325 "potential_range_indexes": [
10326 {
10327 "index": "d",
10328 "usable": true,
10329 "key_parts": [
10330 "d"
10331 ] /* key_parts */
10332 }
10333 ] /* potential_range_indexes */,
10334 "best_covering_index_scan": {
10335 "index": "d",
10336 "cost": 0.667442,
10337 "chosen": true
10338 } /* best_covering_index_scan */,
10339 "setup_range_conditions": [
10340 ] /* setup_range_conditions */,
10341 "group_index_range": {
10342 "chosen": false,
10343 "cause": "not_group_by_or_distinct"
10344 } /* group_index_range */,
10345 "skip_scan_range": {
10346 "potential_skip_scan_indexes": [
10347 {
10348 "index": "d",
10349 "usable": false,
10350 "cause": "prefix_not_const_equality"
10351 }
10352 ] /* potential_skip_scan_indexes */
10353 } /* skip_scan_range */,
10354 "analyzing_range_alternatives": {
10355 "range_scan_alternatives": [
10356 {
10357 "index": "d",
10358 "ranges": [
10359 "NULL < d"
10360 ] /* ranges */,
10361 "index_dives_for_eq_ranges": true,
10362 "rowid_ordered": false,
10363 "using_mrr": false,
10364 "index_only": true,
10365 "in_memory": -1,
10366 "rows": 4,
10367 "cost": 0.677442,
10368 "chosen": false,
10369 "cause": "cost"
10370 }
10371 ] /* range_scan_alternatives */,
10372 "analyzing_roworder_intersect": {
10373 "usable": false,
10374 "cause": "too_few_roworder_scans"
10375 } /* analyzing_roworder_intersect */
10376 } /* analyzing_range_alternatives */
10377 } /* range_analysis */
10378 }
10379 ] /* rows_estimation */
10380 },
10381 {
10382 "considered_execution_plans": [
10383 {
10384 "plan_prefix": [
10385 ] /* plan_prefix */,
10386 "table": "`t6`",
10387 "best_access_path": {
10388 "considered_access_paths": [
10389 {
10390 "rows_to_scan": 4,
10391 "access_type": "scan",
10392 "resulting_rows": 4,
10393 "cost": 0.901709,
10394 "chosen": true
10395 }
10396 ] /* considered_access_paths */
10397 } /* best_access_path */,
10398 "condition_filtering_pct": 100,
10399 "rows_for_plan": 4,
10400 "cost_for_plan": 0.901709,
10401 "chosen": true
10402 }
10403 ] /* considered_execution_plans */
10404 },
10405 {
10406 "attaching_conditions_to_tables": {
10407 "original_condition": "(`t6`.`d` is not null)",
10408 "attached_conditions_computation": [
10409 ] /* attached_conditions_computation */,
10410 "attached_conditions_summary": [
10411 {
10412 "table": "`t6`",
10413 "attached": "(`t6`.`d` is not null)"
10414 }
10415 ] /* attached_conditions_summary */
10416 } /* attaching_conditions_to_tables */
10417 },
10418 {
10419 "finalizing_table_conditions": [
10420 {
10421 "table": "`t6`",
10422 "original_table_condition": "(`t6`.`d` is not null)",
10423 "final_table_condition ": "(`t6`.`d` is not null)"
10424 }
10425 ] /* finalizing_table_conditions */
10426 },
10427 {
10428 "refine_plan": [
10429 {
10430 "table": "`t6`"
10431 }
10432 ] /* refine_plan */
10433 }
10434 ] /* steps */
10435 } /* join_optimization */
10436 },
10437 {
10438 "join_execution": {
10439 "select#": 1,
10440 "steps": [
10441 ] /* steps */
10442 } /* join_execution */
10443 }
10444 ] /* steps */
10445 } 0 0
10446 set_trigger_field NEW.s:=`f1`() {
10447 "steps": [
10448 ] /* steps */
10449 } 0 0
10450 set ret@0 NULL {
10451 "steps": [
10452 ] /* steps */
10453 } 0 0
10454 insert into t1 values("z",0) {
10455 "steps": [
10456 ] /* steps */
10457 } 0 0
10458 delete from t1 where id="z" {
10459 "steps": [
10460 {
10461 "delete_preparation": {
10462 "select#": 1,
10463 "steps": [
10464 "delete from `t1` where (`t1`.`id` = 'z')"
10465 ] /* steps */
10466 } /* delete_preparation */
10467 },
10468 {
10469 "substitute_generated_columns": {
10470 } /* substitute_generated_columns */
10471 },
10472 {
10473 "condition_processing": {
10474 "condition": "WHERE",
10475 "original_condition": "(`t1`.`id` = 'z')",
10476 "steps": [
10477 {
10478 "transformation": "equality_propagation",
10479 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10480 },
10481 {
10482 "transformation": "constant_propagation",
10483 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10484 },
10485 {
10486 "transformation": "trivial_condition_removal",
10487 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10488 }
10489 ] /* steps */
10490 } /* condition_processing */
10491 },
10492 {
10493 "table": "`t1`",
10494 "range_analysis": {
10495 "table_scan": {
10496 "rows": 3,
10497 "cost": 2.91263
10498 } /* table_scan */
10499 } /* range_analysis */
10500 }
10501 ] /* steps */
10502 } 0 0
10503 select sum(data) into ret from t1 {
10504 "steps": [
10505 {
10506 "join_preparation": {
10507 "select#": 1,
10508 "steps": [
10509 {
10510 "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
10511 }
10512 ] /* steps */
10513 } /* join_preparation */
10514 },
10515 {
10516 "join_optimization": {
10517 "select#": 1,
10518 "steps": [
10519 {
10520 "table_dependencies": [
10521 {
10522 "table": "`t1`",
10523 "row_may_be_null": false,
10524 "map_bit": 0,
10525 "depends_on_map_bits": [
10526 ] /* depends_on_map_bits */
10527 }
10528 ] /* table_dependencies */
10529 },
10530 {
10531 "rows_estimation": [
10532 {
10533 "table": "`t1`",
10534 "table_scan": {
10535 "rows": 2,
10536 "cost": 0.512634
10537 } /* table_scan */
10538 }
10539 ] /* rows_estimation */
10540 },
10541 {
10542 "considered_execution_plans": [
10543 {
10544 "plan_prefix": [
10545 ] /* plan_prefix */,
10546 "table": "`t1`",
10547 "best_access_path": {
10548 "considered_access_paths": [
10549 {
10550 "rows_to_scan": 2,
10551 "access_type": "scan",
10552 "resulting_rows": 2,
10553 "cost": 0.712634,
10554 "chosen": true
10555 }
10556 ] /* considered_access_paths */
10557 } /* best_access_path */,
10558 "condition_filtering_pct": 100,
10559 "rows_for_plan": 2,
10560 "cost_for_plan": 0.712634,
10561 "chosen": true
10562 }
10563 ] /* considered_execution_plans */
10564 },
10565 {
10566 "attaching_conditions_to_tables": {
10567 "original_condition": null,
10568 "attached_conditions_computation": [
10569 ] /* attached_conditions_computation */,
10570 "attached_conditions_summary": [
10571 {
10572 "table": "`t1`",
10573 "attached": null
10574 }
10575 ] /* attached_conditions_summary */
10576 } /* attaching_conditions_to_tables */
10577 },
10578 {
10579 "optimizing_distinct_group_by_order_by": {
10580 } /* optimizing_distinct_group_by_order_by */
10581 },
10582 {
10583 "finalizing_table_conditions": [
10584 ] /* finalizing_table_conditions */
10585 },
10586 {
10587 "refine_plan": [
10588 {
10589 "table": "`t1`"
10590 }
10591 ] /* refine_plan */
10592 },
10593 {
10594 "considering_tmp_tables": [
10595 ] /* considering_tmp_tables */
10596 }
10597 ] /* steps */
10598 } /* join_optimization */
10599 },
10600 {
10601 "join_execution": {
10602 "select#": 1,
10603 "steps": [
10604 ] /* steps */
10605 } /* join_execution */
10606 }
10607 ] /* steps */
10608 } 0 0
10609 freturn 3 ret@0 {
10610 "steps": [
10611 ] /* steps */
10612 } 0 0
10613 set_trigger_field NEW.s:=`f1`() {
10614 "steps": [
10615 ] /* steps */
10616 } 0 0
10617 set ret@0 NULL {
10618 "steps": [
10619 ] /* steps */
10620 } 0 0
10621 insert into t1 values("z",0) {
10622 "steps": [
10623 ] /* steps */
10624 } 0 0
10625 delete from t1 where id="z" {
10626 "steps": [
10627 {
10628 "substitute_generated_columns": {
10629 } /* substitute_generated_columns */
10630 },
10631 {
10632 "condition_processing": {
10633 "condition": "WHERE",
10634 "original_condition": "(`t1`.`id` = 'z')",
10635 "steps": [
10636 {
10637 "transformation": "equality_propagation",
10638 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10639 },
10640 {
10641 "transformation": "constant_propagation",
10642 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10643 },
10644 {
10645 "transformation": "trivial_condition_removal",
10646 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10647 }
10648 ] /* steps */
10649 } /* condition_processing */
10650 },
10651 {
10652 "table": "`t1`",
10653 "range_analysis": {
10654 "table_scan": {
10655 "rows": 3,
10656 "cost": 2.91263
10657 } /* table_scan */
10658 } /* range_analysis */
10659 }
10660 ] /* steps */
10661 } 0 0
10662 select sum(data) into ret from t1 {
10663 "steps": [
10664 {
10665 "join_optimization": {
10666 "select#": 1,
10667 "steps": [
10668 {
10669 "table_dependencies": [
10670 {
10671 "table": "`t1`",
10672 "row_may_be_null": false,
10673 "map_bit": 0,
10674 "depends_on_map_bits": [
10675 ] /* depends_on_map_bits */
10676 }
10677 ] /* table_dependencies */
10678 },
10679 {
10680 "rows_estimation": [
10681 {
10682 "table": "`t1`",
10683 "table_scan": {
10684 "rows": 2,
10685 "cost": 0.512634
10686 } /* table_scan */
10687 }
10688 ] /* rows_estimation */
10689 },
10690 {
10691 "considered_execution_plans": [
10692 {
10693 "plan_prefix": [
10694 ] /* plan_prefix */,
10695 "table": "`t1`",
10696 "best_access_path": {
10697 "considered_access_paths": [
10698 {
10699 "rows_to_scan": 2,
10700 "access_type": "scan",
10701 "resulting_rows": 2,
10702 "cost": 0.712634,
10703 "chosen": true
10704 }
10705 ] /* considered_access_paths */
10706 } /* best_access_path */,
10707 "condition_filtering_pct": 100,
10708 "rows_for_plan": 2,
10709 "cost_for_plan": 0.712634,
10710 "chosen": true
10711 }
10712 ] /* considered_execution_plans */
10713 },
10714 {
10715 "attaching_conditions_to_tables": {
10716 "original_condition": null,
10717 "attached_conditions_computation": [
10718 ] /* attached_conditions_computation */,
10719 "attached_conditions_summary": [
10720 {
10721 "table": "`t1`",
10722 "attached": null
10723 }
10724 ] /* attached_conditions_summary */
10725 } /* attaching_conditions_to_tables */
10726 },
10727 {
10728 "optimizing_distinct_group_by_order_by": {
10729 } /* optimizing_distinct_group_by_order_by */
10730 },
10731 {
10732 "finalizing_table_conditions": [
10733 ] /* finalizing_table_conditions */
10734 },
10735 {
10736 "refine_plan": [
10737 {
10738 "table": "`t1`"
10739 }
10740 ] /* refine_plan */
10741 },
10742 {
10743 "considering_tmp_tables": [
10744 ] /* considering_tmp_tables */
10745 }
10746 ] /* steps */
10747 } /* join_optimization */
10748 },
10749 {
10750 "join_execution": {
10751 "select#": 1,
10752 "steps": [
10753 ] /* steps */
10754 } /* join_execution */
10755 }
10756 ] /* steps */
10757 } 0 0
10758 freturn 3 ret@0 {
10759 "steps": [
10760 ] /* steps */
10761 } 0 0
10762 set_trigger_field NEW.s:=`f1`() {
10763 "steps": [
10764 ] /* steps */
10765 } 0 0
10766 set ret@0 NULL {
10767 "steps": [
10768 ] /* steps */
10769 } 0 0
10770 insert into t1 values("z",0) {
10771 "steps": [
10772 ] /* steps */
10773 } 0 0
10774 delete from t1 where id="z" {
10775 "steps": [
10776 {
10777 "substitute_generated_columns": {
10778 } /* substitute_generated_columns */
10779 },
10780 {
10781 "condition_processing": {
10782 "condition": "WHERE",
10783 "original_condition": "(`t1`.`id` = 'z')",
10784 "steps": [
10785 {
10786 "transformation": "equality_propagation",
10787 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10788 },
10789 {
10790 "transformation": "constant_propagation",
10791 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10792 },
10793 {
10794 "transformation": "trivial_condition_removal",
10795 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10796 }
10797 ] /* steps */
10798 } /* condition_processing */
10799 },
10800 {
10801 "table": "`t1`",
10802 "range_analysis": {
10803 "table_scan": {
10804 "rows": 3,
10805 "cost": 2.91263
10806 } /* table_scan */
10807 } /* range_analysis */
10808 }
10809 ] /* steps */
10810 } 0 0
10811 select sum(data) into ret from t1 {
10812 "steps": [
10813 {
10814 "join_optimization": {
10815 "select#": 1,
10816 "steps": [
10817 {
10818 "table_dependencies": [
10819 {
10820 "table": "`t1`",
10821 "row_may_be_null": false,
10822 "map_bit": 0,
10823 "depends_on_map_bits": [
10824 ] /* depends_on_map_bits */
10825 }
10826 ] /* table_dependencies */
10827 },
10828 {
10829 "rows_estimation": [
10830 {
10831 "table": "`t1`",
10832 "table_scan": {
10833 "rows": 2,
10834 "cost": 0.512634
10835 } /* table_scan */
10836 }
10837 ] /* rows_estimation */
10838 },
10839 {
10840 "considered_execution_plans": [
10841 {
10842 "plan_prefix": [
10843 ] /* plan_prefix */,
10844 "table": "`t1`",
10845 "best_access_path": {
10846 "considered_access_paths": [
10847 {
10848 "rows_to_scan": 2,
10849 "access_type": "scan",
10850 "resulting_rows": 2,
10851 "cost": 0.712634,
10852 "chosen": true
10853 }
10854 ] /* considered_access_paths */
10855 } /* best_access_path */,
10856 "condition_filtering_pct": 100,
10857 "rows_for_plan": 2,
10858 "cost_for_plan": 0.712634,
10859 "chosen": true
10860 }
10861 ] /* considered_execution_plans */
10862 },
10863 {
10864 "attaching_conditions_to_tables": {
10865 "original_condition": null,
10866 "attached_conditions_computation": [
10867 ] /* attached_conditions_computation */,
10868 "attached_conditions_summary": [
10869 {
10870 "table": "`t1`",
10871 "attached": null
10872 }
10873 ] /* attached_conditions_summary */
10874 } /* attaching_conditions_to_tables */
10875 },
10876 {
10877 "optimizing_distinct_group_by_order_by": {
10878 } /* optimizing_distinct_group_by_order_by */
10879 },
10880 {
10881 "finalizing_table_conditions": [
10882 ] /* finalizing_table_conditions */
10883 },
10884 {
10885 "refine_plan": [
10886 {
10887 "table": "`t1`"
10888 }
10889 ] /* refine_plan */
10890 },
10891 {
10892 "considering_tmp_tables": [
10893 ] /* considering_tmp_tables */
10894 }
10895 ] /* steps */
10896 } /* join_optimization */
10897 },
10898 {
10899 "join_execution": {
10900 "select#": 1,
10901 "steps": [
10902 ] /* steps */
10903 } /* join_execution */
10904 }
10905 ] /* steps */
10906 } 0 0
10907 freturn 3 ret@0 {
10908 "steps": [
10909 ] /* steps */
10910 } 0 0
10911 set_trigger_field NEW.s:=`f1`() {
10912 "steps": [
10913 ] /* steps */
10914 } 0 0
10915 set ret@0 NULL {
10916 "steps": [
10917 ] /* steps */
10918 } 0 0
10919 insert into t1 values("z",0) {
10920 "steps": [
10921 ] /* steps */
10922 } 0 0
10923 delete from t1 where id="z" {
10924 "steps": [
10925 {
10926 "substitute_generated_columns": {
10927 } /* substitute_generated_columns */
10928 },
10929 {
10930 "condition_processing": {
10931 "condition": "WHERE",
10932 "original_condition": "(`t1`.`id` = 'z')",
10933 "steps": [
10934 {
10935 "transformation": "equality_propagation",
10936 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10937 },
10938 {
10939 "transformation": "constant_propagation",
10940 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10941 },
10942 {
10943 "transformation": "trivial_condition_removal",
10944 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10945 }
10946 ] /* steps */
10947 } /* condition_processing */
10948 },
10949 {
10950 "table": "`t1`",
10951 "range_analysis": {
10952 "table_scan": {
10953 "rows": 3,
10954 "cost": 2.91263
10955 } /* table_scan */
10956 } /* range_analysis */
10957 }
10958 ] /* steps */
10959 } 0 0
10960 select sum(data) into ret from t1 {
10961 "steps": [
10962 {
10963 "join_optimization": {
10964 "select#": 1,
10965 "steps": [
10966 {
10967 "table_dependencies": [
10968 {
10969 "table": "`t1`",
10970 "row_may_be_null": false,
10971 "map_bit": 0,
10972 "depends_on_map_bits": [
10973 ] /* depends_on_map_bits */
10974 }
10975 ] /* table_dependencies */
10976 },
10977 {
10978 "rows_estimation": [
10979 {
10980 "table": "`t1`",
10981 "table_scan": {
10982 "rows": 2,
10983 "cost": 0.512634
10984 } /* table_scan */
10985 }
10986 ] /* rows_estimation */
10987 },
10988 {
10989 "considered_execution_plans": [
10990 {
10991 "plan_prefix": [
10992 ] /* plan_prefix */,
10993 "table": "`t1`",
10994 "best_access_path": {
10995 "considered_access_paths": [
10996 {
10997 "rows_to_scan": 2,
10998 "access_type": "scan",
10999 "resulting_rows": 2,
11000 "cost": 0.712634,
11001 "chosen": true
11002 }
11003 ] /* considered_access_paths */
11004 } /* best_access_path */,
11005 "condition_filtering_pct": 100,
11006 "rows_for_plan": 2,
11007 "cost_for_plan": 0.712634,
11008 "chosen": true
11009 }
11010 ] /* considered_execution_plans */
11011 },
11012 {
11013 "attaching_conditions_to_tables": {
11014 "original_condition": null,
11015 "attached_conditions_computation": [
11016 ] /* attached_conditions_computation */,
11017 "attached_conditions_summary": [
11018 {
11019 "table": "`t1`",
11020 "attached": null
11021 }
11022 ] /* attached_conditions_summary */
11023 } /* attaching_conditions_to_tables */
11024 },
11025 {
11026 "optimizing_distinct_group_by_order_by": {
11027 } /* optimizing_distinct_group_by_order_by */
11028 },
11029 {
11030 "finalizing_table_conditions": [
11031 ] /* finalizing_table_conditions */
11032 },
11033 {
11034 "refine_plan": [
11035 {
11036 "table": "`t1`"
11037 }
11038 ] /* refine_plan */
11039 },
11040 {
11041 "considering_tmp_tables": [
11042 ] /* considering_tmp_tables */
11043 }
11044 ] /* steps */
11045 } /* join_optimization */
11046 },
11047 {
11048 "join_execution": {
11049 "select#": 1,
11050 "steps": [
11051 ] /* steps */
11052 } /* join_execution */
11053 }
11054 ] /* steps */
11055 } 0 0
11056 freturn 3 ret@0 {
11057 "steps": [
11058 ] /* steps */
11059 } 0 0
11060 select * from t2|
11061 s i d
11062 a 1 1
11063 b 2 2
11064 c 3 3
11065 d 4 4
11066 3 100 200
11067 3 100 200
11068 3 100 200
11069 3 100 200
11070 prepare stmt from 'select count(*) from t1 where t1.data=?';
11071 set @param="c";
11072 set optimizer_trace_offset=0, optimizer_trace_limit=100;
11073 execute stmt using @param;
11074 count(*)
11075 0
11076 Warnings:
11077 Warning 1292 Truncated incorrect INTEGER value: 'c'
11078 Warning 1292 Truncated incorrect INTEGER value: 'c'
11079 Warning 1292 Truncated incorrect INTEGER value: 'c'
11080 Warning 1292 Truncated incorrect INTEGER value: 'c'
11081 select count(*) from information_schema.OPTIMIZER_TRACE;
11082 count(*)
11083 1
11084 select TRACE into @trace from information_schema.OPTIMIZER_TRACE;
11085 select @trace;
11086 @trace
11087 {
11088 "steps": [
11089 {
11090 "statement_parameters": [
11091 "LONGLONG"
11092 ] /* statement_parameters */
11093 },
11094 {
11095 "join_optimization": {
11096 "select#": 1,
11097 "steps": [
11098 {
11099 "condition_processing": {
11100 "condition": "WHERE",
11101 "original_condition": "(`t1`.`data` = 'c')",
11102 "steps": [
11103 {
11104 "transformation": "equality_propagation",
11105 "resulting_condition": "multiple equal('c', `t1`.`data`)"
11106 },
11107 {
11108 "transformation": "constant_propagation",
11109 "resulting_condition": "multiple equal('c', `t1`.`data`)"
11110 },
11111 {
11112 "transformation": "trivial_condition_removal",
11113 "resulting_condition": "multiple equal('c', `t1`.`data`)"
11114 }
11115 ] /* steps */
11116 } /* condition_processing */
11117 },
11118 {
11119 "substitute_generated_columns": {
11120 } /* substitute_generated_columns */
11121 },
11122 {
11123 "table_dependencies": [
11124 {
11125 "table": "`t1`",
11126 "row_may_be_null": false,
11127 "map_bit": 0,
11128 "depends_on_map_bits": [
11129 ] /* depends_on_map_bits */
11130 }
11131 ] /* table_dependencies */
11132 },
11133 {
11134 "ref_optimizer_key_uses": [
11135 ] /* ref_optimizer_key_uses */
11136 },
11137 {
11138 "rows_estimation": [
11139 {
11140 "table": "`t1`",
11141 "table_scan": {
11142 "rows": 2,
11143 "cost": 0.512634
11144 } /* table_scan */
11145 }
11146 ] /* rows_estimation */
11147 },
11148 {
11149 "considered_execution_plans": [
11150 {
11151 "plan_prefix": [
11152 ] /* plan_prefix */,
11153 "table": "`t1`",
11154 "best_access_path": {
11155 "considered_access_paths": [
11156 {
11157 "rows_to_scan": 2,
11158 "access_type": "scan",
11159 "resulting_rows": 2,
11160 "cost": 0.712634,
11161 "chosen": true
11162 }
11163 ] /* considered_access_paths */
11164 } /* best_access_path */,
11165 "condition_filtering_pct": 100,
11166 "rows_for_plan": 2,
11167 "cost_for_plan": 0.712634,
11168 "chosen": true
11169 }
11170 ] /* considered_execution_plans */
11171 },
11172 {
11173 "attaching_conditions_to_tables": {
11174 "original_condition": "(`t1`.`data` = 'c')",
11175 "attached_conditions_computation": [
11176 ] /* attached_conditions_computation */,
11177 "attached_conditions_summary": [
11178 {
11179 "table": "`t1`",
11180 "attached": "(`t1`.`data` = 'c')"
11181 }
11182 ] /* attached_conditions_summary */
11183 } /* attaching_conditions_to_tables */
11184 },
11185 {
11186 "optimizing_distinct_group_by_order_by": {
11187 } /* optimizing_distinct_group_by_order_by */
11188 },
11189 {
11190 "finalizing_table_conditions": [
11191 {
11192 "table": "`t1`",
11193 "original_table_condition": "(`t1`.`data` = 'c')",
11194 "final_table_condition ": "(`t1`.`data` = 'c')"
11195 }
11196 ] /* finalizing_table_conditions */
11197 },
11198 {
11199 "refine_plan": [
11200 {
11201 "table": "`t1`"
11202 }
11203 ] /* refine_plan */
11204 },
11205 {
11206 "considering_tmp_tables": [
11207 ] /* considering_tmp_tables */
11208 }
11209 ] /* steps */
11210 } /* join_optimization */
11211 },
11212 {
11213 "join_execution": {
11214 "select#": 1,
11215 "steps": [
11216 ] /* steps */
11217 } /* join_execution */
11218 }
11219 ] /* steps */
11220 }
11221 set optimizer_trace_offset=0, optimizer_trace_limit=100;
11222 execute stmt using @param;
11223 count(*)
11224 0
11225 Warnings:
11226 Warning 1292 Truncated incorrect INTEGER value: 'c'
11227 Warning 1292 Truncated incorrect INTEGER value: 'c'
11228 Warning 1292 Truncated incorrect INTEGER value: 'c'
11229 Warning 1292 Truncated incorrect INTEGER value: 'c'
11230 select count(*) from information_schema.OPTIMIZER_TRACE;
11231 count(*)
11232 1
11233 select TRACE into @trace2 from information_schema.OPTIMIZER_TRACE;
11234 select @trace=@trace2;
11235 @trace=@trace2
11236 1
11237 drop procedure p1;
11238 create temporary table optt like information_schema.OPTIMIZER_TRACE;
11239 create procedure p1(arg char(1) charset utf8mb4)
11240 begin
11241 declare res int;
11242 set optimizer_trace="enabled=off";
11243 # want to see all of SELECT below
11244 set optimizer_trace_offset=0, optimizer_trace_limit=100;
11245 set optimizer_trace="enabled=on";
11246 select d into res from t6 where d in (select f1() from t2 where s=arg);
11247 set optimizer_trace="enabled=off"; # and not more
11248 insert into optt select * from information_schema.OPTIMIZER_TRACE;
11249 set optimizer_trace_offset=default, optimizer_trace_limit=default;
11250 select d+1 into res from t6 where d=res+1;
11251 end|
11252 call p1("c")|
11253 Warnings:
11254 Warning 1329 No data - zero rows fetched, selected, or processed
11255 select * from optt|
11256 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
11257 select d into res from t6 where d in (select f1() from t2 where s=arg) {
11258 "steps": [
11259 {
11260 "join_preparation": {
11261 "select#": 1,
11262 "steps": [
11263 {
11264 "join_preparation": {
11265 "select#": 2,
11266 "steps": [
11267 {
11268 "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0)"
11269 }
11270 ] /* steps */
11271 } /* join_preparation */
11272 },
11273 {
11274 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` where `t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0))"
11275 },
11276 {
11277 "transformation": {
11278 "select#": 2,
11279 "from": "IN (SELECT)",
11280 "to": "semijoin",
11281 "chosen": true,
11282 "transformation_to_semi_join": {
11283 "subquery_predicate": "`t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0))",
11284 "embedded in": "WHERE",
11285 "evaluating_constant_semijoin_conditions": [
11286 ] /* evaluating_constant_semijoin_conditions */,
11287 "semi-join condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
11288 "decorrelated_predicates": [
11289 {
11290 "outer": "`t6`.`d`",
11291 "inner": "`f1`()"
11292 }
11293 ] /* decorrelated_predicates */
11294 } /* transformation_to_semi_join */
11295 } /* transformation */
11296 },
11297 {
11298 "transformations_to_nested_joins": {
11299 "transformations": [
11300 "semijoin"
11301 ] /* transformations */,
11302 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` semi join (`t2`) where ((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
11303 } /* transformations_to_nested_joins */
11304 }
11305 ] /* steps */
11306 } /* join_preparation */
11307 },
11308 {
11309 "join_optimization": {
11310 "select#": 1,
11311 "steps": [
11312 {
11313 "condition_processing": {
11314 "condition": "WHERE",
11315 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
11316 "steps": [
11317 {
11318 "transformation": "equality_propagation",
11319 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
11320 },
11321 {
11322 "transformation": "constant_propagation",
11323 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
11324 },
11325 {
11326 "transformation": "trivial_condition_removal",
11327 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
11328 }
11329 ] /* steps */
11330 } /* condition_processing */
11331 },
11332 {
11333 "substitute_generated_columns": {
11334 } /* substitute_generated_columns */
11335 },
11336 {
11337 "table_dependencies": [
11338 {
11339 "table": "`t6`",
11340 "row_may_be_null": false,
11341 "map_bit": 0,
11342 "depends_on_map_bits": [
11343 ] /* depends_on_map_bits */
11344 },
11345 {
11346 "table": "`t2`",
11347 "row_may_be_null": false,
11348 "map_bit": 1,
11349 "depends_on_map_bits": [
11350 ] /* depends_on_map_bits */
11351 }
11352 ] /* table_dependencies */
11353 },
11354 {
11355 "ref_optimizer_key_uses": [
11356 ] /* ref_optimizer_key_uses */
11357 },
11358 {
11359 "pulled_out_semijoin_tables": [
11360 ] /* pulled_out_semijoin_tables */
11361 },
11362 {
11363 "rows_estimation": [
11364 {
11365 "table": "`t6`",
11366 "table_scan": {
11367 "rows": 4,
11368 "cost": 0.501709
11369 } /* table_scan */
11370 },
11371 {
11372 "table": "`t2`",
11373 "table_scan": {
11374 "rows": 8,
11375 "cost": 0.537598
11376 } /* table_scan */
11377 }
11378 ] /* rows_estimation */
11379 },
11380 {
11381 "execution_plan_for_potential_materialization": {
11382 "steps": [
11383 {
11384 "considered_execution_plans": [
11385 {
11386 "plan_prefix": [
11387 ] /* plan_prefix */,
11388 "table": "`t2`",
11389 "best_access_path": {
11390 "considered_access_paths": [
11391 {
11392 "rows_to_scan": 8,
11393 "filtering_effect": [
11394 ] /* filtering_effect */,
11395 "final_filtering_effect": 0.125,
11396 "access_type": "scan",
11397 "resulting_rows": 1,
11398 "cost": 1.3376,
11399 "chosen": true
11400 }
11401 ] /* considered_access_paths */
11402 } /* best_access_path */,
11403 "condition_filtering_pct": 100,
11404 "rows_for_plan": 1,
11405 "cost_for_plan": 1.3376,
11406 "chosen": true
11407 }
11408 ] /* considered_execution_plans */
11409 }
11410 ] /* steps */
11411 } /* execution_plan_for_potential_materialization */
11412 },
11413 {
11414 "considered_execution_plans": [
11415 {
11416 "plan_prefix": [
11417 ] /* plan_prefix */,
11418 "table": "`t6`",
11419 "best_access_path": {
11420 "considered_access_paths": [
11421 {
11422 "rows_to_scan": 4,
11423 "filtering_effect": [
11424 ] /* filtering_effect */,
11425 "final_filtering_effect": 1,
11426 "access_type": "scan",
11427 "resulting_rows": 4,
11428 "cost": 0.901709,
11429 "chosen": true
11430 }
11431 ] /* considered_access_paths */
11432 } /* best_access_path */,
11433 "condition_filtering_pct": 25,
11434 "rows_for_plan": 1,
11435 "cost_for_plan": 0.901709,
11436 "semijoin_strategy_choice": [
11437 ] /* semijoin_strategy_choice */,
11438 "rest_of_plan": [
11439 {
11440 "plan_prefix": [
11441 "`t6`"
11442 ] /* plan_prefix */,
11443 "table": "`t2`",
11444 "best_access_path": {
11445 "considered_access_paths": [
11446 {
11447 "rows_to_scan": 8,
11448 "filtering_effect": [
11449 ] /* filtering_effect */,
11450 "final_filtering_effect": 0.125,
11451 "access_type": "scan",
11452 "using_join_cache": true,
11453 "buffers_needed": 1,
11454 "resulting_rows": 1,
11455 "cost": 1.33762,
11456 "chosen": true
11457 }
11458 ] /* considered_access_paths */
11459 } /* best_access_path */,
11460 "condition_filtering_pct": 100,
11461 "rows_for_plan": 1,
11462 "cost_for_plan": 2.23933,
11463 "semijoin_strategy_choice": [
11464 {
11465 "strategy": "FirstMatch",
11466 "recalculate_access_paths_and_cost": {
11467 "tables": [
11468 {
11469 "table": "`t2`",
11470 "best_access_path": {
11471 "considered_access_paths": [
11472 {
11473 "rows_to_scan": 8,
11474 "filtering_effect": [
11475 ] /* filtering_effect */,
11476 "final_filtering_effect": 0.125,
11477 "access_type": "scan",
11478 "using_join_cache": true,
11479 "buffers_needed": 1,
11480 "resulting_rows": 1,
11481 "cost": 1.33762,
11482 "chosen": true
11483 }
11484 ] /* considered_access_paths */
11485 } /* best_access_path */
11486 }
11487 ] /* tables */
11488 } /* recalculate_access_paths_and_cost */,
11489 "cost": 2.23933,
11490 "rows": 1,
11491 "chosen": true
11492 },
11493 {
11494 "strategy": "MaterializeLookup",
11495 "cost": 3.43931,
11496 "rows": 1,
11497 "duplicate_tables_left": false,
11498 "chosen": false
11499 },
11500 {
11501 "strategy": "DuplicatesWeedout",
11502 "cost": 3.43933,
11503 "rows": 1,
11504 "duplicate_tables_left": false,
11505 "chosen": false
11506 }
11507 ] /* semijoin_strategy_choice */,
11508 "chosen": true
11509 }
11510 ] /* rest_of_plan */
11511 },
11512 {
11513 "plan_prefix": [
11514 ] /* plan_prefix */,
11515 "table": "`t2`",
11516 "best_access_path": {
11517 "considered_access_paths": [
11518 {
11519 "rows_to_scan": 8,
11520 "filtering_effect": [
11521 ] /* filtering_effect */,
11522 "final_filtering_effect": 0.125,
11523 "access_type": "scan",
11524 "resulting_rows": 1,
11525 "cost": 1.3376,
11526 "chosen": true
11527 }
11528 ] /* considered_access_paths */
11529 } /* best_access_path */,
11530 "condition_filtering_pct": 100,
11531 "rows_for_plan": 1,
11532 "cost_for_plan": 1.3376,
11533 "semijoin_strategy_choice": [
11534 {
11535 "strategy": "MaterializeScan",
11536 "choice": "deferred"
11537 }
11538 ] /* semijoin_strategy_choice */,
11539 "pruned_by_heuristic": true
11540 },
11541 {
11542 "final_semijoin_strategy": "FirstMatch",
11543 "recalculate_access_paths_and_cost": {
11544 "tables": [
11545 {
11546 "table": "`t2`",
11547 "best_access_path": {
11548 "considered_access_paths": [
11549 {
11550 "rows_to_scan": 8,
11551 "filtering_effect": [
11552 ] /* filtering_effect */,
11553 "final_filtering_effect": 0.125,
11554 "access_type": "scan",
11555 "using_join_cache": true,
11556 "buffers_needed": 1,
11557 "resulting_rows": 1,
11558 "cost": 1.33762,
11559 "chosen": true
11560 }
11561 ] /* considered_access_paths */
11562 } /* best_access_path */
11563 }
11564 ] /* tables */
11565 } /* recalculate_access_paths_and_cost */
11566 }
11567 ] /* considered_execution_plans */
11568 },
11569 {
11570 "attaching_conditions_to_tables": {
11571 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
11572 "attached_conditions_computation": [
11573 ] /* attached_conditions_computation */,
11574 "attached_conditions_summary": [
11575 {
11576 "table": "`t6`",
11577 "attached": null
11578 },
11579 {
11580 "table": "`t2`",
11581 "attached": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
11582 }
11583 ] /* attached_conditions_summary */
11584 } /* attaching_conditions_to_tables */
11585 },
11586 {
11587 "finalizing_table_conditions": [
11588 {
11589 "table": "`t2`",
11590 "original_table_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
11591 "final_table_condition ": "((`t2`.`s` = <cache>(arg@0)) and (`t6`.`d` = `f1`()))"
11592 }
11593 ] /* finalizing_table_conditions */
11594 },
11595 {
11596 "refine_plan": [
11597 {
11598 "table": "`t6`"
11599 },
11600 {
11601 "table": "`t2`"
11602 }
11603 ] /* refine_plan */
11604 }
11605 ] /* steps */
11606 } /* join_optimization */
11607 },
11608 {
11609 "join_execution": {
11610 "select#": 1,
11611 "steps": [
11612 ] /* steps */
11613 } /* join_execution */
11614 }
11615 ] /* steps */
11616 } 0 0
11617 set ret@0 NULL {
11618 "steps": [
11619 ] /* steps */
11620 } 0 0
11621 insert into t1 values("z",0) {
11622 "steps": [
11623 ] /* steps */
11624 } 0 0
11625 delete from t1 where id="z" {
11626 "steps": [
11627 {
11628 "delete_preparation": {
11629 "select#": 1,
11630 "steps": [
11631 "delete from `t1` where (`t1`.`id` = 'z')"
11632 ] /* steps */
11633 } /* delete_preparation */
11634 },
11635 {
11636 "substitute_generated_columns": {
11637 } /* substitute_generated_columns */
11638 },
11639 {
11640 "condition_processing": {
11641 "condition": "WHERE",
11642 "original_condition": "(`t1`.`id` = 'z')",
11643 "steps": [
11644 {
11645 "transformation": "equality_propagation",
11646 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11647 },
11648 {
11649 "transformation": "constant_propagation",
11650 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11651 },
11652 {
11653 "transformation": "trivial_condition_removal",
11654 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11655 }
11656 ] /* steps */
11657 } /* condition_processing */
11658 },
11659 {
11660 "table": "`t1`",
11661 "range_analysis": {
11662 "table_scan": {
11663 "rows": 3,
11664 "cost": 2.91263
11665 } /* table_scan */
11666 } /* range_analysis */
11667 }
11668 ] /* steps */
11669 } 0 0
11670 select sum(data) into ret from t1 {
11671 "steps": [
11672 {
11673 "join_preparation": {
11674 "select#": 1,
11675 "steps": [
11676 {
11677 "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
11678 }
11679 ] /* steps */
11680 } /* join_preparation */
11681 },
11682 {
11683 "join_optimization": {
11684 "select#": 1,
11685 "steps": [
11686 {
11687 "table_dependencies": [
11688 {
11689 "table": "`t1`",
11690 "row_may_be_null": false,
11691 "map_bit": 0,
11692 "depends_on_map_bits": [
11693 ] /* depends_on_map_bits */
11694 }
11695 ] /* table_dependencies */
11696 },
11697 {
11698 "rows_estimation": [
11699 {
11700 "table": "`t1`",
11701 "table_scan": {
11702 "rows": 2,
11703 "cost": 0.512634
11704 } /* table_scan */
11705 }
11706 ] /* rows_estimation */
11707 },
11708 {
11709 "considered_execution_plans": [
11710 {
11711 "plan_prefix": [
11712 ] /* plan_prefix */,
11713 "table": "`t1`",
11714 "best_access_path": {
11715 "considered_access_paths": [
11716 {
11717 "rows_to_scan": 2,
11718 "access_type": "scan",
11719 "resulting_rows": 2,
11720 "cost": 0.712634,
11721 "chosen": true
11722 }
11723 ] /* considered_access_paths */
11724 } /* best_access_path */,
11725 "condition_filtering_pct": 100,
11726 "rows_for_plan": 2,
11727 "cost_for_plan": 0.712634,
11728 "chosen": true
11729 }
11730 ] /* considered_execution_plans */
11731 },
11732 {
11733 "attaching_conditions_to_tables": {
11734 "original_condition": null,
11735 "attached_conditions_computation": [
11736 ] /* attached_conditions_computation */,
11737 "attached_conditions_summary": [
11738 {
11739 "table": "`t1`",
11740 "attached": null
11741 }
11742 ] /* attached_conditions_summary */
11743 } /* attaching_conditions_to_tables */
11744 },
11745 {
11746 "optimizing_distinct_group_by_order_by": {
11747 } /* optimizing_distinct_group_by_order_by */
11748 },
11749 {
11750 "finalizing_table_conditions": [
11751 ] /* finalizing_table_conditions */
11752 },
11753 {
11754 "refine_plan": [
11755 {
11756 "table": "`t1`"
11757 }
11758 ] /* refine_plan */
11759 },
11760 {
11761 "considering_tmp_tables": [
11762 ] /* considering_tmp_tables */
11763 }
11764 ] /* steps */
11765 } /* join_optimization */
11766 },
11767 {
11768 "join_execution": {
11769 "select#": 1,
11770 "steps": [
11771 ] /* steps */
11772 } /* join_execution */
11773 }
11774 ] /* steps */
11775 } 0 0
11776 freturn 3 ret@0 {
11777 "steps": [
11778 ] /* steps */
11779 } 0 0
11780 set ret@0 NULL {
11781 "steps": [
11782 ] /* steps */
11783 } 0 0
11784 insert into t1 values("z",0) {
11785 "steps": [
11786 ] /* steps */
11787 } 0 0
11788 delete from t1 where id="z" {
11789 "steps": [
11790 {
11791 "substitute_generated_columns": {
11792 } /* substitute_generated_columns */
11793 },
11794 {
11795 "condition_processing": {
11796 "condition": "WHERE",
11797 "original_condition": "(`t1`.`id` = 'z')",
11798 "steps": [
11799 {
11800 "transformation": "equality_propagation",
11801 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11802 },
11803 {
11804 "transformation": "constant_propagation",
11805 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11806 },
11807 {
11808 "transformation": "trivial_condition_removal",
11809 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11810 }
11811 ] /* steps */
11812 } /* condition_processing */
11813 },
11814 {
11815 "table": "`t1`",
11816 "range_analysis": {
11817 "table_scan": {
11818 "rows": 3,
11819 "cost": 2.91263
11820 } /* table_scan */
11821 } /* range_analysis */
11822 }
11823 ] /* steps */
11824 } 0 0
11825 select sum(data) into ret from t1 {
11826 "steps": [
11827 {
11828 "join_optimization": {
11829 "select#": 1,
11830 "steps": [
11831 {
11832 "table_dependencies": [
11833 {
11834 "table": "`t1`",
11835 "row_may_be_null": false,
11836 "map_bit": 0,
11837 "depends_on_map_bits": [
11838 ] /* depends_on_map_bits */
11839 }
11840 ] /* table_dependencies */
11841 },
11842 {
11843 "rows_estimation": [
11844 {
11845 "table": "`t1`",
11846 "table_scan": {
11847 "rows": 2,
11848 "cost": 0.512634
11849 } /* table_scan */
11850 }
11851 ] /* rows_estimation */
11852 },
11853 {
11854 "considered_execution_plans": [
11855 {
11856 "plan_prefix": [
11857 ] /* plan_prefix */,
11858 "table": "`t1`",
11859 "best_access_path": {
11860 "considered_access_paths": [
11861 {
11862 "rows_to_scan": 2,
11863 "access_type": "scan",
11864 "resulting_rows": 2,
11865 "cost": 0.712634,
11866 "chosen": true
11867 }
11868 ] /* considered_access_paths */
11869 } /* best_access_path */,
11870 "condition_filtering_pct": 100,
11871 "rows_for_plan": 2,
11872 "cost_for_plan": 0.712634,
11873 "chosen": true
11874 }
11875 ] /* considered_execution_plans */
11876 },
11877 {
11878 "attaching_conditions_to_tables": {
11879 "original_condition": null,
11880 "attached_conditions_computation": [
11881 ] /* attached_conditions_computation */,
11882 "attached_conditions_summary": [
11883 {
11884 "table": "`t1`",
11885 "attached": null
11886 }
11887 ] /* attached_conditions_summary */
11888 } /* attaching_conditions_to_tables */
11889 },
11890 {
11891 "optimizing_distinct_group_by_order_by": {
11892 } /* optimizing_distinct_group_by_order_by */
11893 },
11894 {
11895 "finalizing_table_conditions": [
11896 ] /* finalizing_table_conditions */
11897 },
11898 {
11899 "refine_plan": [
11900 {
11901 "table": "`t1`"
11902 }
11903 ] /* refine_plan */
11904 },
11905 {
11906 "considering_tmp_tables": [
11907 ] /* considering_tmp_tables */
11908 }
11909 ] /* steps */
11910 } /* join_optimization */
11911 },
11912 {
11913 "join_execution": {
11914 "select#": 1,
11915 "steps": [
11916 ] /* steps */
11917 } /* join_execution */
11918 }
11919 ] /* steps */
11920 } 0 0
11921 freturn 3 ret@0 {
11922 "steps": [
11923 ] /* steps */
11924 } 0 0
11925 set ret@0 NULL {
11926 "steps": [
11927 ] /* steps */
11928 } 0 0
11929 insert into t1 values("z",0) {
11930 "steps": [
11931 ] /* steps */
11932 } 0 0
11933 delete from t1 where id="z" {
11934 "steps": [
11935 {
11936 "substitute_generated_columns": {
11937 } /* substitute_generated_columns */
11938 },
11939 {
11940 "condition_processing": {
11941 "condition": "WHERE",
11942 "original_condition": "(`t1`.`id` = 'z')",
11943 "steps": [
11944 {
11945 "transformation": "equality_propagation",
11946 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11947 },
11948 {
11949 "transformation": "constant_propagation",
11950 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11951 },
11952 {
11953 "transformation": "trivial_condition_removal",
11954 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11955 }
11956 ] /* steps */
11957 } /* condition_processing */
11958 },
11959 {
11960 "table": "`t1`",
11961 "range_analysis": {
11962 "table_scan": {
11963 "rows": 3,
11964 "cost": 2.91263
11965 } /* table_scan */
11966 } /* range_analysis */
11967 }
11968 ] /* steps */
11969 } 0 0
11970 select sum(data) into ret from t1 {
11971 "steps": [
11972 {
11973 "join_optimization": {
11974 "select#": 1,
11975 "steps": [
11976 {
11977 "table_dependencies": [
11978 {
11979 "table": "`t1`",
11980 "row_may_be_null": false,
11981 "map_bit": 0,
11982 "depends_on_map_bits": [
11983 ] /* depends_on_map_bits */
11984 }
11985 ] /* table_dependencies */
11986 },
11987 {
11988 "rows_estimation": [
11989 {
11990 "table": "`t1`",
11991 "table_scan": {
11992 "rows": 2,
11993 "cost": 0.512634
11994 } /* table_scan */
11995 }
11996 ] /* rows_estimation */
11997 },
11998 {
11999 "considered_execution_plans": [
12000 {
12001 "plan_prefix": [
12002 ] /* plan_prefix */,
12003 "table": "`t1`",
12004 "best_access_path": {
12005 "considered_access_paths": [
12006 {
12007 "rows_to_scan": 2,
12008 "access_type": "scan",
12009 "resulting_rows": 2,
12010 "cost": 0.712634,
12011 "chosen": true
12012 }
12013 ] /* considered_access_paths */
12014 } /* best_access_path */,
12015 "condition_filtering_pct": 100,
12016 "rows_for_plan": 2,
12017 "cost_for_plan": 0.712634,
12018 "chosen": true
12019 }
12020 ] /* considered_execution_plans */
12021 },
12022 {
12023 "attaching_conditions_to_tables": {
12024 "original_condition": null,
12025 "attached_conditions_computation": [
12026 ] /* attached_conditions_computation */,
12027 "attached_conditions_summary": [
12028 {
12029 "table": "`t1`",
12030 "attached": null
12031 }
12032 ] /* attached_conditions_summary */
12033 } /* attaching_conditions_to_tables */
12034 },
12035 {
12036 "optimizing_distinct_group_by_order_by": {
12037 } /* optimizing_distinct_group_by_order_by */
12038 },
12039 {
12040 "finalizing_table_conditions": [
12041 ] /* finalizing_table_conditions */
12042 },
12043 {
12044 "refine_plan": [
12045 {
12046 "table": "`t1`"
12047 }
12048 ] /* refine_plan */
12049 },
12050 {
12051 "considering_tmp_tables": [
12052 ] /* considering_tmp_tables */
12053 }
12054 ] /* steps */
12055 } /* join_optimization */
12056 },
12057 {
12058 "join_execution": {
12059 "select#": 1,
12060 "steps": [
12061 ] /* steps */
12062 } /* join_execution */
12063 }
12064 ] /* steps */
12065 } 0 0
12066 freturn 3 ret@0 {
12067 "steps": [
12068 ] /* steps */
12069 } 0 0
12070 set ret@0 NULL {
12071 "steps": [
12072 ] /* steps */
12073 } 0 0
12074 insert into t1 values("z",0) {
12075 "steps": [
12076 ] /* steps */
12077 } 0 0
12078 delete from t1 where id="z" {
12079 "steps": [
12080 {
12081 "substitute_generated_columns": {
12082 } /* substitute_generated_columns */
12083 },
12084 {
12085 "condition_processing": {
12086 "condition": "WHERE",
12087 "original_condition": "(`t1`.`id` = 'z')",
12088 "steps": [
12089 {
12090 "transformation": "equality_propagation",
12091 "resulting_condition": "multiple equal('z', `t1`.`id`)"
12092 },
12093 {
12094 "transformation": "constant_propagation",
12095 "resulting_condition": "multiple equal('z', `t1`.`id`)"
12096 },
12097 {
12098 "transformation": "trivial_condition_removal",
12099 "resulting_condition": "multiple equal('z', `t1`.`id`)"
12100 }
12101 ] /* steps */
12102 } /* condition_processing */
12103 },
12104 {
12105 "table": "`t1`",
12106 "range_analysis": {
12107 "table_scan": {
12108 "rows": 3,
12109 "cost": 2.91263
12110 } /* table_scan */
12111 } /* range_analysis */
12112 }
12113 ] /* steps */
12114 } 0 0
12115 select sum(data) into ret from t1 {
12116 "steps": [
12117 {
12118 "join_optimization": {
12119 "select#": 1,
12120 "steps": [
12121 {
12122 "table_dependencies": [
12123 {
12124 "table": "`t1`",
12125 "row_may_be_null": false,
12126 "map_bit": 0,
12127 "depends_on_map_bits": [
12128 ] /* depends_on_map_bits */
12129 }
12130 ] /* table_dependencies */
12131 },
12132 {
12133 "rows_estimation": [
12134 {
12135 "table": "`t1`",
12136 "table_scan": {
12137 "rows": 2,
12138 "cost": 0.512634
12139 } /* table_scan */
12140 }
12141 ] /* rows_estimation */
12142 },
12143 {
12144 "considered_execution_plans": [
12145 {
12146 "plan_prefix": [
12147 ] /* plan_prefix */,
12148 "table": "`t1`",
12149 "best_access_path": {
12150 "considered_access_paths": [
12151 {
12152 "rows_to_scan": 2,
12153 "access_type": "scan",
12154 "resulting_rows": 2,
12155 "cost": 0.712634,
12156 "chosen": true
12157 }
12158 ] /* considered_access_paths */
12159 } /* best_access_path */,
12160 "condition_filtering_pct": 100,
12161 "rows_for_plan": 2,
12162 "cost_for_plan": 0.712634,
12163 "chosen": true
12164 }
12165 ] /* considered_execution_plans */
12166 },
12167 {
12168 "attaching_conditions_to_tables": {
12169 "original_condition": null,
12170 "attached_conditions_computation": [
12171 ] /* attached_conditions_computation */,
12172 "attached_conditions_summary": [
12173 {
12174 "table": "`t1`",
12175 "attached": null
12176 }
12177 ] /* attached_conditions_summary */
12178 } /* attaching_conditions_to_tables */
12179 },
12180 {
12181 "optimizing_distinct_group_by_order_by": {
12182 } /* optimizing_distinct_group_by_order_by */
12183 },
12184 {
12185 "finalizing_table_conditions": [
12186 ] /* finalizing_table_conditions */
12187 },
12188 {
12189 "refine_plan": [
12190 {
12191 "table": "`t1`"
12192 }
12193 ] /* refine_plan */
12194 },
12195 {
12196 "considering_tmp_tables": [
12197 ] /* considering_tmp_tables */
12198 }
12199 ] /* steps */
12200 } /* join_optimization */
12201 },
12202 {
12203 "join_execution": {
12204 "select#": 1,
12205 "steps": [
12206 ] /* steps */
12207 } /* join_execution */
12208 }
12209 ] /* steps */
12210 } 0 0
12211 freturn 3 ret@0 {
12212 "steps": [
12213 ] /* steps */
12214 } 0 0
12215 select @@optimizer_trace|
12216 @@optimizer_trace
12217 enabled=off,one_line=off
12218 set optimizer_trace="enabled=on";
12219 drop temporary table optt;
12220 drop function f1;
12221 drop procedure p1;
12222 drop trigger trg1;
12223 create view v1 as select * from t1 where id < "c";
12224 explain select * from v1 where id="b";
12225 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
12226 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
12227 Warnings:
12228 Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`data` AS `data` from `test`.`t1` where (`test`.`t1`.`id` = 'b')
12229 select * from information_schema.OPTIMIZER_TRACE;
12230 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12231 explain select * from v1 where id="b" {
12232 "steps": [
12233 {
12234 "join_preparation": {
12235 "select#": 1,
12236 "steps": [
12237 {
12238 "join_preparation": {
12239 "select#": 2,
12240 "steps": [
12241 {
12242 "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
12243 }
12244 ] /* steps */
12245 } /* join_preparation */
12246 },
12247 {
12248 "view": {
12249 "table": "`v1`",
12250 "select#": 2,
12251 "merged": true
12252 } /* view */
12253 },
12254 {
12255 "expanded_query": "/* select#1 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from <constant table> join (`t1`) on((`t1`.`id` < 'c')) where (`t1`.`id` = 'b')"
12256 },
12257 {
12258 "transformations_to_nested_joins": {
12259 "transformations": [
12260 "JOIN_condition_to_WHERE",
12261 "parenthesis_removal"
12262 ] /* transformations */,
12263 "expanded_query": "/* select#1 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where ((`t1`.`id` = 'b') and (`t1`.`id` < 'c'))"
12264 } /* transformations_to_nested_joins */
12265 }
12266 ] /* steps */
12267 } /* join_preparation */
12268 },
12269 {
12270 "join_optimization": {
12271 "select#": 1,
12272 "steps": [
12273 {
12274 "condition_processing": {
12275 "condition": "WHERE",
12276 "original_condition": "((`t1`.`id` = 'b') and (`t1`.`id` < 'c'))",
12277 "steps": [
12278 {
12279 "transformation": "equality_propagation",
12280 "resulting_condition": "(('b' < 'c') and multiple equal('b', `t1`.`id`))"
12281 },
12282 {
12283 "transformation": "constant_propagation",
12284 "resulting_condition": "(('b' < 'c') and multiple equal('b', `t1`.`id`))"
12285 },
12286 {
12287 "transformation": "trivial_condition_removal",
12288 "resulting_condition": "multiple equal('b', `t1`.`id`)"
12289 }
12290 ] /* steps */
12291 } /* condition_processing */
12292 },
12293 {
12294 "substitute_generated_columns": {
12295 } /* substitute_generated_columns */
12296 },
12297 {
12298 "table_dependencies": [
12299 {
12300 "table": "`t1`",
12301 "row_may_be_null": false,
12302 "map_bit": 0,
12303 "depends_on_map_bits": [
12304 ] /* depends_on_map_bits */
12305 }
12306 ] /* table_dependencies */
12307 },
12308 {
12309 "ref_optimizer_key_uses": [
12310 ] /* ref_optimizer_key_uses */
12311 },
12312 {
12313 "rows_estimation": [
12314 {
12315 "table": "`t1`",
12316 "table_scan": {
12317 "rows": 2,
12318 "cost": 0.512634
12319 } /* table_scan */
12320 }
12321 ] /* rows_estimation */
12322 },
12323 {
12324 "considered_execution_plans": [
12325 {
12326 "plan_prefix": [
12327 ] /* plan_prefix */,
12328 "table": "`t1`",
12329 "best_access_path": {
12330 "considered_access_paths": [
12331 {
12332 "rows_to_scan": 2,
12333 "filtering_effect": [
12334 ] /* filtering_effect */,
12335 "final_filtering_effect": 0.5,
12336 "access_type": "scan",
12337 "resulting_rows": 1,
12338 "cost": 0.712634,
12339 "chosen": true
12340 }
12341 ] /* considered_access_paths */
12342 } /* best_access_path */,
12343 "condition_filtering_pct": 100,
12344 "rows_for_plan": 1,
12345 "cost_for_plan": 0.712634,
12346 "chosen": true
12347 }
12348 ] /* considered_execution_plans */
12349 },
12350 {
12351 "attaching_conditions_to_tables": {
12352 "original_condition": "(`t1`.`id` = 'b')",
12353 "attached_conditions_computation": [
12354 ] /* attached_conditions_computation */,
12355 "attached_conditions_summary": [
12356 {
12357 "table": "`t1`",
12358 "attached": "(`t1`.`id` = 'b')"
12359 }
12360 ] /* attached_conditions_summary */
12361 } /* attaching_conditions_to_tables */
12362 },
12363 {
12364 "finalizing_table_conditions": [
12365 {
12366 "table": "`t1`",
12367 "original_table_condition": "(`t1`.`id` = 'b')",
12368 "final_table_condition ": "(`t1`.`id` = 'b')"
12369 }
12370 ] /* finalizing_table_conditions */
12371 },
12372 {
12373 "refine_plan": [
12374 {
12375 "table": "`t1`"
12376 }
12377 ] /* refine_plan */
12378 }
12379 ] /* steps */
12380 } /* join_optimization */
12381 },
12382 {
12383 "join_explain": {
12384 "select#": 1,
12385 "steps": [
12386 ] /* steps */
12387 } /* join_explain */
12388 }
12389 ] /* steps */
12390 } 0 0
12391 insert into v1 values("z", 100);
12392 select * from information_schema.OPTIMIZER_TRACE;
12393 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12394 insert into v1 values("z", 100) {
12395 "steps": [
12396 {
12397 "join_preparation": {
12398 "select#": 2,
12399 "steps": [
12400 {
12401 "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
12402 }
12403 ] /* steps */
12404 } /* join_preparation */
12405 },
12406 {
12407 "view": {
12408 "table": "`v1`",
12409 "select#": 2,
12410 "merged": true
12411 } /* view */
12412 }
12413 ] /* steps */
12414 } 0 0
12415 delete from v1 where data=100;
12416 select * from information_schema.OPTIMIZER_TRACE;
12417 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12418 delete from v1 where data=100 {
12419 "steps": [
12420 {
12421 "delete_preparation": {
12422 "select#": 1,
12423 "steps": [
12424 {
12425 "join_preparation": {
12426 "select#": 2,
12427 "steps": [
12428 {
12429 "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
12430 }
12431 ] /* steps */
12432 } /* join_preparation */
12433 },
12434 {
12435 "view": {
12436 "table": "`v1`",
12437 "select#": 2,
12438 "merged": true
12439 } /* view */
12440 },
12441 "delete from (`t1`) on((`t1`.`id` < 'c')) where (`t1`.`data` = 100)",
12442 {
12443 "transformations_to_nested_joins": {
12444 "transformations": [
12445 "JOIN_condition_to_WHERE",
12446 "parenthesis_removal"
12447 ] /* transformations */,
12448 "expanded_query": "delete from (`t1`) where ((`t1`.`data` = 100) and (`t1`.`id` < 'c'))"
12449 } /* transformations_to_nested_joins */
12450 }
12451 ] /* steps */
12452 } /* delete_preparation */
12453 },
12454 {
12455 "substitute_generated_columns": {
12456 } /* substitute_generated_columns */
12457 },
12458 {
12459 "condition_processing": {
12460 "condition": "WHERE",
12461 "original_condition": "((`t1`.`data` = 100) and (`t1`.`id` < 'c'))",
12462 "steps": [
12463 {
12464 "transformation": "equality_propagation",
12465 "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
12466 },
12467 {
12468 "transformation": "constant_propagation",
12469 "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
12470 },
12471 {
12472 "transformation": "trivial_condition_removal",
12473 "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
12474 }
12475 ] /* steps */
12476 } /* condition_processing */
12477 },
12478 {
12479 "table": "`t1`",
12480 "range_analysis": {
12481 "table_scan": {
12482 "rows": 3,
12483 "cost": 2.91263
12484 } /* table_scan */
12485 } /* range_analysis */
12486 }
12487 ] /* steps */
12488 } 0 0
12489 drop view v1;
12490 create view v1 as select * from t1 where id < "c" limit 2;
12491 explain select * from v1 where id="b";
12492 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
12493 1 PRIMARY <derived2> NULL ref <auto_key0> <auto_key0> 64 const 1 100.00 Using where
12494 2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where
12495 Warnings:
12496 Note 1003 /* select#1 */ select `test`.`v1`.`id` AS `id`,`test`.`v1`.`data` AS `data` from `test`.`v1` where (`test`.`v1`.`id` = 'b')
12497 select * from information_schema.OPTIMIZER_TRACE;
12498 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12499 explain select * from v1 where id="b" {
12500 "steps": [
12501 {
12502 "join_preparation": {
12503 "select#": 1,
12504 "steps": [
12505 {
12506 "join_preparation": {
12507 "select#": 2,
12508 "steps": [
12509 {
12510 "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c') limit 2"
12511 }
12512 ] /* steps */
12513 } /* join_preparation */
12514 },
12515 {
12516 "view": {
12517 "table": "`v1`",
12518 "select#": 2,
12519 "materialized": true
12520 } /* view */
12521 },
12522 {
12523 "expanded_query": "/* select#1 */ select `v1`.`id` AS `id`,`v1`.`data` AS `data` from `v1` where (`v1`.`id` = 'b')"
12524 }
12525 ] /* steps */
12526 } /* join_preparation */
12527 },
12528 {
12529 "join_optimization": {
12530 "select#": 1,
12531 "steps": [
12532 {
12533 "join_optimization": {
12534 "select#": 2,
12535 "steps": [
12536 {
12537 "condition_processing": {
12538 "condition": "WHERE",
12539 "original_condition": "(`t1`.`id` < 'c')",
12540 "steps": [
12541 {
12542 "transformation": "equality_propagation",
12543 "resulting_condition": "(`t1`.`id` < 'c')"
12544 },
12545 {
12546 "transformation": "constant_propagation",
12547 "resulting_condition": "(`t1`.`id` < 'c')"
12548 },
12549 {
12550 "transformation": "trivial_condition_removal",
12551 "resulting_condition": "(`t1`.`id` < 'c')"
12552 }
12553 ] /* steps */
12554 } /* condition_processing */
12555 },
12556 {
12557 "substitute_generated_columns": {
12558 } /* substitute_generated_columns */
12559 },
12560 {
12561 "table_dependencies": [
12562 {
12563 "table": "`t1`",
12564 "row_may_be_null": false,
12565 "map_bit": 0,
12566 "depends_on_map_bits": [
12567 ] /* depends_on_map_bits */
12568 }
12569 ] /* table_dependencies */
12570 },
12571 {
12572 "ref_optimizer_key_uses": [
12573 ] /* ref_optimizer_key_uses */
12574 },
12575 {
12576 "rows_estimation": [
12577 {
12578 "table": "`t1`",
12579 "table_scan": {
12580 "rows": 3,
12581 "cost": 0.512634
12582 } /* table_scan */
12583 }
12584 ] /* rows_estimation */
12585 },
12586 {
12587 "considered_execution_plans": [
12588 {
12589 "plan_prefix": [
12590 ] /* plan_prefix */,
12591 "table": "`t1`",
12592 "best_access_path": {
12593 "considered_access_paths": [
12594 {
12595 "rows_to_scan": 3,
12596 "filtering_effect": [
12597 ] /* filtering_effect */,
12598 "final_filtering_effect": 0.333333,
12599 "access_type": "scan",
12600 "resulting_rows": 1,
12601 "cost": 0.812634,
12602 "chosen": true
12603 }
12604 ] /* considered_access_paths */
12605 } /* best_access_path */,
12606 "condition_filtering_pct": 100,
12607 "rows_for_plan": 1,
12608 "cost_for_plan": 0.812634,
12609 "chosen": true
12610 }
12611 ] /* considered_execution_plans */
12612 },
12613 {
12614 "attaching_conditions_to_tables": {
12615 "original_condition": "(`t1`.`id` < 'c')",
12616 "attached_conditions_computation": [
12617 ] /* attached_conditions_computation */,
12618 "attached_conditions_summary": [
12619 {
12620 "table": "`t1`",
12621 "attached": "(`t1`.`id` < 'c')"
12622 }
12623 ] /* attached_conditions_summary */
12624 } /* attaching_conditions_to_tables */
12625 },
12626 {
12627 "finalizing_table_conditions": [
12628 {
12629 "table": "`t1`",
12630 "original_table_condition": "(`t1`.`id` < 'c')",
12631 "final_table_condition ": "(`t1`.`id` < 'c')"
12632 }
12633 ] /* finalizing_table_conditions */
12634 },
12635 {
12636 "refine_plan": [
12637 {
12638 "table": "`t1`"
12639 }
12640 ] /* refine_plan */
12641 }
12642 ] /* steps */
12643 } /* join_optimization */
12644 },
12645 {
12646 "condition_processing": {
12647 "condition": "WHERE",
12648 "original_condition": "(`v1`.`id` = 'b')",
12649 "steps": [
12650 {
12651 "transformation": "equality_propagation",
12652 "resulting_condition": "multiple equal('b', `v1`.`id`)"
12653 },
12654 {
12655 "transformation": "constant_propagation",
12656 "resulting_condition": "multiple equal('b', `v1`.`id`)"
12657 },
12658 {
12659 "transformation": "trivial_condition_removal",
12660 "resulting_condition": "multiple equal('b', `v1`.`id`)"
12661 }
12662 ] /* steps */
12663 } /* condition_processing */
12664 },
12665 {
12666 "substitute_generated_columns": {
12667 } /* substitute_generated_columns */
12668 },
12669 {
12670 "table_dependencies": [
12671 {
12672 "table": "`v1`",
12673 "row_may_be_null": false,
12674 "map_bit": 0,
12675 "depends_on_map_bits": [
12676 ] /* depends_on_map_bits */
12677 }
12678 ] /* table_dependencies */
12679 },
12680 {
12681 "ref_optimizer_key_uses": [
12682 {
12683 "table": "`v1`",
12684 "field": "id",
12685 "equals": "'b'",
12686 "null_rejecting": true
12687 }
12688 ] /* ref_optimizer_key_uses */
12689 },
12690 {
12691 "rows_estimation": [
12692 {
12693 "table": "`v1`"
12694 }
12695 ] /* rows_estimation */
12696 },
12697 {
12698 "considered_execution_plans": [
12699 {
12700 "plan_prefix": [
12701 ] /* plan_prefix */,
12702 "table": "`v1`",
12703 "best_access_path": {
12704 "considered_access_paths": [
12705 {
12706 "access_type": "ref",
12707 "index": "<auto_key0>",
12708 "rows": 1,
12709 "cost": 0.35,
12710 "chosen": true
12711 },
12712 {
12713 "access_type": "scan",
12714 "cost": 2.725,
12715 "rows": 2,
12716 "chosen": false,
12717 "cause": "cost"
12718 }
12719 ] /* considered_access_paths */
12720 } /* best_access_path */,
12721 "condition_filtering_pct": 100,
12722 "rows_for_plan": 1,
12723 "cost_for_plan": 0.35,
12724 "chosen": true
12725 }
12726 ] /* considered_execution_plans */
12727 },
12728 {
12729 "attaching_conditions_to_tables": {
12730 "original_condition": "(`v1`.`id` = 'b')",
12731 "attached_conditions_computation": [
12732 ] /* attached_conditions_computation */,
12733 "attached_conditions_summary": [
12734 {
12735 "table": "`v1`",
12736 "attached": "(`v1`.`id` = 'b')"
12737 }
12738 ] /* attached_conditions_summary */
12739 } /* attaching_conditions_to_tables */
12740 },
12741 {
12742 "finalizing_table_conditions": [
12743 {
12744 "table": "`v1`",
12745 "original_table_condition": "(`v1`.`id` = 'b')",
12746 "final_table_condition ": "(`v1`.`id` = 'b')"
12747 }
12748 ] /* finalizing_table_conditions */
12749 },
12750 {
12751 "refine_plan": [
12752 {
12753 "table": "`v1`"
12754 }
12755 ] /* refine_plan */
12756 }
12757 ] /* steps */
12758 } /* join_optimization */
12759 },
12760 {
12761 "join_explain": {
12762 "select#": 1,
12763 "steps": [
12764 {
12765 "join_explain": {
12766 "select#": 2,
12767 "steps": [
12768 ] /* steps */
12769 } /* join_explain */
12770 }
12771 ] /* steps */
12772 } /* join_explain */
12773 }
12774 ] /* steps */
12775 } 0 0
12776 drop view v1;
12777 set end_markers_in_json=off;
12778 select 1 union select 2;
12779 1
12780 1
12781 2
12782 select TRACE into dumpfile 'MYSQLTEST_VARDIR/tmp/optimizer_trace.txt' from information_schema.OPTIMIZER_TRACE;;
12783 {
12784 "steps": [
12785 {
12786 "join_preparation": {
12787 "select#": 1,
12788 "steps": [
12789 {
12790 "expanded_query": "/* select#1 */ select 1 AS `1`"
12791 }
12792 ]
12793 }
12794 },
12795 {
12796 "join_preparation": {
12797 "select#": 2,
12798 "steps": [
12799 {
12800 "expanded_query": "/* select#2 */ select 2 AS `2`"
12801 }
12802 ]
12803 }
12804 },
12805 {
12806 "creating_tmp_table": {
12807 "tmp_table_info": {
12808 "table": "<union temporary>",
12809 "columns": 1,
12810 "row_length": 9,
12811 "key_length": 8,
12812 "unique_constraint": false,
12813 "makes_grouped_rows": false,
12814 "cannot_insert_duplicates": true,
12815 "location": "TempTable"
12816 }
12817 }
12818 },
12819 {
12820 "join_preparation": {
12821 "select#": 3,
12822 "steps": [
12823 {
12824 "expanded_query": "/* select#3 */ select `1` AS `1` from dual"
12825 }
12826 ]
12827 }
12828 },
12829 {
12830 "join_optimization": {
12831 "select#": 1,
12832 "steps": [
12833 ]
12834 }
12835 },
12836 {
12837 "join_optimization": {
12838 "select#": 2,
12839 "steps": [
12840 ]
12841 }
12842 },
12843 {
12844 "join_optimization": {
12845 "select#": 3,
12846 "steps": [
12847 {
12848 "table_dependencies": [
12849 {
12850 "table": "``",
12851 "row_may_be_null": false,
12852 "map_bit": 0,
12853 "depends_on_map_bits": [
12854 ]
12855 }
12856 ]
12857 },
12858 {
12859 "rows_estimation": [
12860 {
12861 "table": "``",
12862 "table_scan": {
12863 "rows": 0,
12864 "cost": 2.5
12865 }
12866 }
12867 ]
12868 },
12869 {
12870 "considered_execution_plans": [
12871 {
12872 "plan_prefix": [
12873 ],
12874 "table": "``",
12875 "best_access_path": {
12876 "considered_access_paths": [
12877 {
12878 "rows_to_scan": 0,
12879 "access_type": "scan",
12880 "resulting_rows": 0,
12881 "cost": 2.5,
12882 "chosen": true
12883 }
12884 ]
12885 },
12886 "condition_filtering_pct": 100,
12887 "rows_for_plan": 0,
12888 "cost_for_plan": 2.5,
12889 "chosen": true
12890 }
12891 ]
12892 },
12893 {
12894 "attaching_conditions_to_tables": {
12895 "original_condition": null,
12896 "attached_conditions_computation": [
12897 ],
12898 "attached_conditions_summary": [
12899 {
12900 "table": "``",
12901 "attached": null
12902 }
12903 ]
12904 }
12905 },
12906 {
12907 "finalizing_table_conditions": [
12908 ]
12909 },
12910 {
12911 "refine_plan": [
12912 {
12913 "table": "``"
12914 }
12915 ]
12916 }
12917 ]
12918 }
12919 },
12920 {
12921 "join_execution": {
12922 "steps": [
12923 {
12924 "materialize": {
12925 "select#": 1,
12926 "steps": [
12927 ]
12928 }
12929 },
12930 {
12931 "materialize": {
12932 "select#": 2,
12933 "steps": [
12934 ]
12935 }
12936 }
12937 ]
12938 }
12939 }
12940 ]
12941 }set optimizer_switch='default,index_merge=on,index_merge=off,default';
12942 ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off,default'
12943 select @@optimizer_switch=@old_opt_switch;
12944 @@optimizer_switch=@old_opt_switch
12945 1
12946 select * from information_schema.OPTIMIZER_TRACE;
12947 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12948 select "abc1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111def" as col {
12949 "steps": [
12950 {
12951 "join_preparation": {
12952 "select#": 1,
12953 "steps": [
12954 {
12955 "expanded_query": "/* select#1 */ select 'abc1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111def' AS `col`"
12956 }
12957 ]
12958 }
12959 },
12960 {
12961 "join_optimization": {
12962 "select#": 1,
12963 "steps": [
12964 ]
12965 }
12966 },
12967 {
12968 "join_execution": {
12969 "select#": 1,
12970 "steps": [
12971 ]
12972 }
12973 }
12974 ]
12975 } 0 0
12976 drop table t1,t2;
12977 DROP TABLE t5,t6;
12978 # Trace for transformation scalar subquery to derived table
12979 CREATE TABLE t1(a INT);
12980 CREATE TABLE t2(a INT);
12981 INSERT INTO t1 VALUES (1),(2),(3),(4);
12982 INSERT INTO t2 VALUES (1),(2);
12983 ANALYZE TABLE t1, t2;
12984 Table Op Msg_type Msg_text
12985 test.t1 analyze status OK
12986 test.t2 analyze status OK
12987 SET optimizer_switch='subquery_to_derived=on';
12988 SELECT a + (SELECT SUM(a) + (SELECT COUNT(a) FROM t1) FROM t1) AS cnt FROM t2;
12989 cnt
12990 15
12991 16
12992 SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
12993 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12994 SELECT a + (SELECT SUM(a) + (SELECT COUNT(a) FROM t1) FROM t1) AS cnt FROM t2 {
12995 "steps": [
12996 {
12997 "join_preparation": {
12998 "select#": 1,
12999 "steps": [
13000 {
13001 "join_preparation": {
13002 "select#": 2,
13003 "steps": [
13004 {
13005 "join_preparation": {
13006 "select#": 3,
13007 "steps": [
13008 {
13009 "expanded_query": "/* select#3 */ select count(`t1`.`a`) from `t1`"
13010 }
13011 ]
13012 }
13013 },
13014 {
13015 "expanded_query": "/* select#2 */ select (sum(`t1`.`a`) + (/* select#3 */ select count(`t1`.`a`) from `t1`)) from `t1`"
13016 },
13017 {
13018 "join_preparation": {
13019 "select#": 4,
13020 "steps": [
13021 {
13022 "expanded_query": "/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`"
13023 }
13024 ]
13025 }
13026 },
13027 {
13028 "derived": {
13029 "table": " `derived_2_4`",
13030 "select#": 4,
13031 "materialized": true
13032 }
13033 },
13034 {
13035 "transformation": {
13036 "select#": 2,
13037 "from": "grouped subquery",
13038 "to": "subquery over grouped derived table",
13039 "expanded_query": "/* select#2 */ select (`derived_2_4`.`tmp_aggr_1` + (/* select#5 */ select count(`t1`.`a`) from `t1`)) from (/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`) `derived_2_4`"
13040 }
13041 },
13042 {
13043 "derived": {
13044 "table": " `derived_2_5`",
13045 "select#": 5,
13046 "materialized": true
13047 }
13048 },
13049 {
13050 "transformation": {
13051 "select#": 5,
13052 "from": "scalar subquery",
13053 "to": "derived table",
13054 "expanded_query": "/* select#2 */ select (`derived_2_4`.`tmp_aggr_1` + `derived_2_5`.`COUNT(a)`) from ((/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`) `derived_2_4` left join (/* select#5 */ select count(`t1`.`a`) AS `COUNT(a)` from `t1`) `derived_2_5` on(true))"
13055 }
13056 }
13057 ]
13058 }
13059 },
13060 {
13061 "expanded_query": "/* select#1 */ select (`t2`.`a` + (/* select#2 */ select (`derived_2_4`.`tmp_aggr_1` + `derived_2_5`.`COUNT(a)`) from ((/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`) `derived_2_4` left join (/* select#5 */ select count(`t1`.`a`) AS `COUNT(a)` from `t1`) `derived_2_5` on(true)))) AS `cnt` from `t2`"
13062 },
13063 {
13064 "derived": {
13065 "table": " `derived_1_2`",
13066 "select#": 2,
13067 "materialized": true
13068 }
13069 },
13070 {
13071 "transformation": {
13072 "select#": 2,
13073 "from": "scalar subquery",
13074 "to": "derived table",
13075 "expanded_query": "/* select#1 */ select (`t2`.`a` + `derived_1_2`.`SUM(a) + (SELECT COUNT(a) FROM t1)`) AS `cnt` from (`t2` left join (/* select#2 */ select (`derived_2_4`.`tmp_aggr_1` + `derived_2_5`.`COUNT(a)`) AS `SUM(a) + (SELECT COUNT(a) FROM t1)` from ((/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`) `derived_2_4` left join (/* select#5 */ select count(`t1`.`a`) AS `COUNT(a)` from `t1`) `derived_2_5` on(true))) `derived_1_2` on(true))"
13076 }
13077 },
13078 {
13079 "transformations_to_nested_joins": {
13080 "transformations": [
13081 "parenthesis_removal"
13082 ],
13083 "expanded_query": "/* select#2 */ select (`derived_2_4`.`tmp_aggr_1` + `derived_2_5`.`COUNT(a)`) AS `SUM(a) + (SELECT COUNT(a) FROM t1)` from (/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`) `derived_2_4` left join (/* select#5 */ select count(`t1`.`a`) AS `COUNT(a)` from `t1`) `derived_2_5` on(true)"
13084 }
13085 },
13086 {
13087 "transformations_to_nested_joins": {
13088 "transformations": [
13089 "parenthesis_removal"
13090 ],
13091 "expanded_query": "/* select#1 */ select (`t2`.`a` + `derived_1_2`.`SUM(a) + (SELECT COUNT(a) FROM t1)`) AS `cnt` from `t2` left join (/* select#2 */ select (`derived_2_4`.`tmp_aggr_1` + `derived_2_5`.`COUNT(a)`) AS `SUM(a) + (SELECT COUNT(a) FROM t1)` from (/* select#4 */ select sum(`t1`.`a`) AS `tmp_aggr_1` from `t1`) `derived_2_4` left join (/* select#5 */ select count(`t1`.`a`) AS `COUNT(a)` from `t1`) `derived_2_5` on(true)) `derived_1_2` on(true)"
13092 }
13093 }
13094 ]
13095 }
13096 },
13097 {
13098 "join_optimization": {
13099 "select#": 1,
13100 "steps": [
13101 {
13102 "join_optimization": {
13103 "select#": 2,
13104 "steps": [
13105 {
13106 "join_optimization": {
13107 "select#": 4,
13108 "steps": [
13109 {
13110 "table_dependencies": [
13111 {
13112 "table": "`t1`",
13113 "row_may_be_null": false,
13114 "map_bit": 0,
13115 "depends_on_map_bits": [
13116 ]
13117 }
13118 ]
13119 },
13120 {
13121 "rows_estimation": [
13122 {
13123 "table": "`t1`",
13124 "table_scan": {
13125 "rows": 4,
13126 "cost": 0.501709
13127 }
13128 }
13129 ]
13130 },
13131 {
13132 "considered_execution_plans": [
13133 {
13134 "plan_prefix": [
13135 ],
13136 "table": "`t1`",
13137 "best_access_path": {
13138 "considered_access_paths": [
13139 {
13140 "rows_to_scan": 4,
13141 "access_type": "scan",
13142 "resulting_rows": 4,
13143 "cost": 0.901709,
13144 "chosen": true
13145 }
13146 ]
13147 },
13148 "condition_filtering_pct": 100,
13149 "rows_for_plan": 4,
13150 "cost_for_plan": 0.901709,
13151 "chosen": true
13152 }
13153 ]
13154 },
13155 {
13156 "attaching_conditions_to_tables": {
13157 "original_condition": null,
13158 "attached_conditions_computation": [
13159 ],
13160 "attached_conditions_summary": [
13161 {
13162 "table": "`t1`",
13163 "attached": null
13164 }
13165 ]
13166 }
13167 },
13168 {
13169 "optimizing_distinct_group_by_order_by": {
13170 }
13171 },
13172 {
13173 "finalizing_table_conditions": [
13174 ]
13175 },
13176 {
13177 "refine_plan": [
13178 {
13179 "table": "`t1`"
13180 }
13181 ]
13182 },
13183 {
13184 "considering_tmp_tables": [
13185 ]
13186 }
13187 ]
13188 }
13189 },
13190 {
13191 "creating_tmp_table": {
13192 "tmp_table_info": {
13193 "table": "derived_2_4",
13194 "columns": 1,
13195 "row_length": 16,
13196 "key_length": 0,
13197 "unique_constraint": false,
13198 "makes_grouped_rows": false,
13199 "cannot_insert_duplicates": false,
13200 "location": "TempTable"
13201 }
13202 }
13203 },
13204 {
13205 "join_execution": {
13206 "select#": 4,
13207 "steps": [
13208 ]
13209 }
13210 },
13211 {
13212 "join_optimization": {
13213 "select#": 5,
13214 "steps": [
13215 {
13216 "table_dependencies": [
13217 {
13218 "table": "`t1`",
13219 "row_may_be_null": false,
13220 "map_bit": 0,
13221 "depends_on_map_bits": [
13222 ]
13223 }
13224 ]
13225 },
13226 {
13227 "rows_estimation": [
13228 {
13229 "table": "`t1`",
13230 "table_scan": {
13231 "rows": 4,
13232 "cost": 0.501709
13233 }
13234 }
13235 ]
13236 },
13237 {
13238 "considered_execution_plans": [
13239 {
13240 "plan_prefix": [
13241 ],
13242 "table": "`t1`",
13243 "best_access_path": {
13244 "considered_access_paths": [
13245 {
13246 "rows_to_scan": 4,
13247 "access_type": "scan",
13248 "resulting_rows": 4,
13249 "cost": 0.901709,
13250 "chosen": true
13251 }
13252 ]
13253 },
13254 "condition_filtering_pct": 100,
13255 "rows_for_plan": 4,
13256 "cost_for_plan": 0.901709,
13257 "chosen": true
13258 }
13259 ]
13260 },
13261 {
13262 "attaching_conditions_to_tables": {
13263 "original_condition": null,
13264 "attached_conditions_computation": [
13265 ],
13266 "attached_conditions_summary": [
13267 {
13268 "table": "`t1`",
13269 "attached": null
13270 }
13271 ]
13272 }
13273 },
13274 {
13275 "optimizing_distinct_group_by_order_by": {
13276 }
13277 },
13278 {
13279 "finalizing_table_conditions": [
13280 ]
13281 },
13282 {
13283 "refine_plan": [
13284 {
13285 "table": "`t1`"
13286 }
13287 ]
13288 },
13289 {
13290 "considering_tmp_tables": [
13291 ]
13292 }
13293 ]
13294 }
13295 },
13296 {
13297 "creating_tmp_table": {
13298 "tmp_table_info": {
13299 "table": "derived_2_5",
13300 "columns": 1,
13301 "row_length": 9,
13302 "key_length": 0,
13303 "unique_constraint": false,
13304 "makes_grouped_rows": false,
13305 "cannot_insert_duplicates": false,
13306 "location": "TempTable"
13307 }
13308 }
13309 },
13310 {
13311 "join_execution": {
13312 "select#": 5,
13313 "steps": [
13314 ]
13315 }
13316 },
13317 {
13318 "condition_processing": {
13319 "condition": "WHERE",
13320 "original_condition": null,
13321 "steps": [
13322 {
13323 "transformation": "equality_propagation",
13324 "resulting_condition": null
13325 }
13326 ]
13327 }
13328 },
13329 {
13330 "table_dependencies": [
13331 {
13332 "table": " `derived_2_4`",
13333 "row_may_be_null": false,
13334 "map_bit": 0,
13335 "depends_on_map_bits": [
13336 ]
13337 },
13338 {
13339 "table": " `derived_2_5`",
13340 "row_may_be_null": true,
13341 "map_bit": 1,
13342 "depends_on_map_bits": [
13343 0
13344 ]
13345 }
13346 ]
13347 },
13348 {
13349 "ref_optimizer_key_uses": [
13350 ]
13351 },
13352 {
13353 "rows_estimation": [
13354 {
13355 "table": " `derived_2_4`",
13356 "table_scan": {
13357 "rows": 1,
13358 "cost": 2.5125
13359 }
13360 },
13361 {
13362 "table": " `derived_2_5`",
13363 "table_scan": {
13364 "rows": 1,
13365 "cost": 2.5125
13366 }
13367 }
13368 ]
13369 },
13370 {
13371 "considered_execution_plans": [
13372 {
13373 "plan_prefix": [
13374 ],
13375 "table": " `derived_2_4`",
13376 "best_access_path": {
13377 "considered_access_paths": [
13378 {
13379 "rows_to_scan": 1,
13380 "access_type": "scan",
13381 "resulting_rows": 1,
13382 "cost": 2.6125,
13383 "chosen": true
13384 }
13385 ]
13386 },
13387 "condition_filtering_pct": 100,
13388 "rows_for_plan": 1,
13389 "cost_for_plan": 2.6125,
13390 "rest_of_plan": [
13391 {
13392 "plan_prefix": [
13393 " `derived_2_4`"
13394 ],
13395 "table": " `derived_2_5`",
13396 "best_access_path": {
13397 "considered_access_paths": [
13398 {
13399 "rows_to_scan": 1,
13400 "access_type": "scan",
13401 "using_join_cache": true,
13402 "buffers_needed": 1,
13403 "resulting_rows": 1,
13404 "cost": 2.61265,
13405 "chosen": true
13406 }
13407 ]
13408 },
13409 "condition_filtering_pct": 100,
13410 "rows_for_plan": 1,
13411 "cost_for_plan": 5.22515,
13412 "chosen": true
13413 }
13414 ]
13415 }
13416 ]
13417 },
13418 {
13419 "condition_on_constant_tables": "true",
13420 "condition_value": true
13421 },
13422 {
13423 "attaching_conditions_to_tables": {
13424 "original_condition": "true",
13425 "attached_conditions_computation": [
13426 ],
13427 "attached_conditions_summary": [
13428 {
13429 "table": " `derived_2_4`",
13430 "attached": null
13431 },
13432 {
13433 "table": " `derived_2_5`",
13434 "attached": "<if>(is_not_null_compl(derived_2_5), true, true)"
13435 }
13436 ]
13437 }
13438 },
13439 {
13440 "finalizing_table_conditions": [
13441 {
13442 "table": " `derived_2_5`",
13443 "original_table_condition": "<if>(is_not_null_compl(derived_2_5), true, true)",
13444 "final_table_condition ": "<if>(is_not_null_compl(derived_2_5), true, true)"
13445 }
13446 ]
13447 },
13448 {
13449 "refine_plan": [
13450 {
13451 "table": " `derived_2_4`"
13452 },
13453 {
13454 "table": " `derived_2_5`"
13455 }
13456 ]
13457 }
13458 ]
13459 }
13460 },
13461 {
13462 "condition_processing": {
13463 "condition": "WHERE",
13464 "original_condition": null,
13465 "steps": [
13466 {
13467 "transformation": "equality_propagation",
13468 "resulting_condition": null
13469 }
13470 ]
13471 }
13472 },
13473 {
13474 "table_dependencies": [
13475 {
13476 "table": "`t2`",
13477 "row_may_be_null": false,
13478 "map_bit": 0,
13479 "depends_on_map_bits": [
13480 ]
13481 },
13482 {
13483 "table": " `derived_1_2`",
13484 "row_may_be_null": true,
13485 "map_bit": 1,
13486 "depends_on_map_bits": [
13487 0
13488 ]
13489 }
13490 ]
13491 },
13492 {
13493 "ref_optimizer_key_uses": [
13494 ]
13495 },
13496 {
13497 "rows_estimation": [
13498 {
13499 "table": "`t2`",
13500 "table_scan": {
13501 "rows": 2,
13502 "cost": 0.500854
13503 }
13504 },
13505 {
13506 "table": " `derived_1_2`",
13507 "table_scan": {
13508 "rows": 2,
13509 "cost": 2.525
13510 }
13511 }
13512 ]
13513 },
13514 {
13515 "considered_execution_plans": [
13516 {
13517 "plan_prefix": [
13518 ],
13519 "table": "`t2`",
13520 "best_access_path": {
13521 "considered_access_paths": [
13522 {
13523 "rows_to_scan": 2,
13524 "access_type": "scan",
13525 "resulting_rows": 2,
13526 "cost": 0.700854,
13527 "chosen": true
13528 }
13529 ]
13530 },
13531 "condition_filtering_pct": 100,
13532 "rows_for_plan": 2,
13533 "cost_for_plan": 0.700854,
13534 "rest_of_plan": [
13535 {
13536 "plan_prefix": [
13537 "`t2`"
13538 ],
13539 "table": " `derived_1_2`",
13540 "best_access_path": {
13541 "considered_access_paths": [
13542 {
13543 "rows_to_scan": 2,
13544 "access_type": "scan",
13545 "using_join_cache": true,
13546 "buffers_needed": 1,
13547 "resulting_rows": 2,
13548 "cost": 2.9251,
13549 "chosen": true
13550 }
13551 ]
13552 },
13553 "condition_filtering_pct": 100,
13554 "rows_for_plan": 4,
13555 "cost_for_plan": 3.62595,
13556 "chosen": true
13557 }
13558 ]
13559 }
13560 ]
13561 },
13562 {
13563 "condition_on_constant_tables": "true",
13564 "condition_value": true
13565 },
13566 {
13567 "attaching_conditions_to_tables": {
13568 "original_condition": "true",
13569 "attached_conditions_computation": [
13570 ],
13571 "attached_conditions_summary": [
13572 {
13573 "table": "`t2`",
13574 "attached": null
13575 },
13576 {
13577 "table": " `derived_1_2`",
13578 "attached": "<if>(is_not_null_compl(derived_1_2), true, true)"
13579 }
13580 ]
13581 }
13582 },
13583 {
13584 "finalizing_table_conditions": [
13585 {
13586 "table": " `derived_1_2`",
13587 "original_table_condition": "<if>(is_not_null_compl(derived_1_2), true, true)",
13588 "final_table_condition ": "<if>(is_not_null_compl(derived_1_2), true, true)"
13589 }
13590 ]
13591 },
13592 {
13593 "refine_plan": [
13594 {
13595 "table": "`t2`"
13596 },
13597 {
13598 "table": " `derived_1_2`"
13599 }
13600 ]
13601 }
13602 ]
13603 }
13604 },
13605 {
13606 "join_execution": {
13607 "select#": 1,
13608 "steps": [
13609 {
13610 "creating_tmp_table": {
13611 "tmp_table_info": {
13612 "table": "derived_1_2",
13613 "in_plan_at_position": 1,
13614 "columns": 1,
13615 "row_length": 16,
13616 "key_length": 0,
13617 "unique_constraint": false,
13618 "makes_grouped_rows": false,
13619 "cannot_insert_duplicates": false,
13620 "location": "TempTable"
13621 }
13622 }
13623 },
13624 {
13625 "materialize": {
13626 "select#": 2,
13627 "steps": [
13628 ]
13629 }
13630 }
13631 ]
13632 }
13633 }
13634 ]
13635 } 0 0
13636 SET optimizer_switch='subquery_to_derived=default';
13637 DROP TABLE t1, t2;
13638 SET optimizer_trace=default;