Debian Codegraph @

mysql-test/suite/opt_trace/r/general_ps_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_optimization": {
21 "select#": 1,
22 "steps": [
23 {
24 "table_dependencies": [
25 {
26 "table": "`t5`",
27 "row_may_be_null": false,
28 "map_bit": 0,
29 "depends_on_map_bits": [
30 ]
31 }
32 ]
33 },
34 {
35 "rows_estimation": [
36 {
37 "table": "`t5`",
38 "rows": 1,
39 "cost": 1,
40 "table_type": "system",
41 "empty": false
42 }
43 ]
44 },
45 {
46 "attaching_conditions_to_tables": {
47 "original_condition": null,
48 "attached_conditions_computation": [
49 ],
50 "attached_conditions_summary": [
51 ]
52 }
53 },
54 {
55 "refine_plan": [
56 ]
57 }
58 ]
59 }
60 },
61 {
62 "join_optimization": {
63 "select#": 2,
64 "steps": [
65 {
66 "condition_processing": {
67 "condition": "WHERE",
68 "original_condition": "(`t6`.`d` = NULL)",
69 "steps": [
70 {
71 "transformation": "equality_propagation",
72 "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
73 },
74 {
75 "transformation": "constant_propagation",
76 "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
77 },
78 {
79 "transformation": "trivial_condition_removal",
80 "resulting_condition": "multiple equal(NULL, `t6`.`d`)"
81 }
82 ]
83 }
84 },
85 {
86 "substitute_generated_columns": {
87 }
88 },
89 {
90 "table_dependencies": [
91 {
92 "table": "`t6`",
93 "row_may_be_null": false,
94 "map_bit": 0,
95 "depends_on_map_bits": [
96 ]
97 }
98 ]
99 },
100 {
101 "ref_optimizer_key_uses": [
102 {
103 "table": "`t6`",
104 "field": "d",
105 "equals": "NULL",
106 "null_rejecting": true
107 }
108 ]
109 },
110 {
111 "rows_estimation": [
112 {
113 "table": "`t6`",
114 "range_analysis": {
115 "table_scan": {
116 "rows": 2,
117 "cost": 2.80085
118 },
119 "potential_range_indexes": [
120 {
121 "index": "d",
122 "usable": true,
123 "key_parts": [
124 "d"
125 ]
126 }
127 ],
128 "best_covering_index_scan": {
129 "index": "d",
130 "cost": 0.455814,
131 "chosen": true
132 },
133 "setup_range_conditions": [
134 {
135 "impossible_condition": {
136 "cause": "comparison_with_null_always_false"
137 }
138 }
139 ],
140 "impossible_range": true
141 },
142 "rows": 0,
143 "cause": "impossible_where_condition"
144 }
145 ]
146 }
147 ],
148 "empty_result": {
149 "cause": "no matching row in const table"
150 }
151 }
152 },
153 {
154 "join_execution": {
155 "select#": 1,
156 "steps": [
157 {
158 "subselect_execution": {
159 "select#": 2,
160 "steps": [
161 {
162 "join_execution": {
163 "select#": 2,
164 "steps": [
165 ]
166 }
167 }
168 ]
169 }
170 }
171 ]
172 }
173 }
174 ]
175 } 0 0
176 select (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
177 from information_schema.OPTIMIZER_TRACE;
178 (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
179 55.0197
180 set optimizer_trace="one_line=on";
181 SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 ;
182 RESULT
183 NULL
184 select * from information_schema.OPTIMIZER_TRACE;
185 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
186 SELECT (SELECT 1 FROM t6 WHERE d = c) AS RESULT FROM t5 {"steps": [{"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
187 select (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
188 from information_schema.OPTIMIZER_TRACE;
189 (1-length(replace(TRACE, " ", ""))/length(TRACE))*100
190 5.0057
191 set end_markers_in_json=on;
192 set optimizer_trace="one_line=off";
193 EXPLAIN SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
194 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
195 1 PRIMARY t5 NULL system NULL NULL NULL NULL 1 100.00 NULL
196 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
197 Warnings:
198 Note 1276 Field or reference 'test.t5.c' of SELECT #2 was resolved in SELECT #1
199 Note 1003 /* select#1 */ select (/* select#2 */ select 1 from `test`.`t6` where (`test`.`t6`.`d` = ifnull(NULL,NULL))) AS `RESULT` from dual
200 select * from information_schema.OPTIMIZER_TRACE;
201 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
202 EXPLAIN SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 {
203 "steps": [
204 {
205 "join_preparation": {
206 "select#": 1,
207 "steps": [
208 {
209 "join_preparation": {
210 "select#": 2,
211 "steps": [
212 {
213 "expanded_query": "/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))"
214 }
215 ] /* steps */
216 } /* join_preparation */
217 },
218 {
219 "expanded_query": "/* select#1 */ select (/* select#2 */ select 1 from `t6` where (`t6`.`d` = ifnull(`t5`.`c`,NULL))) AS `RESULT` from `t5`"
220 }
221 ] /* steps */
222 } /* join_preparation */
223 },
224 {
225 "join_optimization": {
226 "select#": 1,
227 "steps": [
228 {
229 "table_dependencies": [
230 {
231 "table": "`t5`",
232 "row_may_be_null": false,
233 "map_bit": 0,
234 "depends_on_map_bits": [
235 ] /* depends_on_map_bits */
236 }
237 ] /* table_dependencies */
238 },
239 {
240 "rows_estimation": [
241 {
242 "table": "`t5`",
243 "rows": 1,
244 "cost": 1,
245 "table_type": "system",
246 "empty": false
247 }
248 ] /* rows_estimation */
249 },
250 {
251 "attaching_conditions_to_tables": {
252 "original_condition": null,
253 "attached_conditions_computation": [
254 ] /* attached_conditions_computation */,
255 "attached_conditions_summary": [
256 ] /* attached_conditions_summary */
257 } /* attaching_conditions_to_tables */
258 },
259 {
260 "refine_plan": [
261 ] /* refine_plan */
262 }
263 ] /* steps */
264 } /* join_optimization */
265 },
266 {
267 "join_optimization": {
268 "select#": 2,
269 "steps": [
270 {
271 "condition_processing": {
272 "condition": "WHERE",
273 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
274 "steps": [
275 {
276 "transformation": "equality_propagation",
277 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
278 },
279 {
280 "transformation": "constant_propagation",
281 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
282 },
283 {
284 "transformation": "trivial_condition_removal",
285 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
286 }
287 ] /* steps */
288 } /* condition_processing */
289 },
290 {
291 "substitute_generated_columns": {
292 } /* substitute_generated_columns */
293 },
294 {
295 "table_dependencies": [
296 {
297 "table": "`t6`",
298 "row_may_be_null": false,
299 "map_bit": 0,
300 "depends_on_map_bits": [
301 ] /* depends_on_map_bits */
302 }
303 ] /* table_dependencies */
304 },
305 {
306 "ref_optimizer_key_uses": [
307 {
308 "table": "`t6`",
309 "field": "d",
310 "equals": "ifnull(NULL,NULL)",
311 "null_rejecting": true
312 }
313 ] /* ref_optimizer_key_uses */
314 },
315 {
316 "rows_estimation": [
317 {
318 "table": "`t6`",
319 "range_analysis": {
320 "table_scan": {
321 "rows": 2,
322 "cost": 2.80085
323 } /* table_scan */,
324 "potential_range_indexes": [
325 {
326 "index": "d",
327 "usable": true,
328 "key_parts": [
329 "d"
330 ] /* key_parts */
331 }
332 ] /* potential_range_indexes */,
333 "best_covering_index_scan": {
334 "index": "d",
335 "cost": 0.455814,
336 "chosen": true
337 } /* best_covering_index_scan */,
338 "setup_range_conditions": [
339 {
340 "impossible_condition": {
341 "cause": "comparison_with_null_always_false"
342 } /* impossible_condition */
343 }
344 ] /* setup_range_conditions */,
345 "impossible_range": true
346 } /* range_analysis */,
347 "rows": 0,
348 "cause": "impossible_where_condition"
349 }
350 ] /* rows_estimation */
351 }
352 ] /* steps */,
353 "empty_result": {
354 "cause": "no matching row in const table"
355 } /* empty_result */
356 } /* join_optimization */
357 },
358 {
359 "join_explain": {
360 "select#": 1,
361 "steps": [
362 {
363 "join_explain": {
364 "select#": 2,
365 "steps": [
366 ] /* steps */
367 } /* join_explain */
368 }
369 ] /* steps */
370 } /* join_explain */
371 }
372 ] /* steps */
373 } 0 0
374 SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
375 RESULT
376 NULL
377 select * from information_schema.OPTIMIZER_TRACE;
378 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
379 SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 {
380 "steps": [
381 {
382 "join_optimization": {
383 "select#": 1,
384 "steps": [
385 {
386 "table_dependencies": [
387 {
388 "table": "`t5`",
389 "row_may_be_null": false,
390 "map_bit": 0,
391 "depends_on_map_bits": [
392 ] /* depends_on_map_bits */
393 }
394 ] /* table_dependencies */
395 },
396 {
397 "rows_estimation": [
398 {
399 "table": "`t5`",
400 "rows": 1,
401 "cost": 1,
402 "table_type": "system",
403 "empty": false
404 }
405 ] /* rows_estimation */
406 },
407 {
408 "attaching_conditions_to_tables": {
409 "original_condition": null,
410 "attached_conditions_computation": [
411 ] /* attached_conditions_computation */,
412 "attached_conditions_summary": [
413 ] /* attached_conditions_summary */
414 } /* attaching_conditions_to_tables */
415 },
416 {
417 "refine_plan": [
418 ] /* refine_plan */
419 }
420 ] /* steps */
421 } /* join_optimization */
422 },
423 {
424 "join_optimization": {
425 "select#": 2,
426 "steps": [
427 {
428 "condition_processing": {
429 "condition": "WHERE",
430 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
431 "steps": [
432 {
433 "transformation": "equality_propagation",
434 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
435 },
436 {
437 "transformation": "constant_propagation",
438 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
439 },
440 {
441 "transformation": "trivial_condition_removal",
442 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
443 }
444 ] /* steps */
445 } /* condition_processing */
446 },
447 {
448 "substitute_generated_columns": {
449 } /* substitute_generated_columns */
450 },
451 {
452 "table_dependencies": [
453 {
454 "table": "`t6`",
455 "row_may_be_null": false,
456 "map_bit": 0,
457 "depends_on_map_bits": [
458 ] /* depends_on_map_bits */
459 }
460 ] /* table_dependencies */
461 },
462 {
463 "ref_optimizer_key_uses": [
464 {
465 "table": "`t6`",
466 "field": "d",
467 "equals": "ifnull(NULL,NULL)",
468 "null_rejecting": true
469 }
470 ] /* ref_optimizer_key_uses */
471 },
472 {
473 "rows_estimation": [
474 {
475 "table": "`t6`",
476 "range_analysis": {
477 "table_scan": {
478 "rows": 2,
479 "cost": 2.80085
480 } /* table_scan */,
481 "potential_range_indexes": [
482 {
483 "index": "d",
484 "usable": true,
485 "key_parts": [
486 "d"
487 ] /* key_parts */
488 }
489 ] /* potential_range_indexes */,
490 "best_covering_index_scan": {
491 "index": "d",
492 "cost": 0.455814,
493 "chosen": true
494 } /* best_covering_index_scan */,
495 "setup_range_conditions": [
496 {
497 "impossible_condition": {
498 "cause": "comparison_with_null_always_false"
499 } /* impossible_condition */
500 }
501 ] /* setup_range_conditions */,
502 "impossible_range": true
503 } /* range_analysis */,
504 "rows": 0,
505 "cause": "impossible_where_condition"
506 }
507 ] /* rows_estimation */
508 }
509 ] /* steps */,
510 "empty_result": {
511 "cause": "no matching row in const table"
512 } /* empty_result */
513 } /* join_optimization */
514 },
515 {
516 "join_execution": {
517 "select#": 1,
518 "steps": [
519 {
520 "subselect_execution": {
521 "select#": 2,
522 "steps": [
523 {
524 "join_execution": {
525 "select#": 2,
526 "steps": [
527 ] /* steps */
528 } /* join_execution */
529 }
530 ] /* steps */
531 } /* subselect_execution */
532 }
533 ] /* steps */
534 } /* join_execution */
535 }
536 ] /* steps */
537 } 0 0
538 set @@session.optimizer_trace="enabled=off";
539 SELECT /* bug if you see this*/ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
540 RESULT
541 NULL
542 select QUERY from information_schema.OPTIMIZER_TRACE;
543 QUERY
544 SELECT /* should be last */ (SELECT 1 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5
545 set @@session.optimizer_trace="enabled=on";
546 SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 ;
547 RESULT
548 NULL
549 select * from information_schema.OPTIMIZER_TRACE;
550 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
551 SELECT (SELECT 1 FROM t6 WHERE d = ifnull(c,null) UNION SELECT 2 FROM t6 WHERE d = ifnull(c,null)) AS RESULT FROM t5 {
552 "steps": [
553 {
554 "join_optimization": {
555 "select#": 1,
556 "steps": [
557 {
558 "table_dependencies": [
559 {
560 "table": "`t5`",
561 "row_may_be_null": false,
562 "map_bit": 0,
563 "depends_on_map_bits": [
564 ] /* depends_on_map_bits */
565 }
566 ] /* table_dependencies */
567 },
568 {
569 "rows_estimation": [
570 {
571 "table": "`t5`",
572 "rows": 1,
573 "cost": 1,
574 "table_type": "system",
575 "empty": false
576 }
577 ] /* rows_estimation */
578 },
579 {
580 "attaching_conditions_to_tables": {
581 "original_condition": null,
582 "attached_conditions_computation": [
583 ] /* attached_conditions_computation */,
584 "attached_conditions_summary": [
585 ] /* attached_conditions_summary */
586 } /* attaching_conditions_to_tables */
587 },
588 {
589 "refine_plan": [
590 ] /* refine_plan */
591 }
592 ] /* steps */
593 } /* join_optimization */
594 },
595 {
596 "join_optimization": {
597 "select#": 2,
598 "steps": [
599 {
600 "condition_processing": {
601 "condition": "WHERE",
602 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
603 "steps": [
604 {
605 "transformation": "equality_propagation",
606 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
607 },
608 {
609 "transformation": "constant_propagation",
610 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
611 },
612 {
613 "transformation": "trivial_condition_removal",
614 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
615 }
616 ] /* steps */
617 } /* condition_processing */
618 },
619 {
620 "substitute_generated_columns": {
621 } /* substitute_generated_columns */
622 },
623 {
624 "table_dependencies": [
625 {
626 "table": "`t6`",
627 "row_may_be_null": false,
628 "map_bit": 0,
629 "depends_on_map_bits": [
630 ] /* depends_on_map_bits */
631 }
632 ] /* table_dependencies */
633 },
634 {
635 "ref_optimizer_key_uses": [
636 {
637 "table": "`t6`",
638 "field": "d",
639 "equals": "ifnull(NULL,NULL)",
640 "null_rejecting": true
641 }
642 ] /* ref_optimizer_key_uses */
643 },
644 {
645 "rows_estimation": [
646 {
647 "table": "`t6`",
648 "range_analysis": {
649 "table_scan": {
650 "rows": 2,
651 "cost": 2.80085
652 } /* table_scan */,
653 "potential_range_indexes": [
654 {
655 "index": "d",
656 "usable": true,
657 "key_parts": [
658 "d"
659 ] /* key_parts */
660 }
661 ] /* potential_range_indexes */,
662 "best_covering_index_scan": {
663 "index": "d",
664 "cost": 0.455814,
665 "chosen": true
666 } /* best_covering_index_scan */,
667 "setup_range_conditions": [
668 {
669 "impossible_condition": {
670 "cause": "comparison_with_null_always_false"
671 } /* impossible_condition */
672 }
673 ] /* setup_range_conditions */,
674 "impossible_range": true
675 } /* range_analysis */,
676 "rows": 0,
677 "cause": "impossible_where_condition"
678 }
679 ] /* rows_estimation */
680 }
681 ] /* steps */,
682 "empty_result": {
683 "cause": "no matching row in const table"
684 } /* empty_result */
685 } /* join_optimization */
686 },
687 {
688 "join_optimization": {
689 "select#": 3,
690 "steps": [
691 {
692 "condition_processing": {
693 "condition": "WHERE",
694 "original_condition": "(`t6`.`d` = ifnull(NULL,NULL))",
695 "steps": [
696 {
697 "transformation": "equality_propagation",
698 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
699 },
700 {
701 "transformation": "constant_propagation",
702 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
703 },
704 {
705 "transformation": "trivial_condition_removal",
706 "resulting_condition": "(`t6`.`d` = ifnull(NULL,NULL))"
707 }
708 ] /* steps */
709 } /* condition_processing */
710 },
711 {
712 "substitute_generated_columns": {
713 } /* substitute_generated_columns */
714 },
715 {
716 "table_dependencies": [
717 {
718 "table": "`t6`",
719 "row_may_be_null": false,
720 "map_bit": 0,
721 "depends_on_map_bits": [
722 ] /* depends_on_map_bits */
723 }
724 ] /* table_dependencies */
725 },
726 {
727 "ref_optimizer_key_uses": [
728 {
729 "table": "`t6`",
730 "field": "d",
731 "equals": "ifnull(NULL,NULL)",
732 "null_rejecting": true
733 }
734 ] /* ref_optimizer_key_uses */
735 },
736 {
737 "rows_estimation": [
738 {
739 "table": "`t6`",
740 "range_analysis": {
741 "table_scan": {
742 "rows": 2,
743 "cost": 2.80085
744 } /* table_scan */,
745 "potential_range_indexes": [
746 {
747 "index": "d",
748 "usable": true,
749 "key_parts": [
750 "d"
751 ] /* key_parts */
752 }
753 ] /* potential_range_indexes */,
754 "best_covering_index_scan": {
755 "index": "d",
756 "cost": 0.455814,
757 "chosen": true
758 } /* best_covering_index_scan */,
759 "setup_range_conditions": [
760 {
761 "impossible_condition": {
762 "cause": "comparison_with_null_always_false"
763 } /* impossible_condition */
764 }
765 ] /* setup_range_conditions */,
766 "impossible_range": true
767 } /* range_analysis */,
768 "rows": 0,
769 "cause": "impossible_where_condition"
770 }
771 ] /* rows_estimation */
772 }
773 ] /* steps */,
774 "empty_result": {
775 "cause": "no matching row in const table"
776 } /* empty_result */
777 } /* join_optimization */
778 },
779 {
780 "creating_tmp_table": {
781 "tmp_table_info": {
782 "table": "<union temporary>",
783 "columns": 1,
784 "row_length": 9,
785 "key_length": 8,
786 "unique_constraint": false,
787 "makes_grouped_rows": false,
788 "cannot_insert_duplicates": true,
789 "location": "TempTable"
790 } /* tmp_table_info */
791 } /* creating_tmp_table */
792 },
793 {
794 "join_optimization": {
795 "select#": 4,
796 "steps": [
797 {
798 "table_dependencies": [
799 {
800 "table": "``",
801 "row_may_be_null": false,
802 "map_bit": 0,
803 "depends_on_map_bits": [
804 ] /* depends_on_map_bits */
805 }
806 ] /* table_dependencies */
807 },
808 {
809 "rows_estimation": [
810 {
811 "table": "``",
812 "table_scan": {
813 "rows": 0,
814 "cost": 2.5
815 } /* table_scan */
816 }
817 ] /* rows_estimation */
818 },
819 {
820 "considered_execution_plans": [
821 {
822 "plan_prefix": [
823 ] /* plan_prefix */,
824 "table": "``",
825 "best_access_path": {
826 "considered_access_paths": [
827 {
828 "rows_to_scan": 0,
829 "access_type": "scan",
830 "resulting_rows": 0,
831 "cost": 2.5,
832 "chosen": true
833 }
834 ] /* considered_access_paths */
835 } /* best_access_path */,
836 "condition_filtering_pct": 100,
837 "rows_for_plan": 0,
838 "cost_for_plan": 2.5,
839 "chosen": true
840 }
841 ] /* considered_execution_plans */
842 },
843 {
844 "attaching_conditions_to_tables": {
845 "original_condition": null,
846 "attached_conditions_computation": [
847 ] /* attached_conditions_computation */,
848 "attached_conditions_summary": [
849 {
850 "table": "``",
851 "attached": null
852 }
853 ] /* attached_conditions_summary */
854 } /* attaching_conditions_to_tables */
855 },
856 {
857 "finalizing_table_conditions": [
858 ] /* finalizing_table_conditions */
859 },
860 {
861 "refine_plan": [
862 {
863 "table": "``"
864 }
865 ] /* refine_plan */
866 }
867 ] /* steps */
868 } /* join_optimization */
869 },
870 {
871 "join_execution": {
872 "select#": 1,
873 "steps": [
874 {
875 "subselect_execution": {
876 "select#": 2,
877 "steps": [
878 {
879 "join_execution": {
880 "steps": [
881 {
882 "materialize": {
883 "select#": 2,
884 "steps": [
885 ] /* steps */
886 } /* materialize */
887 },
888 {
889 "materialize": {
890 "select#": 3,
891 "steps": [
892 ] /* steps */
893 } /* materialize */
894 }
895 ] /* steps */
896 } /* join_execution */
897 }
898 ] /* steps */
899 } /* subselect_execution */
900 }
901 ] /* steps */
902 } /* join_execution */
903 }
904 ] /* steps */
905 } 0 0
906 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));
907 c
908 select * from information_schema.OPTIMIZER_TRACE;
909 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
910 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)) {
911 "steps": [
912 {
913 "join_optimization": {
914 "select#": 1,
915 "steps": [
916 {
917 "condition_processing": {
918 "condition": "WHERE",
919 "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))))",
920 "steps": [
921 {
922 "transformation": "equality_propagation",
923 "subselect_evaluation": [
924 ] /* subselect_evaluation */,
925 "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))))"
926 },
927 {
928 "transformation": "constant_propagation",
929 "subselect_evaluation": [
930 ] /* subselect_evaluation */,
931 "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))))"
932 },
933 {
934 "transformation": "trivial_condition_removal",
935 "subselect_evaluation": [
936 ] /* subselect_evaluation */,
937 "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))))"
938 }
939 ] /* steps */
940 } /* condition_processing */
941 },
942 {
943 "substitute_generated_columns": {
944 } /* substitute_generated_columns */
945 },
946 {
947 "table_dependencies": [
948 {
949 "table": "`t5`",
950 "row_may_be_null": false,
951 "map_bit": 0,
952 "depends_on_map_bits": [
953 ] /* depends_on_map_bits */
954 }
955 ] /* table_dependencies */
956 },
957 {
958 "ref_optimizer_key_uses": [
959 ] /* ref_optimizer_key_uses */
960 },
961 {
962 "rows_estimation": [
963 {
964 "table": "`t5`",
965 "rows": 1,
966 "cost": 1,
967 "table_type": "system",
968 "empty": false
969 }
970 ] /* rows_estimation */
971 },
972 {
973 "subselect_execution": {
974 "select#": 2,
975 "steps": [
976 {
977 "join_optimization": {
978 "select#": 2,
979 "steps": [
980 {
981 "condition_processing": {
982 "condition": "WHERE",
983 "original_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 1))",
984 "steps": [
985 {
986 "transformation": "equality_propagation",
987 "resulting_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 1))"
988 },
989 {
990 "transformation": "constant_propagation",
991 "resulting_condition": "((`t6`.`d` = NULL) and (<cache>(5) = 1))"
992 },
993 {
994 "transformation": "trivial_condition_removal",
995 "resulting_condition": null
996 }
997 ] /* steps */
998 } /* condition_processing */
999 }
1000 ] /* steps */,
1001 "empty_result": {
1002 "cause": "Impossible WHERE"
1003 } /* empty_result */
1004 } /* join_optimization */
1005 },
1006 {
1007 "join_optimization": {
1008 "select#": 3,
1009 "steps": [
1010 {
1011 "condition_processing": {
1012 "condition": "WHERE",
1013 "original_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 2))",
1014 "steps": [
1015 {
1016 "transformation": "equality_propagation",
1017 "resulting_condition": "((`t6`.`d` = ifnull(NULL,NULL)) and (<cache>(5) = 2))"
1018 },
1019 {
1020 "transformation": "constant_propagation",
1021 "resulting_condition": "((`t6`.`d` = NULL) and (<cache>(5) = 2))"
1022 },
1023 {
1024 "transformation": "trivial_condition_removal",
1025 "resulting_condition": null
1026 }
1027 ] /* steps */
1028 } /* condition_processing */
1029 }
1030 ] /* steps */,
1031 "empty_result": {
1032 "cause": "Impossible WHERE"
1033 } /* empty_result */
1034 } /* join_optimization */
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_optimization": {
1052 "select#": 4,
1053 "steps": [
1054 {
1055 "table_dependencies": [
1056 {
1057 "table": "``",
1058 "row_may_be_null": false,
1059 "map_bit": 0,
1060 "depends_on_map_bits": [
1061 ] /* depends_on_map_bits */
1062 }
1063 ] /* table_dependencies */
1064 },
1065 {
1066 "rows_estimation": [
1067 {
1068 "table": "``",
1069 "table_scan": {
1070 "rows": 0,
1071 "cost": 2.5
1072 } /* table_scan */
1073 }
1074 ] /* rows_estimation */
1075 },
1076 {
1077 "considered_execution_plans": [
1078 {
1079 "plan_prefix": [
1080 ] /* plan_prefix */,
1081 "table": "``",
1082 "best_access_path": {
1083 "considered_access_paths": [
1084 {
1085 "rows_to_scan": 0,
1086 "access_type": "scan",
1087 "resulting_rows": 0,
1088 "cost": 2.5,
1089 "chosen": true
1090 }
1091 ] /* considered_access_paths */
1092 } /* best_access_path */,
1093 "condition_filtering_pct": 100,
1094 "rows_for_plan": 0,
1095 "cost_for_plan": 2.5,
1096 "chosen": true
1097 }
1098 ] /* considered_execution_plans */
1099 },
1100 {
1101 "attaching_conditions_to_tables": {
1102 "original_condition": null,
1103 "attached_conditions_computation": [
1104 ] /* attached_conditions_computation */,
1105 "attached_conditions_summary": [
1106 {
1107 "table": "``",
1108 "attached": null
1109 }
1110 ] /* attached_conditions_summary */
1111 } /* attaching_conditions_to_tables */
1112 },
1113 {
1114 "finalizing_table_conditions": [
1115 ] /* finalizing_table_conditions */
1116 },
1117 {
1118 "refine_plan": [
1119 {
1120 "table": "``"
1121 }
1122 ] /* refine_plan */
1123 }
1124 ] /* steps */
1125 } /* join_optimization */
1126 },
1127 {
1128 "join_execution": {
1129 "steps": [
1130 {
1131 "materialize": {
1132 "select#": 2,
1133 "steps": [
1134 ] /* steps */
1135 } /* materialize */
1136 },
1137 {
1138 "materialize": {
1139 "select#": 3,
1140 "steps": [
1141 ] /* steps */
1142 } /* materialize */
1143 }
1144 ] /* steps */
1145 } /* join_execution */
1146 }
1147 ] /* steps */
1148 } /* subselect_execution */
1149 },
1150 {
1151 "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))",
1152 "condition_value": false
1153 }
1154 ] /* steps */,
1155 "empty_result": {
1156 "cause": "Impossible WHERE noticed after reading const tables"
1157 } /* empty_result */
1158 } /* join_optimization */
1159 },
1160 {
1161 "join_execution": {
1162 "select#": 1,
1163 "steps": [
1164 ] /* steps */
1165 } /* join_execution */
1166 }
1167 ] /* steps */
1168 } 0 0
1169 select (@query:=QUERY)+NULL, (@trace:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
1170 (@query:=QUERY)+NULL (@trace:=TRACE)+NULL
1171 NULL NULL
1172 select length(@trace);
1173 length(@trace)
1174 10810
1175 set @max_mem_size=13307;
1176 set optimizer_trace_max_mem_size=@max_mem_size;
1177 select length(@query)+length(@trace) > @@optimizer_trace_max_mem_size;
1178 length(@query)+length(@trace) > @@optimizer_trace_max_mem_size
1179 0
1180 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));
1181 c
1182 select (@missing_bytes:=missing_bytes_beyond_max_mem_size) from information_schema.OPTIMIZER_TRACE;
1183 (@missing_bytes:=missing_bytes_beyond_max_mem_size)
1184 0
1185 Warnings:
1186 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)'.
1187 select (@query2:=QUERY)+NULL,(@trace2:=TRACE)+NULL from information_schema.OPTIMIZER_TRACE;
1188 (@query2:=QUERY)+NULL (@trace2:=TRACE)+NULL
1189 NULL NULL
1190 select length(@trace2),
1191 (length(@trace2) + @missing_bytes) = length(@trace),
1192 @query2 = @query;
1193 length(@trace2) (length(@trace2) + @missing_bytes) = length(@trace) @query2 = @query
1194 10810 1 1
1195 select length(@query2) + length(@trace2)
1196 between (@@optimizer_trace_max_mem_size-200) and (@@optimizer_trace_max_mem_size+200);
1197 length(@query2) + length(@trace2)
1198 between (@@optimizer_trace_max_mem_size-200) and (@@optimizer_trace_max_mem_size+200)
1199 0
1200 select instr(@trace, @trace2) = 1;
1201 instr(@trace, @trace2) = 1
1202 1
1203 set optimizer_trace_max_mem_size=1;
1204 select 1;
1205 1
1206 1
1207 select * from information_schema.OPTIMIZER_TRACE;
1208 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1209 select 1 299 0
1210 set optimizer_trace_max_mem_size=0;
1211 select 1;
1212 1
1213 1
1214 select * from information_schema.OPTIMIZER_TRACE;
1215 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1216 307 0
1217 set optimizer_trace_max_mem_size=1048576;
1218 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null);
1219 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1220 1 SIMPLE t5 NULL system NULL NULL NULL NULL 1 100.00 NULL
1221 1 SIMPLE t6 NULL ref d d 5 const 1 100.00 Using where; Using index; FirstMatch(t5)
1222 Warnings:
1223 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)))
1224 select * from information_schema.OPTIMIZER_TRACE;
1225 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1226 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null) {
1227 "steps": [
1228 {
1229 "join_preparation": {
1230 "select#": 1,
1231 "steps": [
1232 {
1233 "join_preparation": {
1234 "select#": 2,
1235 "steps": [
1236 {
1237 "expanded_query": "/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null)"
1238 }
1239 ] /* steps */
1240 } /* join_preparation */
1241 },
1242 {
1243 "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))"
1244 },
1245 {
1246 "transformation": {
1247 "select#": 2,
1248 "from": "IN (SELECT)",
1249 "to": "semijoin",
1250 "chosen": true,
1251 "transformation_to_semi_join": {
1252 "subquery_predicate": "(`t5`.`c` + 1) in (/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null))",
1253 "embedded in": "WHERE",
1254 "evaluating_constant_semijoin_conditions": [
1255 ] /* evaluating_constant_semijoin_conditions */,
1256 "semi-join condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))",
1257 "decorrelated_predicates": [
1258 {
1259 "outer": "(`t5`.`c` + 1)",
1260 "inner": "(`t6`.`d` + 1)"
1261 }
1262 ] /* decorrelated_predicates */
1263 } /* transformation_to_semi_join */
1264 } /* transformation */
1265 },
1266 {
1267 "transformations_to_nested_joins": {
1268 "transformations": [
1269 "semijoin"
1270 ] /* transformations */,
1271 "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)))"
1272 } /* transformations_to_nested_joins */
1273 }
1274 ] /* steps */
1275 } /* join_preparation */
1276 },
1277 {
1278 "join_optimization": {
1279 "select#": 1,
1280 "steps": [
1281 {
1282 "condition_processing": {
1283 "condition": "WHERE",
1284 "original_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))",
1285 "steps": [
1286 {
1287 "transformation": "equality_propagation",
1288 "resulting_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1289 },
1290 {
1291 "transformation": "constant_propagation",
1292 "resulting_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1293 },
1294 {
1295 "transformation": "trivial_condition_removal",
1296 "resulting_condition": "((`t6`.`d` is null) and ((`t5`.`c` + 1) = (`t6`.`d` + 1)))"
1297 }
1298 ] /* steps */
1299 } /* condition_processing */
1300 },
1301 {
1302 "substitute_generated_columns": {
1303 } /* substitute_generated_columns */
1304 },
1305 {
1306 "table_dependencies": [
1307 {
1308 "table": "`t5`",
1309 "row_may_be_null": false,
1310 "map_bit": 0,
1311 "depends_on_map_bits": [
1312 ] /* depends_on_map_bits */
1313 },
1314 {
1315 "table": "`t6`",
1316 "row_may_be_null": false,
1317 "map_bit": 1,
1318 "depends_on_map_bits": [
1319 ] /* depends_on_map_bits */
1320 }
1321 ] /* table_dependencies */
1322 },
1323 {
1324 "ref_optimizer_key_uses": [
1325 {
1326 "table": "`t6`",
1327 "field": "d",
1328 "equals": "NULL",
1329 "null_rejecting": false
1330 }
1331 ] /* ref_optimizer_key_uses */
1332 },
1333 {
1334 "pulled_out_semijoin_tables": [
1335 ] /* pulled_out_semijoin_tables */
1336 },
1337 {
1338 "rows_estimation": [
1339 {
1340 "table": "`t5`",
1341 "rows": 1,
1342 "cost": 1,
1343 "table_type": "system",
1344 "empty": false
1345 },
1346 {
1347 "table": "`t6`",
1348 "range_analysis": {
1349 "table_scan": {
1350 "rows": 2,
1351 "cost": 2.80085
1352 } /* table_scan */,
1353 "potential_range_indexes": [
1354 {
1355 "index": "d",
1356 "usable": true,
1357 "key_parts": [
1358 "d"
1359 ] /* key_parts */
1360 }
1361 ] /* potential_range_indexes */,
1362 "best_covering_index_scan": {
1363 "index": "d",
1364 "cost": 0.455814,
1365 "chosen": true
1366 } /* best_covering_index_scan */,
1367 "setup_range_conditions": [
1368 ] /* setup_range_conditions */,
1369 "group_index_range": {
1370 "chosen": false,
1371 "cause": "not_original_query_table"
1372 } /* group_index_range */,
1373 "skip_scan_range": {
1374 "chosen": false,
1375 "cause": "not_single_table"
1376 } /* skip_scan_range */,
1377 "analyzing_range_alternatives": {
1378 "range_scan_alternatives": [
1379 {
1380 "index": "d",
1381 "ranges": [
1382 "d = NULL"
1383 ] /* ranges */,
1384 "index_dives_for_eq_ranges": true,
1385 "rowid_ordered": true,
1386 "using_mrr": false,
1387 "index_only": true,
1388 "in_memory": -1,
1389 "rows": 1,
1390 "cost": 0.36,
1391 "chosen": true
1392 }
1393 ] /* range_scan_alternatives */,
1394 "analyzing_roworder_intersect": {
1395 "usable": false,
1396 "cause": "too_few_roworder_scans"
1397 } /* analyzing_roworder_intersect */
1398 } /* analyzing_range_alternatives */,
1399 "chosen_range_access_summary": {
1400 "range_access_plan": {
1401 "type": "range_scan",
1402 "index": "d",
1403 "rows": 1,
1404 "ranges": [
1405 "d = NULL"
1406 ] /* ranges */
1407 } /* range_access_plan */,
1408 "rows_for_plan": 1,
1409 "cost_for_plan": 0.36,
1410 "chosen": true
1411 } /* chosen_range_access_summary */
1412 } /* range_analysis */
1413 }
1414 ] /* rows_estimation */
1415 },
1416 {
1417 "execution_plan_for_potential_materialization": {
1418 "steps": [
1419 {
1420 "considered_execution_plans": [
1421 {
1422 "plan_prefix": [
1423 ] /* plan_prefix */,
1424 "table": "`t6`",
1425 "best_access_path": {
1426 "considered_access_paths": [
1427 {
1428 "access_type": "ref",
1429 "index": "d",
1430 "rows": 1,
1431 "cost": 0.35,
1432 "chosen": true
1433 },
1434 {
1435 "access_type": "range",
1436 "range_details": {
1437 "used_index": "d"
1438 } /* range_details */,
1439 "chosen": false,
1440 "cause": "heuristic_index_cheaper"
1441 }
1442 ] /* considered_access_paths */
1443 } /* best_access_path */,
1444 "condition_filtering_pct": 100,
1445 "rows_for_plan": 1,
1446 "cost_for_plan": 0.35,
1447 "chosen": true
1448 }
1449 ] /* considered_execution_plans */
1450 }
1451 ] /* steps */
1452 } /* execution_plan_for_potential_materialization */
1453 },
1454 {
1455 "considered_execution_plans": [
1456 {
1457 "plan_prefix": [
1458 "`t5`"
1459 ] /* plan_prefix */,
1460 "table": "`t6`",
1461 "best_access_path": {
1462 "considered_access_paths": [
1463 {
1464 "access_type": "ref",
1465 "index": "d",
1466 "rows": 1,
1467 "cost": 0.35,
1468 "chosen": true
1469 },
1470 {
1471 "access_type": "range",
1472 "range_details": {
1473 "used_index": "d"
1474 } /* range_details */,
1475 "chosen": false,
1476 "cause": "heuristic_index_cheaper"
1477 }
1478 ] /* considered_access_paths */
1479 } /* best_access_path */,
1480 "condition_filtering_pct": 100,
1481 "rows_for_plan": 1,
1482 "cost_for_plan": 0.35,
1483 "semijoin_strategy_choice": [
1484 {
1485 "strategy": "FirstMatch",
1486 "recalculate_access_paths_and_cost": {
1487 "tables": [
1488 ] /* tables */
1489 } /* recalculate_access_paths_and_cost */,
1490 "cost": 0.35,
1491 "rows": 1,
1492 "chosen": true
1493 },
1494 {
1495 "strategy": "MaterializeLookup",
1496 "cost": 1.55,
1497 "rows": 1,
1498 "duplicate_tables_left": false,
1499 "chosen": false
1500 },
1501 {
1502 "strategy": "DuplicatesWeedout",
1503 "cost": 1.55,
1504 "rows": 1,
1505 "duplicate_tables_left": false,
1506 "chosen": false
1507 }
1508 ] /* semijoin_strategy_choice */,
1509 "chosen": true
1510 },
1511 {
1512 "final_semijoin_strategy": "FirstMatch",
1513 "recalculate_access_paths_and_cost": {
1514 "tables": [
1515 ] /* tables */
1516 } /* recalculate_access_paths_and_cost */
1517 }
1518 ] /* considered_execution_plans */
1519 },
1520 {
1521 "attaching_conditions_to_tables": {
1522 "original_condition": "((`t6`.`d` is null) and ((NULL + 1) = (`t6`.`d` + 1)))",
1523 "attached_conditions_computation": [
1524 ] /* attached_conditions_computation */,
1525 "attached_conditions_summary": [
1526 {
1527 "table": "`t6`",
1528 "attached": "((`t6`.`d` is null) and ((NULL + 1) = (`t6`.`d` + 1)))"
1529 }
1530 ] /* attached_conditions_summary */
1531 } /* attaching_conditions_to_tables */
1532 },
1533 {
1534 "finalizing_table_conditions": [
1535 {
1536 "table": "`t6`",
1537 "original_table_condition": "((`t6`.`d` is null) and ((NULL + 1) = (`t6`.`d` + 1)))",
1538 "final_table_condition ": "((`t6`.`d` is null) and (<cache>((NULL + 1)) = (`t6`.`d` + 1)))"
1539 }
1540 ] /* finalizing_table_conditions */
1541 },
1542 {
1543 "refine_plan": [
1544 {
1545 "table": "`t6`"
1546 }
1547 ] /* refine_plan */
1548 }
1549 ] /* steps */
1550 } /* join_optimization */
1551 },
1552 {
1553 "join_explain": {
1554 "select#": 1,
1555 "steps": [
1556 ] /* steps */
1557 } /* join_explain */
1558 }
1559 ] /* steps */
1560 } 0 0
1561 set @old_opt_switch=@@optimizer_switch;
1562 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null);
1563 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1564 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1565 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL NULL Not optimized, outer query is empty
1566 Warnings:
1567 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)))))
1568 select * from information_schema.OPTIMIZER_TRACE;
1569 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1570 explain SELECT c FROM t5 where c+1 in (select d+1 from t6 where d is null) {
1571 "steps": [
1572 {
1573 "join_preparation": {
1574 "select#": 1,
1575 "steps": [
1576 {
1577 "join_preparation": {
1578 "select#": 2,
1579 "steps": [
1580 {
1581 "expanded_query": "/* select#2 */ select (`t6`.`d` + 1) from `t6` where (`t6`.`d` is null)"
1582 },
1583 {
1584 "transformation": {
1585 "select#": 2,
1586 "from": "IN (SELECT)",
1587 "to": "EXISTS (CORRELATED SELECT)",
1588 "chosen": true,
1589 "evaluating_constant_where_conditions": [
1590 ] /* evaluating_constant_where_conditions */
1591 } /* transformation */
1592 }
1593 ] /* steps */
1594 } /* join_preparation */
1595 },
1596 {
1597 "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)))))"
1598 }
1599 ] /* steps */
1600 } /* join_preparation */
1601 },
1602 {
1603 "join_optimization": {
1604 "select#": 1,
1605 "steps": [
1606 {
1607 "condition_processing": {
1608 "condition": "WHERE",
1609 "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)))))",
1610 "steps": [
1611 {
1612 "transformation": "equality_propagation",
1613 "subselect_evaluation": [
1614 ] /* subselect_evaluation */,
1615 "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)))))"
1616 },
1617 {
1618 "transformation": "constant_propagation",
1619 "subselect_evaluation": [
1620 ] /* subselect_evaluation */,
1621 "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)))))"
1622 },
1623 {
1624 "transformation": "trivial_condition_removal",
1625 "subselect_evaluation": [
1626 ] /* subselect_evaluation */,
1627 "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)))))"
1628 }
1629 ] /* steps */
1630 } /* condition_processing */
1631 },
1632 {
1633 "substitute_generated_columns": {
1634 } /* substitute_generated_columns */
1635 },
1636 {
1637 "table_dependencies": [
1638 {
1639 "table": "`t5`",
1640 "row_may_be_null": false,
1641 "map_bit": 0,
1642 "depends_on_map_bits": [
1643 ] /* depends_on_map_bits */
1644 }
1645 ] /* table_dependencies */
1646 },
1647 {
1648 "ref_optimizer_key_uses": [
1649 ] /* ref_optimizer_key_uses */
1650 },
1651 {
1652 "rows_estimation": [
1653 {
1654 "table": "`t5`",
1655 "rows": 1,
1656 "cost": 1,
1657 "table_type": "system",
1658 "empty": false
1659 }
1660 ] /* rows_estimation */
1661 },
1662 {
1663 "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)))))",
1664 "condition_value": false
1665 }
1666 ] /* steps */,
1667 "empty_result": {
1668 "cause": "Impossible WHERE noticed after reading const tables"
1669 } /* empty_result */
1670 } /* join_optimization */
1671 },
1672 {
1673 "join_explain": {
1674 "select#": 1,
1675 "steps": [
1676 {
1677 "join_explain": {
1678 "select#": 2,
1679 "steps": [
1680 ] /* steps */
1681 } /* join_explain */
1682 }
1683 ] /* steps */
1684 } /* join_explain */
1685 }
1686 ] /* steps */
1687 } 0 0
1688 set optimizer_switch=@old_opt_switch;
1689 CREATE TABLE t1 (s1 CHAR(5),
1690 s2 CHAR(5)) CHARSET utf8mb4;
1691 INSERT INTO t1 VALUES ('z','?'),('y','!');
1692 explain select * from t1 where s1 > any (select s2 from t1);
1693 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1694 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
1695 2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
1696 Warnings:
1697 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`)))
1698 select * from information_schema.OPTIMIZER_TRACE;
1699 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1700 explain select * from t1 where s1 > any (select s2 from t1) {
1701 "steps": [
1702 {
1703 "join_preparation": {
1704 "select#": 1,
1705 "steps": [
1706 {
1707 "join_preparation": {
1708 "select#": 2,
1709 "steps": [
1710 {
1711 "expanded_query": "/* select#2 */ select `t1`.`s2` from `t1`"
1712 },
1713 {
1714 "transformation": {
1715 "select#": 2,
1716 "from": "> ALL/ANY (SELECT)",
1717 "to": "SELECT(MIN)",
1718 "chosen": true
1719 } /* transformation */
1720 }
1721 ] /* steps */
1722 } /* join_preparation */
1723 },
1724 {
1725 "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`)))"
1726 }
1727 ] /* steps */
1728 } /* join_preparation */
1729 },
1730 {
1731 "join_optimization": {
1732 "select#": 1,
1733 "steps": [
1734 {
1735 "condition_processing": {
1736 "condition": "WHERE",
1737 "original_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
1738 "steps": [
1739 {
1740 "transformation": "equality_propagation",
1741 "subselect_evaluation": [
1742 ] /* subselect_evaluation */,
1743 "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1744 },
1745 {
1746 "transformation": "constant_propagation",
1747 "subselect_evaluation": [
1748 ] /* subselect_evaluation */,
1749 "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1750 },
1751 {
1752 "transformation": "trivial_condition_removal",
1753 "subselect_evaluation": [
1754 ] /* subselect_evaluation */,
1755 "resulting_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1756 }
1757 ] /* steps */
1758 } /* condition_processing */
1759 },
1760 {
1761 "substitute_generated_columns": {
1762 } /* substitute_generated_columns */
1763 },
1764 {
1765 "table_dependencies": [
1766 {
1767 "table": "`t1`",
1768 "row_may_be_null": false,
1769 "map_bit": 0,
1770 "depends_on_map_bits": [
1771 ] /* depends_on_map_bits */
1772 }
1773 ] /* table_dependencies */
1774 },
1775 {
1776 "ref_optimizer_key_uses": [
1777 ] /* ref_optimizer_key_uses */
1778 },
1779 {
1780 "rows_estimation": [
1781 {
1782 "table": "`t1`",
1783 "table_scan": {
1784 "rows": 2,
1785 "cost": 0.505005
1786 } /* table_scan */
1787 }
1788 ] /* rows_estimation */
1789 },
1790 {
1791 "considered_execution_plans": [
1792 {
1793 "plan_prefix": [
1794 ] /* plan_prefix */,
1795 "table": "`t1`",
1796 "best_access_path": {
1797 "considered_access_paths": [
1798 {
1799 "rows_to_scan": 2,
1800 "filtering_effect": [
1801 ] /* filtering_effect */,
1802 "final_filtering_effect": 1,
1803 "access_type": "scan",
1804 "resulting_rows": 2,
1805 "cost": 0.705005,
1806 "chosen": true
1807 }
1808 ] /* considered_access_paths */
1809 } /* best_access_path */,
1810 "condition_filtering_pct": 50,
1811 "rows_for_plan": 1,
1812 "cost_for_plan": 0.705005,
1813 "chosen": true
1814 }
1815 ] /* considered_execution_plans */
1816 },
1817 {
1818 "attaching_conditions_to_tables": {
1819 "original_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
1820 "attached_conditions_computation": [
1821 ] /* attached_conditions_computation */,
1822 "attached_conditions_summary": [
1823 {
1824 "table": "`t1`",
1825 "attached": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1826 }
1827 ] /* attached_conditions_summary */
1828 } /* attaching_conditions_to_tables */
1829 },
1830 {
1831 "finalizing_table_conditions": [
1832 {
1833 "table": "`t1`",
1834 "original_table_condition": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))",
1835 "final_table_condition ": "<nop>((`t1`.`s1` > (/* select#2 */ select min(`t1`.`s2`) from `t1`)))"
1836 }
1837 ] /* finalizing_table_conditions */
1838 },
1839 {
1840 "refine_plan": [
1841 {
1842 "table": "`t1`"
1843 }
1844 ] /* refine_plan */
1845 }
1846 ] /* steps */
1847 } /* join_optimization */
1848 },
1849 {
1850 "join_optimization": {
1851 "select#": 2,
1852 "steps": [
1853 {
1854 "table_dependencies": [
1855 {
1856 "table": "`t1`",
1857 "row_may_be_null": false,
1858 "map_bit": 0,
1859 "depends_on_map_bits": [
1860 ] /* depends_on_map_bits */
1861 }
1862 ] /* table_dependencies */
1863 },
1864 {
1865 "rows_estimation": [
1866 {
1867 "table": "`t1`",
1868 "table_scan": {
1869 "rows": 2,
1870 "cost": 0.505005
1871 } /* table_scan */
1872 }
1873 ] /* rows_estimation */
1874 },
1875 {
1876 "considered_execution_plans": [
1877 {
1878 "plan_prefix": [
1879 ] /* plan_prefix */,
1880 "table": "`t1`",
1881 "best_access_path": {
1882 "considered_access_paths": [
1883 {
1884 "rows_to_scan": 2,
1885 "access_type": "scan",
1886 "resulting_rows": 2,
1887 "cost": 0.705005,
1888 "chosen": true
1889 }
1890 ] /* considered_access_paths */
1891 } /* best_access_path */,
1892 "condition_filtering_pct": 100,
1893 "rows_for_plan": 2,
1894 "cost_for_plan": 0.705005,
1895 "chosen": true
1896 }
1897 ] /* considered_execution_plans */
1898 },
1899 {
1900 "attaching_conditions_to_tables": {
1901 "original_condition": null,
1902 "attached_conditions_computation": [
1903 ] /* attached_conditions_computation */,
1904 "attached_conditions_summary": [
1905 {
1906 "table": "`t1`",
1907 "attached": null
1908 }
1909 ] /* attached_conditions_summary */
1910 } /* attaching_conditions_to_tables */
1911 },
1912 {
1913 "optimizing_distinct_group_by_order_by": {
1914 } /* optimizing_distinct_group_by_order_by */
1915 },
1916 {
1917 "finalizing_table_conditions": [
1918 ] /* finalizing_table_conditions */
1919 },
1920 {
1921 "refine_plan": [
1922 {
1923 "table": "`t1`"
1924 }
1925 ] /* refine_plan */
1926 },
1927 {
1928 "considering_tmp_tables": [
1929 ] /* considering_tmp_tables */
1930 }
1931 ] /* steps */
1932 } /* join_optimization */
1933 },
1934 {
1935 "join_explain": {
1936 "select#": 1,
1937 "steps": [
1938 {
1939 "join_explain": {
1940 "select#": 2,
1941 "steps": [
1942 ] /* steps */
1943 } /* join_explain */
1944 }
1945 ] /* steps */
1946 } /* join_explain */
1947 }
1948 ] /* steps */
1949 } 0 0
1950 explain select * from t1 where s1 > any (select max(s2) from t1);
1951 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1952 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
1953 2 SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
1954 Warnings:
1955 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`)))
1956 select * from information_schema.OPTIMIZER_TRACE;
1957 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
1958 explain select * from t1 where s1 > any (select max(s2) from t1) {
1959 "steps": [
1960 {
1961 "join_preparation": {
1962 "select#": 1,
1963 "steps": [
1964 {
1965 "join_preparation": {
1966 "select#": 2,
1967 "steps": [
1968 {
1969 "expanded_query": "/* select#2 */ select max(`t1`.`s2`) from `t1`"
1970 },
1971 {
1972 "transformation": {
1973 "select#": 2,
1974 "from": "> ALL/ANY (SELECT)",
1975 "to": "MIN (SELECT)",
1976 "chosen": true
1977 } /* transformation */
1978 }
1979 ] /* steps */
1980 } /* join_preparation */
1981 },
1982 {
1983 "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`)))"
1984 }
1985 ] /* steps */
1986 } /* join_preparation */
1987 },
1988 {
1989 "join_optimization": {
1990 "select#": 1,
1991 "steps": [
1992 {
1993 "condition_processing": {
1994 "condition": "WHERE",
1995 "original_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
1996 "steps": [
1997 {
1998 "transformation": "equality_propagation",
1999 "subselect_evaluation": [
2000 ] /* subselect_evaluation */,
2001 "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2002 },
2003 {
2004 "transformation": "constant_propagation",
2005 "subselect_evaluation": [
2006 ] /* subselect_evaluation */,
2007 "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2008 },
2009 {
2010 "transformation": "trivial_condition_removal",
2011 "subselect_evaluation": [
2012 ] /* subselect_evaluation */,
2013 "resulting_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2014 }
2015 ] /* steps */
2016 } /* condition_processing */
2017 },
2018 {
2019 "substitute_generated_columns": {
2020 } /* substitute_generated_columns */
2021 },
2022 {
2023 "table_dependencies": [
2024 {
2025 "table": "`t1`",
2026 "row_may_be_null": false,
2027 "map_bit": 0,
2028 "depends_on_map_bits": [
2029 ] /* depends_on_map_bits */
2030 }
2031 ] /* table_dependencies */
2032 },
2033 {
2034 "ref_optimizer_key_uses": [
2035 ] /* ref_optimizer_key_uses */
2036 },
2037 {
2038 "rows_estimation": [
2039 {
2040 "table": "`t1`",
2041 "table_scan": {
2042 "rows": 2,
2043 "cost": 0.505005
2044 } /* table_scan */
2045 }
2046 ] /* rows_estimation */
2047 },
2048 {
2049 "considered_execution_plans": [
2050 {
2051 "plan_prefix": [
2052 ] /* plan_prefix */,
2053 "table": "`t1`",
2054 "best_access_path": {
2055 "considered_access_paths": [
2056 {
2057 "rows_to_scan": 2,
2058 "filtering_effect": [
2059 ] /* filtering_effect */,
2060 "final_filtering_effect": 1,
2061 "access_type": "scan",
2062 "resulting_rows": 2,
2063 "cost": 0.705005,
2064 "chosen": true
2065 }
2066 ] /* considered_access_paths */
2067 } /* best_access_path */,
2068 "condition_filtering_pct": 50,
2069 "rows_for_plan": 1,
2070 "cost_for_plan": 0.705005,
2071 "chosen": true
2072 }
2073 ] /* considered_execution_plans */
2074 },
2075 {
2076 "attaching_conditions_to_tables": {
2077 "original_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2078 "attached_conditions_computation": [
2079 ] /* attached_conditions_computation */,
2080 "attached_conditions_summary": [
2081 {
2082 "table": "`t1`",
2083 "attached": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2084 }
2085 ] /* attached_conditions_summary */
2086 } /* attaching_conditions_to_tables */
2087 },
2088 {
2089 "finalizing_table_conditions": [
2090 {
2091 "table": "`t1`",
2092 "original_table_condition": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))",
2093 "final_table_condition ": "<nop>((`t1`.`s1` > <min>(/* select#2 */ select max(`t1`.`s2`) from `t1`)))"
2094 }
2095 ] /* finalizing_table_conditions */
2096 },
2097 {
2098 "refine_plan": [
2099 {
2100 "table": "`t1`"
2101 }
2102 ] /* refine_plan */
2103 }
2104 ] /* steps */
2105 } /* join_optimization */
2106 },
2107 {
2108 "join_optimization": {
2109 "select#": 2,
2110 "steps": [
2111 {
2112 "table_dependencies": [
2113 {
2114 "table": "`t1`",
2115 "row_may_be_null": false,
2116 "map_bit": 0,
2117 "depends_on_map_bits": [
2118 ] /* depends_on_map_bits */
2119 }
2120 ] /* table_dependencies */
2121 },
2122 {
2123 "rows_estimation": [
2124 {
2125 "table": "`t1`",
2126 "table_scan": {
2127 "rows": 2,
2128 "cost": 0.505005
2129 } /* table_scan */
2130 }
2131 ] /* rows_estimation */
2132 },
2133 {
2134 "considered_execution_plans": [
2135 {
2136 "plan_prefix": [
2137 ] /* plan_prefix */,
2138 "table": "`t1`",
2139 "best_access_path": {
2140 "considered_access_paths": [
2141 {
2142 "rows_to_scan": 2,
2143 "access_type": "scan",
2144 "resulting_rows": 2,
2145 "cost": 0.705005,
2146 "chosen": true
2147 }
2148 ] /* considered_access_paths */
2149 } /* best_access_path */,
2150 "condition_filtering_pct": 100,
2151 "rows_for_plan": 2,
2152 "cost_for_plan": 0.705005,
2153 "chosen": true
2154 }
2155 ] /* considered_execution_plans */
2156 },
2157 {
2158 "attaching_conditions_to_tables": {
2159 "original_condition": null,
2160 "attached_conditions_computation": [
2161 ] /* attached_conditions_computation */,
2162 "attached_conditions_summary": [
2163 {
2164 "table": "`t1`",
2165 "attached": null
2166 }
2167 ] /* attached_conditions_summary */
2168 } /* attaching_conditions_to_tables */
2169 },
2170 {
2171 "optimizing_distinct_group_by_order_by": {
2172 } /* optimizing_distinct_group_by_order_by */
2173 },
2174 {
2175 "finalizing_table_conditions": [
2176 ] /* finalizing_table_conditions */
2177 },
2178 {
2179 "refine_plan": [
2180 {
2181 "table": "`t1`"
2182 }
2183 ] /* refine_plan */
2184 },
2185 {
2186 "considering_tmp_tables": [
2187 ] /* considering_tmp_tables */
2188 }
2189 ] /* steps */
2190 } /* join_optimization */
2191 },
2192 {
2193 "join_explain": {
2194 "select#": 1,
2195 "steps": [
2196 {
2197 "join_explain": {
2198 "select#": 2,
2199 "steps": [
2200 ] /* steps */
2201 } /* join_explain */
2202 }
2203 ] /* steps */
2204 } /* join_explain */
2205 }
2206 ] /* steps */
2207 } 0 0
2208 explain select * from t1 where s1 in (select s2 from t1);
2209 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2210 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where
2211 2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
2212 Warnings:
2213 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`)))
2214 select * from information_schema.OPTIMIZER_TRACE;
2215 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2216 explain select * from t1 where s1 in (select s2 from t1) {
2217 "steps": [
2218 {
2219 "join_preparation": {
2220 "select#": 1,
2221 "steps": [
2222 {
2223 "join_preparation": {
2224 "select#": 2,
2225 "steps": [
2226 {
2227 "expanded_query": "/* select#2 */ select `t1`.`s2` from `t1`"
2228 },
2229 {
2230 "transformation": {
2231 "select#": 2,
2232 "from": "IN (SELECT)",
2233 "to": "EXISTS (CORRELATED SELECT)",
2234 "chosen": true,
2235 "evaluating_constant_where_conditions": [
2236 ] /* evaluating_constant_where_conditions */
2237 } /* transformation */
2238 }
2239 ] /* steps */
2240 } /* join_preparation */
2241 },
2242 {
2243 "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`)))"
2244 }
2245 ] /* steps */
2246 } /* join_preparation */
2247 },
2248 {
2249 "join_optimization": {
2250 "select#": 1,
2251 "steps": [
2252 {
2253 "condition_processing": {
2254 "condition": "WHERE",
2255 "original_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2256 "steps": [
2257 {
2258 "transformation": "equality_propagation",
2259 "subselect_evaluation": [
2260 ] /* subselect_evaluation */,
2261 "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2262 },
2263 {
2264 "transformation": "constant_propagation",
2265 "subselect_evaluation": [
2266 ] /* subselect_evaluation */,
2267 "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2268 },
2269 {
2270 "transformation": "trivial_condition_removal",
2271 "subselect_evaluation": [
2272 ] /* subselect_evaluation */,
2273 "resulting_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2274 }
2275 ] /* steps */
2276 } /* condition_processing */
2277 },
2278 {
2279 "substitute_generated_columns": {
2280 } /* substitute_generated_columns */
2281 },
2282 {
2283 "table_dependencies": [
2284 {
2285 "table": "`t1`",
2286 "row_may_be_null": false,
2287 "map_bit": 0,
2288 "depends_on_map_bits": [
2289 ] /* depends_on_map_bits */
2290 }
2291 ] /* table_dependencies */
2292 },
2293 {
2294 "ref_optimizer_key_uses": [
2295 ] /* ref_optimizer_key_uses */
2296 },
2297 {
2298 "rows_estimation": [
2299 {
2300 "table": "`t1`",
2301 "table_scan": {
2302 "rows": 2,
2303 "cost": 0.505005
2304 } /* table_scan */
2305 }
2306 ] /* rows_estimation */
2307 },
2308 {
2309 "considered_execution_plans": [
2310 {
2311 "plan_prefix": [
2312 ] /* plan_prefix */,
2313 "table": "`t1`",
2314 "best_access_path": {
2315 "considered_access_paths": [
2316 {
2317 "rows_to_scan": 2,
2318 "filtering_effect": [
2319 ] /* filtering_effect */,
2320 "final_filtering_effect": 1,
2321 "access_type": "scan",
2322 "resulting_rows": 2,
2323 "cost": 0.705005,
2324 "chosen": true
2325 }
2326 ] /* considered_access_paths */
2327 } /* best_access_path */,
2328 "condition_filtering_pct": 100,
2329 "rows_for_plan": 2,
2330 "cost_for_plan": 0.705005,
2331 "chosen": true
2332 }
2333 ] /* considered_execution_plans */
2334 },
2335 {
2336 "attaching_conditions_to_tables": {
2337 "original_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2338 "attached_conditions_computation": [
2339 ] /* attached_conditions_computation */,
2340 "attached_conditions_summary": [
2341 {
2342 "table": "`t1`",
2343 "attached": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2344 }
2345 ] /* attached_conditions_summary */
2346 } /* attaching_conditions_to_tables */
2347 },
2348 {
2349 "finalizing_table_conditions": [
2350 {
2351 "table": "`t1`",
2352 "original_table_condition": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))",
2353 "final_table_condition ": "<in_optimizer>(`t1`.`s1`,<exists>(/* select#2 */ select `t1`.`s2` from `t1` where (<cache>(`t1`.`s1`) = `t1`.`s2`)))"
2354 }
2355 ] /* finalizing_table_conditions */
2356 },
2357 {
2358 "refine_plan": [
2359 {
2360 "table": "`t1`"
2361 }
2362 ] /* refine_plan */
2363 }
2364 ] /* steps */
2365 } /* join_optimization */
2366 },
2367 {
2368 "join_optimization": {
2369 "select#": 2,
2370 "steps": [
2371 {
2372 "condition_processing": {
2373 "condition": "WHERE",
2374 "original_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2375 "steps": [
2376 {
2377 "transformation": "equality_propagation",
2378 "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2379 },
2380 {
2381 "transformation": "constant_propagation",
2382 "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2383 },
2384 {
2385 "transformation": "trivial_condition_removal",
2386 "resulting_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2387 }
2388 ] /* steps */
2389 } /* condition_processing */
2390 },
2391 {
2392 "substitute_generated_columns": {
2393 } /* substitute_generated_columns */
2394 },
2395 {
2396 "table_dependencies": [
2397 {
2398 "table": "`t1`",
2399 "row_may_be_null": false,
2400 "map_bit": 0,
2401 "depends_on_map_bits": [
2402 ] /* depends_on_map_bits */
2403 }
2404 ] /* table_dependencies */
2405 },
2406 {
2407 "ref_optimizer_key_uses": [
2408 ] /* ref_optimizer_key_uses */
2409 },
2410 {
2411 "rows_estimation": [
2412 {
2413 "table": "`t1`",
2414 "table_scan": {
2415 "rows": 2,
2416 "cost": 0.505005
2417 } /* table_scan */
2418 }
2419 ] /* rows_estimation */
2420 },
2421 {
2422 "considered_execution_plans": [
2423 {
2424 "plan_prefix": [
2425 ] /* plan_prefix */,
2426 "table": "`t1`",
2427 "best_access_path": {
2428 "considered_access_paths": [
2429 {
2430 "rows_to_scan": 2,
2431 "filtering_effect": [
2432 ] /* filtering_effect */,
2433 "final_filtering_effect": 1,
2434 "access_type": "scan",
2435 "resulting_rows": 2,
2436 "cost": 0.705005,
2437 "chosen": true
2438 }
2439 ] /* considered_access_paths */
2440 } /* best_access_path */,
2441 "condition_filtering_pct": 50,
2442 "rows_for_plan": 1,
2443 "cost_for_plan": 0.705005,
2444 "chosen": true
2445 }
2446 ] /* considered_execution_plans */
2447 },
2448 {
2449 "attaching_conditions_to_tables": {
2450 "original_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2451 "attached_conditions_computation": [
2452 ] /* attached_conditions_computation */,
2453 "attached_conditions_summary": [
2454 {
2455 "table": "`t1`",
2456 "attached": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2457 }
2458 ] /* attached_conditions_summary */
2459 } /* attaching_conditions_to_tables */
2460 },
2461 {
2462 "finalizing_table_conditions": [
2463 {
2464 "table": "`t1`",
2465 "original_table_condition": "(<cache>(`t1`.`s1`) = `t1`.`s2`)",
2466 "final_table_condition ": "(<cache>(`t1`.`s1`) = `t1`.`s2`)"
2467 }
2468 ] /* finalizing_table_conditions */
2469 },
2470 {
2471 "refine_plan": [
2472 {
2473 "table": "`t1`"
2474 }
2475 ] /* refine_plan */
2476 }
2477 ] /* steps */
2478 } /* join_optimization */
2479 },
2480 {
2481 "join_explain": {
2482 "select#": 1,
2483 "steps": [
2484 {
2485 "join_explain": {
2486 "select#": 2,
2487 "steps": [
2488 ] /* steps */
2489 } /* join_explain */
2490 }
2491 ] /* steps */
2492 } /* join_explain */
2493 }
2494 ] /* steps */
2495 } 0 0
2496 explain select * from t1 where (s1,s2) in (select s2,s1 from t1);
2497 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2498 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 2 100.00 Using where
2499 2 DEPENDENT SUBQUERY t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
2500 Warnings:
2501 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`))))
2502 select * from information_schema.OPTIMIZER_TRACE;
2503 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2504 explain select * from t1 where (s1,s2) in (select s2,s1 from t1) {
2505 "steps": [
2506 {
2507 "join_preparation": {
2508 "select#": 1,
2509 "steps": [
2510 {
2511 "join_preparation": {
2512 "select#": 2,
2513 "steps": [
2514 {
2515 "expanded_query": "/* select#2 */ select `t1`.`s2`,`t1`.`s1` from `t1`"
2516 },
2517 {
2518 "transformation": {
2519 "select#": 2,
2520 "from": "IN (SELECT)",
2521 "to": "EXISTS (CORRELATED SELECT)",
2522 "chosen": true,
2523 "evaluating_constant_where_conditions": [
2524 ] /* evaluating_constant_where_conditions */
2525 } /* transformation */
2526 }
2527 ] /* steps */
2528 } /* join_preparation */
2529 },
2530 {
2531 "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`))))"
2532 }
2533 ] /* steps */
2534 } /* join_preparation */
2535 },
2536 {
2537 "join_optimization": {
2538 "select#": 1,
2539 "steps": [
2540 {
2541 "condition_processing": {
2542 "condition": "WHERE",
2543 "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`))))",
2544 "steps": [
2545 {
2546 "transformation": "equality_propagation",
2547 "subselect_evaluation": [
2548 ] /* subselect_evaluation */,
2549 "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`))))"
2550 },
2551 {
2552 "transformation": "constant_propagation",
2553 "subselect_evaluation": [
2554 ] /* subselect_evaluation */,
2555 "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`))))"
2556 },
2557 {
2558 "transformation": "trivial_condition_removal",
2559 "subselect_evaluation": [
2560 ] /* subselect_evaluation */,
2561 "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`))))"
2562 }
2563 ] /* steps */
2564 } /* condition_processing */
2565 },
2566 {
2567 "substitute_generated_columns": {
2568 } /* substitute_generated_columns */
2569 },
2570 {
2571 "table_dependencies": [
2572 {
2573 "table": "`t1`",
2574 "row_may_be_null": false,
2575 "map_bit": 0,
2576 "depends_on_map_bits": [
2577 ] /* depends_on_map_bits */
2578 }
2579 ] /* table_dependencies */
2580 },
2581 {
2582 "ref_optimizer_key_uses": [
2583 ] /* ref_optimizer_key_uses */
2584 },
2585 {
2586 "rows_estimation": [
2587 {
2588 "table": "`t1`",
2589 "table_scan": {
2590 "rows": 2,
2591 "cost": 0.505005
2592 } /* table_scan */
2593 }
2594 ] /* rows_estimation */
2595 },
2596 {
2597 "considered_execution_plans": [
2598 {
2599 "plan_prefix": [
2600 ] /* plan_prefix */,
2601 "table": "`t1`",
2602 "best_access_path": {
2603 "considered_access_paths": [
2604 {
2605 "rows_to_scan": 2,
2606 "filtering_effect": [
2607 ] /* filtering_effect */,
2608 "final_filtering_effect": 1,
2609 "access_type": "scan",
2610 "resulting_rows": 2,
2611 "cost": 0.705005,
2612 "chosen": true
2613 }
2614 ] /* considered_access_paths */
2615 } /* best_access_path */,
2616 "condition_filtering_pct": 100,
2617 "rows_for_plan": 2,
2618 "cost_for_plan": 0.705005,
2619 "chosen": true
2620 }
2621 ] /* considered_execution_plans */
2622 },
2623 {
2624 "attaching_conditions_to_tables": {
2625 "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`))))",
2626 "attached_conditions_computation": [
2627 ] /* attached_conditions_computation */,
2628 "attached_conditions_summary": [
2629 {
2630 "table": "`t1`",
2631 "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`))))"
2632 }
2633 ] /* attached_conditions_summary */
2634 } /* attaching_conditions_to_tables */
2635 },
2636 {
2637 "finalizing_table_conditions": [
2638 {
2639 "table": "`t1`",
2640 "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`))))",
2641 "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`))))"
2642 }
2643 ] /* finalizing_table_conditions */
2644 },
2645 {
2646 "refine_plan": [
2647 {
2648 "table": "`t1`"
2649 }
2650 ] /* refine_plan */
2651 }
2652 ] /* steps */
2653 } /* join_optimization */
2654 },
2655 {
2656 "join_optimization": {
2657 "select#": 2,
2658 "steps": [
2659 {
2660 "condition_processing": {
2661 "condition": "WHERE",
2662 "original_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2663 "steps": [
2664 {
2665 "transformation": "equality_propagation",
2666 "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2667 },
2668 {
2669 "transformation": "constant_propagation",
2670 "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2671 },
2672 {
2673 "transformation": "trivial_condition_removal",
2674 "resulting_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2675 }
2676 ] /* steps */
2677 } /* condition_processing */
2678 },
2679 {
2680 "substitute_generated_columns": {
2681 } /* substitute_generated_columns */
2682 },
2683 {
2684 "table_dependencies": [
2685 {
2686 "table": "`t1`",
2687 "row_may_be_null": false,
2688 "map_bit": 0,
2689 "depends_on_map_bits": [
2690 ] /* depends_on_map_bits */
2691 }
2692 ] /* table_dependencies */
2693 },
2694 {
2695 "ref_optimizer_key_uses": [
2696 ] /* ref_optimizer_key_uses */
2697 },
2698 {
2699 "rows_estimation": [
2700 {
2701 "table": "`t1`",
2702 "table_scan": {
2703 "rows": 2,
2704 "cost": 0.505005
2705 } /* table_scan */
2706 }
2707 ] /* rows_estimation */
2708 },
2709 {
2710 "considered_execution_plans": [
2711 {
2712 "plan_prefix": [
2713 ] /* plan_prefix */,
2714 "table": "`t1`",
2715 "best_access_path": {
2716 "considered_access_paths": [
2717 {
2718 "rows_to_scan": 2,
2719 "filtering_effect": [
2720 ] /* filtering_effect */,
2721 "final_filtering_effect": 1,
2722 "access_type": "scan",
2723 "resulting_rows": 2,
2724 "cost": 0.705005,
2725 "chosen": true
2726 }
2727 ] /* considered_access_paths */
2728 } /* best_access_path */,
2729 "condition_filtering_pct": 50,
2730 "rows_for_plan": 1,
2731 "cost_for_plan": 0.705005,
2732 "chosen": true
2733 }
2734 ] /* considered_execution_plans */
2735 },
2736 {
2737 "attaching_conditions_to_tables": {
2738 "original_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2739 "attached_conditions_computation": [
2740 ] /* attached_conditions_computation */,
2741 "attached_conditions_summary": [
2742 {
2743 "table": "`t1`",
2744 "attached": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2745 }
2746 ] /* attached_conditions_summary */
2747 } /* attaching_conditions_to_tables */
2748 },
2749 {
2750 "finalizing_table_conditions": [
2751 {
2752 "table": "`t1`",
2753 "original_table_condition": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))",
2754 "final_table_condition ": "((<cache>(`t1`.`s1`) = `t1`.`s2`) and (<cache>(`t1`.`s2`) = `t1`.`s1`))"
2755 }
2756 ] /* finalizing_table_conditions */
2757 },
2758 {
2759 "refine_plan": [
2760 {
2761 "table": "`t1`"
2762 }
2763 ] /* refine_plan */
2764 }
2765 ] /* steps */
2766 } /* join_optimization */
2767 },
2768 {
2769 "join_explain": {
2770 "select#": 1,
2771 "steps": [
2772 {
2773 "join_explain": {
2774 "select#": 2,
2775 "steps": [
2776 ] /* steps */
2777 } /* join_explain */
2778 }
2779 ] /* steps */
2780 } /* join_explain */
2781 }
2782 ] /* steps */
2783 } 0 0
2784 set optimizer_switch=@old_opt_switch;
2785 drop table t1;
2786 create table t1(a int);
2787 create table t2(a int);
2788 insert into t1 values(1),(2),(3);
2789 insert into t2 values(1),(2);
2790 set @@session.optimizer_prune_level=0;
2791 explain select * from t1,t2;
2792 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2793 1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
2794 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
2795 Warnings:
2796 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2`
2797 select * from information_schema.OPTIMIZER_TRACE;
2798 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2799 explain select * from t1,t2 {
2800 "steps": [
2801 {
2802 "join_preparation": {
2803 "select#": 1,
2804 "steps": [
2805 {
2806 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
2807 }
2808 ] /* steps */
2809 } /* join_preparation */
2810 },
2811 {
2812 "join_optimization": {
2813 "select#": 1,
2814 "steps": [
2815 {
2816 "table_dependencies": [
2817 {
2818 "table": "`t1`",
2819 "row_may_be_null": false,
2820 "map_bit": 0,
2821 "depends_on_map_bits": [
2822 ] /* depends_on_map_bits */
2823 },
2824 {
2825 "table": "`t2`",
2826 "row_may_be_null": false,
2827 "map_bit": 1,
2828 "depends_on_map_bits": [
2829 ] /* depends_on_map_bits */
2830 }
2831 ] /* table_dependencies */
2832 },
2833 {
2834 "rows_estimation": [
2835 {
2836 "table": "`t1`",
2837 "table_scan": {
2838 "rows": 3,
2839 "cost": 0.501282
2840 } /* table_scan */
2841 },
2842 {
2843 "table": "`t2`",
2844 "table_scan": {
2845 "rows": 2,
2846 "cost": 0.500854
2847 } /* table_scan */
2848 }
2849 ] /* rows_estimation */
2850 },
2851 {
2852 "considered_execution_plans": [
2853 {
2854 "plan_prefix": [
2855 ] /* plan_prefix */,
2856 "table": "`t2`",
2857 "best_access_path": {
2858 "considered_access_paths": [
2859 {
2860 "rows_to_scan": 2,
2861 "access_type": "scan",
2862 "resulting_rows": 2,
2863 "cost": 0.700854,
2864 "chosen": true
2865 }
2866 ] /* considered_access_paths */
2867 } /* best_access_path */,
2868 "condition_filtering_pct": 100,
2869 "rows_for_plan": 2,
2870 "cost_for_plan": 0.700854,
2871 "rest_of_plan": [
2872 {
2873 "plan_prefix": [
2874 "`t2`"
2875 ] /* plan_prefix */,
2876 "table": "`t1`",
2877 "best_access_path": {
2878 "considered_access_paths": [
2879 {
2880 "rows_to_scan": 3,
2881 "access_type": "scan",
2882 "using_join_cache": true,
2883 "buffers_needed": 1,
2884 "resulting_rows": 3,
2885 "cost": 1.1013,
2886 "chosen": true
2887 }
2888 ] /* considered_access_paths */
2889 } /* best_access_path */,
2890 "condition_filtering_pct": 100,
2891 "rows_for_plan": 6,
2892 "cost_for_plan": 1.80216,
2893 "chosen": true
2894 }
2895 ] /* rest_of_plan */
2896 },
2897 {
2898 "plan_prefix": [
2899 ] /* plan_prefix */,
2900 "table": "`t1`",
2901 "best_access_path": {
2902 "considered_access_paths": [
2903 {
2904 "rows_to_scan": 3,
2905 "access_type": "scan",
2906 "resulting_rows": 3,
2907 "cost": 0.801282,
2908 "chosen": true
2909 }
2910 ] /* considered_access_paths */
2911 } /* best_access_path */,
2912 "condition_filtering_pct": 100,
2913 "rows_for_plan": 3,
2914 "cost_for_plan": 0.801282,
2915 "rest_of_plan": [
2916 {
2917 "plan_prefix": [
2918 "`t1`"
2919 ] /* plan_prefix */,
2920 "table": "`t2`",
2921 "best_access_path": {
2922 "considered_access_paths": [
2923 {
2924 "rows_to_scan": 2,
2925 "access_type": "scan",
2926 "using_join_cache": true,
2927 "buffers_needed": 1,
2928 "resulting_rows": 2,
2929 "cost": 1.10088,
2930 "chosen": true
2931 }
2932 ] /* considered_access_paths */
2933 } /* best_access_path */,
2934 "condition_filtering_pct": 100,
2935 "rows_for_plan": 6,
2936 "cost_for_plan": 1.90216,
2937 "pruned_by_cost": true
2938 }
2939 ] /* rest_of_plan */
2940 }
2941 ] /* considered_execution_plans */
2942 },
2943 {
2944 "attaching_conditions_to_tables": {
2945 "original_condition": null,
2946 "attached_conditions_computation": [
2947 ] /* attached_conditions_computation */,
2948 "attached_conditions_summary": [
2949 {
2950 "table": "`t2`",
2951 "attached": null
2952 },
2953 {
2954 "table": "`t1`",
2955 "attached": null
2956 }
2957 ] /* attached_conditions_summary */
2958 } /* attaching_conditions_to_tables */
2959 },
2960 {
2961 "finalizing_table_conditions": [
2962 ] /* finalizing_table_conditions */
2963 },
2964 {
2965 "refine_plan": [
2966 {
2967 "table": "`t2`"
2968 },
2969 {
2970 "table": "`t1`"
2971 }
2972 ] /* refine_plan */
2973 }
2974 ] /* steps */
2975 } /* join_optimization */
2976 },
2977 {
2978 "join_explain": {
2979 "select#": 1,
2980 "steps": [
2981 ] /* steps */
2982 } /* join_explain */
2983 }
2984 ] /* steps */
2985 } 0 0
2986 select @@optimizer_trace_features;
2987 @@optimizer_trace_features
2988 greedy_search=on,range_optimizer=on,dynamic_range=on,repeated_subselect=on
2989 set @@optimizer_trace_features="greedy_search=off";
2990 explain select * from t1,t2;
2991 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
2992 1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 2 100.00 NULL
2993 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using join buffer (hash join)
2994 Warnings:
2995 Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2`
2996 select * from information_schema.OPTIMIZER_TRACE;
2997 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
2998 explain select * from t1,t2 {
2999 "steps": [
3000 {
3001 "join_preparation": {
3002 "select#": 1,
3003 "steps": [
3004 {
3005 "expanded_query": "/* select#1 */ select `t1`.`a` AS `a`,`t2`.`a` AS `a` from `t1` join `t2`"
3006 }
3007 ] /* steps */
3008 } /* join_preparation */
3009 },
3010 {
3011 "join_optimization": {
3012 "select#": 1,
3013 "steps": [
3014 {
3015 "table_dependencies": [
3016 {
3017 "table": "`t1`",
3018 "row_may_be_null": false,
3019 "map_bit": 0,
3020 "depends_on_map_bits": [
3021 ] /* depends_on_map_bits */
3022 },
3023 {
3024 "table": "`t2`",
3025 "row_may_be_null": false,
3026 "map_bit": 1,
3027 "depends_on_map_bits": [
3028 ] /* depends_on_map_bits */
3029 }
3030 ] /* table_dependencies */
3031 },
3032 {
3033 "rows_estimation": [
3034 {
3035 "table": "`t1`",
3036 "table_scan": {
3037 "rows": 3,
3038 "cost": 0.501282
3039 } /* table_scan */
3040 },
3041 {
3042 "table": "`t2`",
3043 "table_scan": {
3044 "rows": 2,
3045 "cost": 0.500854
3046 } /* table_scan */
3047 }
3048 ] /* rows_estimation */
3049 },
3050 {
3051 "considered_execution_plans": "..."
3052 },
3053 {
3054 "attaching_conditions_to_tables": {
3055 "original_condition": null,
3056 "attached_conditions_computation": [
3057 ] /* attached_conditions_computation */,
3058 "attached_conditions_summary": [
3059 {
3060 "table": "`t2`",
3061 "attached": null
3062 },
3063 {
3064 "table": "`t1`",
3065 "attached": null
3066 }
3067 ] /* attached_conditions_summary */
3068 } /* attaching_conditions_to_tables */
3069 },
3070 {
3071 "finalizing_table_conditions": [
3072 ] /* finalizing_table_conditions */
3073 },
3074 {
3075 "refine_plan": [
3076 {
3077 "table": "`t2`"
3078 },
3079 {
3080 "table": "`t1`"
3081 }
3082 ] /* refine_plan */
3083 }
3084 ] /* steps */
3085 } /* join_optimization */
3086 },
3087 {
3088 "join_explain": {
3089 "select#": 1,
3090 "steps": [
3091 ] /* steps */
3092 } /* join_explain */
3093 }
3094 ] /* steps */
3095 } 0 0
3096 set @@optimizer_trace_features=default;
3097 set @@session.optimizer_prune_level=default;
3098 drop table t1, t2;
3099 set @prefix_len = 6;
3100 set @blob_len = 16;
3101 set @suffix_len = @blob_len - @prefix_len;
3102 create table t1_16 (a1 blob(16), a2 blob(16));
3103 create table t2_16 (b1 blob(16), b2 blob(16));
3104 create table t3_16 (c1 blob(16), c2 blob(16));
3105 insert into t1_16 values
3106 (concat('1 - 00', repeat('x', @suffix_len)), concat('2 - 00', repeat('x', @suffix_len)));
3107 insert into t1_16 values
3108 (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3109 insert into t1_16 values
3110 (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3111 insert into t2_16 values
3112 (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3113 insert into t2_16 values
3114 (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3115 insert into t2_16 values
3116 (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3117 insert into t3_16 values
3118 (concat('1 - 01', repeat('x', @suffix_len)), concat('2 - 01', repeat('x', @suffix_len)));
3119 insert into t3_16 values
3120 (concat('1 - 02', repeat('x', @suffix_len)), concat('2 - 02', repeat('x', @suffix_len)));
3121 insert into t3_16 values
3122 (concat('1 - 03', repeat('x', @suffix_len)), concat('2 - 03', repeat('x', @suffix_len)));
3123 insert into t3_16 values
3124 (concat('1 - 04', repeat('x', @suffix_len)), concat('2 - 04', repeat('x', @suffix_len)));
3125 explain select left(a1,7), left(a2,7)
3126 from t1_16
3127 where a1 in (select b1 from t2_16 where b1 > '0');
3128 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
3129 1 PRIMARY t1_16 NULL ALL NULL NULL NULL NULL 3 100.00 Using where
3130 2 DEPENDENT SUBQUERY t2_16 NULL ALL NULL NULL NULL NULL 3 33.33 Using where
3131 Warnings:
3132 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`))))
3133 select * from information_schema.OPTIMIZER_TRACE;
3134 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
3135 explain select left(a1,7), left(a2,7)
3136 from t1_16
3137 where a1 in (select b1 from t2_16 where b1 > '0') {
3138 "steps": [
3139 {
3140 "join_preparation": {
3141 "select#": 1,
3142 "steps": [
3143 {
3144 "join_preparation": {
3145 "select#": 2,
3146 "steps": [
3147 {
3148 "expanded_query": "/* select#2 */ select `t2_16`.`b1` from `t2_16` where (`t2_16`.`b1` > '0')"
3149 },
3150 {
3151 "transformation": {
3152 "select#": 2,
3153 "from": "IN (SELECT)",
3154 "to": "EXISTS (CORRELATED SELECT)",
3155 "chosen": true,
3156 "evaluating_constant_where_conditions": [
3157 ] /* evaluating_constant_where_conditions */
3158 } /* transformation */
3159 }
3160 ] /* steps */
3161 } /* join_preparation */
3162 },
3163 {
3164 "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`))))"
3165 }
3166 ] /* steps */
3167 } /* join_preparation */
3168 },
3169 {
3170 "join_optimization": {
3171 "select#": 1,
3172 "steps": [
3173 {
3174 "condition_processing": {
3175 "condition": "WHERE",
3176 "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`))))",
3177 "steps": [
3178 {
3179 "transformation": "equality_propagation",
3180 "subselect_evaluation": [
3181 ] /* subselect_evaluation */,
3182 "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`))))"
3183 },
3184 {
3185 "transformation": "constant_propagation",
3186 "subselect_evaluation": [
3187 ] /* subselect_evaluation */,
3188 "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`))))"
3189 },
3190 {
3191 "transformation": "trivial_condition_removal",
3192 "subselect_evaluation": [
3193 ] /* subselect_evaluation */,
3194 "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`))))"
3195 }
3196 ] /* steps */
3197 } /* condition_processing */
3198 },
3199 {
3200 "substitute_generated_columns": {
3201 } /* substitute_generated_columns */
3202 },
3203 {
3204 "table_dependencies": [
3205 {
3206 "table": "`t1_16`",
3207 "row_may_be_null": false,
3208 "map_bit": 0,
3209 "depends_on_map_bits": [
3210 ] /* depends_on_map_bits */
3211 }
3212 ] /* table_dependencies */
3213 },
3214 {
3215 "ref_optimizer_key_uses": [
3216 ] /* ref_optimizer_key_uses */
3217 },
3218 {
3219 "rows_estimation": [
3220 {
3221 "table": "`t1_16`",
3222 "table_scan": {
3223 "rows": 3,
3224 "cost": 0.507324
3225 } /* table_scan */
3226 }
3227 ] /* rows_estimation */
3228 },
3229 {
3230 "considered_execution_plans": [
3231 {
3232 "plan_prefix": [
3233 ] /* plan_prefix */,
3234 "table": "`t1_16`",
3235 "best_access_path": {
3236 "considered_access_paths": [
3237 {
3238 "rows_to_scan": 3,
3239 "filtering_effect": [
3240 ] /* filtering_effect */,
3241 "final_filtering_effect": 1,
3242 "access_type": "scan",
3243 "resulting_rows": 3,
3244 "cost": 0.807324,
3245 "chosen": true
3246 }
3247 ] /* considered_access_paths */
3248 } /* best_access_path */,
3249 "condition_filtering_pct": 100,
3250 "rows_for_plan": 3,
3251 "cost_for_plan": 0.807324,
3252 "chosen": true
3253 }
3254 ] /* considered_execution_plans */
3255 },
3256 {
3257 "attaching_conditions_to_tables": {
3258 "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`))))",
3259 "attached_conditions_computation": [
3260 ] /* attached_conditions_computation */,
3261 "attached_conditions_summary": [
3262 {
3263 "table": "`t1_16`",
3264 "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`))))"
3265 }
3266 ] /* attached_conditions_summary */
3267 } /* attaching_conditions_to_tables */
3268 },
3269 {
3270 "finalizing_table_conditions": [
3271 {
3272 "table": "`t1_16`",
3273 "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`))))",
3274 "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`))))"
3275 }
3276 ] /* finalizing_table_conditions */
3277 },
3278 {
3279 "refine_plan": [
3280 {
3281 "table": "`t1_16`"
3282 }
3283 ] /* refine_plan */
3284 }
3285 ] /* steps */
3286 } /* join_optimization */
3287 },
3288 {
3289 "join_optimization": {
3290 "select#": 2,
3291 "steps": [
3292 {
3293 "condition_processing": {
3294 "condition": "WHERE",
3295 "original_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3296 "steps": [
3297 {
3298 "transformation": "equality_propagation",
3299 "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3300 },
3301 {
3302 "transformation": "constant_propagation",
3303 "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3304 },
3305 {
3306 "transformation": "trivial_condition_removal",
3307 "resulting_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3308 }
3309 ] /* steps */
3310 } /* condition_processing */
3311 },
3312 {
3313 "substitute_generated_columns": {
3314 } /* substitute_generated_columns */
3315 },
3316 {
3317 "table_dependencies": [
3318 {
3319 "table": "`t2_16`",
3320 "row_may_be_null": false,
3321 "map_bit": 0,
3322 "depends_on_map_bits": [
3323 ] /* depends_on_map_bits */
3324 }
3325 ] /* table_dependencies */
3326 },
3327 {
3328 "ref_optimizer_key_uses": [
3329 ] /* ref_optimizer_key_uses */
3330 },
3331 {
3332 "rows_estimation": [
3333 {
3334 "table": "`t2_16`",
3335 "table_scan": {
3336 "rows": 3,
3337 "cost": 0.507324
3338 } /* table_scan */
3339 }
3340 ] /* rows_estimation */
3341 },
3342 {
3343 "considered_execution_plans": [
3344 {
3345 "plan_prefix": [
3346 ] /* plan_prefix */,
3347 "table": "`t2_16`",
3348 "best_access_path": {
3349 "considered_access_paths": [
3350 {
3351 "rows_to_scan": 3,
3352 "filtering_effect": [
3353 ] /* filtering_effect */,
3354 "final_filtering_effect": 0.333333,
3355 "access_type": "scan",
3356 "resulting_rows": 1,
3357 "cost": 0.807324,
3358 "chosen": true
3359 }
3360 ] /* considered_access_paths */
3361 } /* best_access_path */,
3362 "condition_filtering_pct": 100,
3363 "rows_for_plan": 1,
3364 "cost_for_plan": 0.807324,
3365 "chosen": true
3366 }
3367 ] /* considered_execution_plans */
3368 },
3369 {
3370 "transformation": {
3371 "select#": 2,
3372 "from": "IN (SELECT)",
3373 "to": "materialization",
3374 "possible": false,
3375 "cause": "inner blob"
3376 } /* transformation */
3377 },
3378 {
3379 "attaching_conditions_to_tables": {
3380 "original_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3381 "attached_conditions_computation": [
3382 ] /* attached_conditions_computation */,
3383 "attached_conditions_summary": [
3384 {
3385 "table": "`t2_16`",
3386 "attached": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3387 }
3388 ] /* attached_conditions_summary */
3389 } /* attaching_conditions_to_tables */
3390 },
3391 {
3392 "finalizing_table_conditions": [
3393 {
3394 "table": "`t2_16`",
3395 "original_table_condition": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))",
3396 "final_table_condition ": "((`t2_16`.`b1` > '0') and (<cache>(`t1_16`.`a1`) = `t2_16`.`b1`))"
3397 }
3398 ] /* finalizing_table_conditions */
3399 },
3400 {
3401 "refine_plan": [
3402 {
3403 "table": "`t2_16`"
3404 }
3405 ] /* refine_plan */
3406 }
3407 ] /* steps */
3408 } /* join_optimization */
3409 },
3410 {
3411 "join_explain": {
3412 "select#": 1,
3413 "steps": [
3414 {
3415 "join_explain": {
3416 "select#": 2,
3417 "steps": [
3418 ] /* steps */
3419 } /* join_explain */
3420 }
3421 ] /* steps */
3422 } /* join_explain */
3423 }
3424 ] /* steps */
3425 } 0 0
3426 drop table t1_16,t2_16,t3_16;
3427 set @@optimizer_switch=@old_opt_switch;
3428 CREATE table t1 ( c1 integer );
3429 INSERT INTO t1 VALUES ( 1 );
3430 INSERT INTO t1 VALUES ( 2 );
3431 INSERT INTO t1 VALUES ( 3 );
3432 CREATE TABLE t2 ( c2 integer );
3433 INSERT INTO t2 VALUES ( 1 );
3434 INSERT INTO t2 VALUES ( 4 );
3435 INSERT INTO t2 VALUES ( 5 );
3436 SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
3437 WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
3438 c1 c2
3439 1 1
3440 select * from information_schema.OPTIMIZER_TRACE;
3441 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
3442 SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
3443 WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) ) {
3444 "steps": [
3445 {
3446 "join_optimization": {
3447 "select#": 1,
3448 "steps": [
3449 {
3450 "condition_processing": {
3451 "condition": "WHERE",
3452 "original_condition": "((`t2`.`c2` = 1) and (`t2`.`c2` = `t2`.`c2`) and (`t1`.`c1` = `t2`.`c2`))",
3453 "steps": [
3454 {
3455 "transformation": "equality_propagation",
3456 "resulting_condition": "(multiple equal(1, `t2`.`c2`, `t2`.`c2`, `t1`.`c1`))"
3457 },
3458 {
3459 "transformation": "constant_propagation",
3460 "resulting_condition": "(multiple equal(1, `t2`.`c2`, `t2`.`c2`, `t1`.`c1`))"
3461 },
3462 {
3463 "transformation": "trivial_condition_removal",
3464 "resulting_condition": "multiple equal(1, `t2`.`c2`, `t2`.`c2`, `t1`.`c1`)"
3465 }
3466 ] /* steps */
3467 } /* condition_processing */
3468 },
3469 {
3470 "substitute_generated_columns": {
3471 } /* substitute_generated_columns */
3472 },
3473 {
3474 "table_dependencies": [
3475 {
3476 "table": "`t1`",
3477 "row_may_be_null": false,
3478 "map_bit": 0,
3479 "depends_on_map_bits": [
3480 ] /* depends_on_map_bits */
3481 },
3482 {
3483 "table": "`t2`",
3484 "row_may_be_null": true,
3485 "map_bit": 1,
3486 "depends_on_map_bits": [
3487 ] /* depends_on_map_bits */
3488 },
3489 {
3490 "table": "`t2`",
3491 "row_may_be_null": false,
3492 "map_bit": 2,
3493 "depends_on_map_bits": [
3494 ] /* depends_on_map_bits */
3495 }
3496 ] /* table_dependencies */
3497 },
3498 {
3499 "ref_optimizer_key_uses": [
3500 ] /* ref_optimizer_key_uses */
3501 },
3502 {
3503 "pulled_out_semijoin_tables": [
3504 ] /* pulled_out_semijoin_tables */
3505 },
3506 {
3507 "rows_estimation": [
3508 {
3509 "table": "`t1`",
3510 "table_scan": {
3511 "rows": 3,
3512 "cost": 0.501282
3513 } /* table_scan */
3514 },
3515 {
3516 "table": "`t2`",
3517 "table_scan": {
3518 "rows": 3,
3519 "cost": 0.501282
3520 } /* table_scan */
3521 },
3522 {
3523 "table": "`t2`",
3524 "table_scan": {
3525 "rows": 3,
3526 "cost": 0.501282
3527 } /* table_scan */
3528 }
3529 ] /* rows_estimation */
3530 },
3531 {
3532 "execution_plan_for_potential_materialization": {
3533 "steps": [
3534 {
3535 "considered_execution_plans": [
3536 {
3537 "plan_prefix": [
3538 ] /* plan_prefix */,
3539 "table": "`t2`",
3540 "best_access_path": {
3541 "considered_access_paths": [
3542 {
3543 "rows_to_scan": 3,
3544 "filtering_effect": [
3545 ] /* filtering_effect */,
3546 "final_filtering_effect": 0.333333,
3547 "access_type": "scan",
3548 "resulting_rows": 1,
3549 "cost": 0.801282,
3550 "chosen": true
3551 }
3552 ] /* considered_access_paths */
3553 } /* best_access_path */,
3554 "condition_filtering_pct": 100,
3555 "rows_for_plan": 1,
3556 "cost_for_plan": 0.801282,
3557 "chosen": true
3558 }
3559 ] /* considered_execution_plans */
3560 }
3561 ] /* steps */
3562 } /* execution_plan_for_potential_materialization */
3563 },
3564 {
3565 "considered_execution_plans": [
3566 {
3567 "plan_prefix": [
3568 ] /* plan_prefix */,
3569 "table": "`t1`",
3570 "best_access_path": {
3571 "considered_access_paths": [
3572 {
3573 "rows_to_scan": 3,
3574 "filtering_effect": [
3575 ] /* filtering_effect */,
3576 "final_filtering_effect": 0.333333,
3577 "access_type": "scan",
3578 "resulting_rows": 1,
3579 "cost": 0.801282,
3580 "chosen": true
3581 }
3582 ] /* considered_access_paths */
3583 } /* best_access_path */,
3584 "condition_filtering_pct": 100,
3585 "rows_for_plan": 1,
3586 "cost_for_plan": 0.801282,
3587 "semijoin_strategy_choice": [
3588 ] /* semijoin_strategy_choice */,
3589 "rest_of_plan": [
3590 {
3591 "plan_prefix": [
3592 "`t1`"
3593 ] /* plan_prefix */,
3594 "table": "`t2`",
3595 "best_access_path": {
3596 "considered_access_paths": [
3597 {
3598 "rows_to_scan": 3,
3599 "filtering_effect": [
3600 ] /* filtering_effect */,
3601 "final_filtering_effect": 0.333333,
3602 "access_type": "scan",
3603 "using_join_cache": true,
3604 "buffers_needed": 1,
3605 "resulting_rows": 1,
3606 "cost": 0.801295,
3607 "chosen": true
3608 }
3609 ] /* considered_access_paths */
3610 } /* best_access_path */,
3611 "condition_filtering_pct": 100,
3612 "rows_for_plan": 1,
3613 "cost_for_plan": 1.60258,
3614 "semijoin_strategy_choice": [
3615 ] /* semijoin_strategy_choice */,
3616 "rest_of_plan": [
3617 {
3618 "plan_prefix": [
3619 "`t1`",
3620 "`t2`"
3621 ] /* plan_prefix */,
3622 "table": "`t2`",
3623 "best_access_path": {
3624 "considered_access_paths": [
3625 {
3626 "rows_to_scan": 3,
3627 "filtering_effect": [
3628 ] /* filtering_effect */,
3629 "final_filtering_effect": 0.333333,
3630 "access_type": "scan",
3631 "using_join_cache": true,
3632 "buffers_needed": 1,
3633 "resulting_rows": 1,
3634 "cost": 0.801311,
3635 "chosen": true
3636 }
3637 ] /* considered_access_paths */
3638 } /* best_access_path */,
3639 "condition_filtering_pct": 100,
3640 "rows_for_plan": 1,
3641 "cost_for_plan": 2.40389,
3642 "semijoin_strategy_choice": [
3643 {
3644 "strategy": "FirstMatch",
3645 "recalculate_access_paths_and_cost": {
3646 "tables": [
3647 {
3648 "table": "`t2`",
3649 "best_access_path": {
3650 "considered_access_paths": [
3651 {
3652 "rows_to_scan": 3,
3653 "filtering_effect": [
3654 ] /* filtering_effect */,
3655 "final_filtering_effect": 0.333333,
3656 "access_type": "scan",
3657 "using_join_cache": true,
3658 "buffers_needed": 1,
3659 "resulting_rows": 1,
3660 "cost": 0.801311,
3661 "chosen": true
3662 }
3663 ] /* considered_access_paths */
3664 } /* best_access_path */
3665 }
3666 ] /* tables */
3667 } /* recalculate_access_paths_and_cost */,
3668 "cost": 2.40389,
3669 "rows": 1,
3670 "chosen": true
3671 },
3672 {
3673 "strategy": "MaterializeLookup",
3674 "cost": 3.60386,
3675 "rows": 1,
3676 "duplicate_tables_left": false,
3677 "chosen": false
3678 },
3679 {
3680 "strategy": "DuplicatesWeedout",
3681 "cost": 3.60389,
3682 "rows": 1,
3683 "duplicate_tables_left": false,
3684 "chosen": false
3685 }
3686 ] /* semijoin_strategy_choice */,
3687 "chosen": true
3688 }
3689 ] /* rest_of_plan */
3690 },
3691 {
3692 "plan_prefix": [
3693 "`t1`"
3694 ] /* plan_prefix */,
3695 "table": "`t2`",
3696 "best_access_path": {
3697 "considered_access_paths": [
3698 {
3699 "rows_to_scan": 3,
3700 "filtering_effect": [
3701 ] /* filtering_effect */,
3702 "final_filtering_effect": 0.333333,
3703 "access_type": "scan",
3704 "using_join_cache": true,
3705 "buffers_needed": 1,
3706 "resulting_rows": 1,
3707 "cost": 0.801295,
3708 "chosen": true
3709 }
3710 ] /* considered_access_paths */
3711 } /* best_access_path */,
3712 "condition_filtering_pct": 100,
3713 "rows_for_plan": 1,
3714 "cost_for_plan": 1.60258,
3715 "semijoin_strategy_choice": [
3716 {
3717 "strategy": "MaterializeScan",
3718 "choice": "deferred"
3719 }
3720 ] /* semijoin_strategy_choice */,
3721 "pruned_by_heuristic": true
3722 }
3723 ] /* rest_of_plan */
3724 },
3725 {
3726 "plan_prefix": [
3727 ] /* plan_prefix */,
3728 "table": "`t2`",
3729 "best_access_path": {
3730 "considered_access_paths": [
3731 {
3732 "rows_to_scan": 3,
3733 "filtering_effect": [
3734 ] /* filtering_effect */,
3735 "final_filtering_effect": 0.333333,
3736 "access_type": "scan",
3737 "resulting_rows": 1,
3738 "cost": 0.801282,
3739 "chosen": true
3740 }
3741 ] /* considered_access_paths */
3742 } /* best_access_path */,
3743 "condition_filtering_pct": 100,
3744 "rows_for_plan": 1,
3745 "cost_for_plan": 0.801282,
3746 "semijoin_strategy_choice": [
3747 ] /* semijoin_strategy_choice */,
3748 "pruned_by_heuristic": true
3749 },
3750 {
3751 "plan_prefix": [
3752 ] /* plan_prefix */,
3753 "table": "`t2`",
3754 "best_access_path": {
3755 "considered_access_paths": [
3756 {
3757 "rows_to_scan": 3,
3758 "filtering_effect": [
3759 ] /* filtering_effect */,
3760 "final_filtering_effect": 0.333333,
3761 "access_type": "scan",
3762 "resulting_rows": 1,
3763 "cost": 0.801282,
3764 "chosen": true
3765 }
3766 ] /* considered_access_paths */
3767 } /* best_access_path */,
3768 "condition_filtering_pct": 100,
3769 "rows_for_plan": 1,
3770 "cost_for_plan": 0.801282,
3771 "semijoin_strategy_choice": [
3772 {
3773 "strategy": "MaterializeScan",
3774 "choice": "deferred"
3775 }
3776 ] /* semijoin_strategy_choice */,
3777 "pruned_by_heuristic": true
3778 },
3779 {
3780 "final_semijoin_strategy": "FirstMatch",
3781 "recalculate_access_paths_and_cost": {
3782 "tables": [
3783 {
3784 "table": "`t2`",
3785 "best_access_path": {
3786 "considered_access_paths": [
3787 {
3788 "rows_to_scan": 3,
3789 "filtering_effect": [
3790 ] /* filtering_effect */,
3791 "final_filtering_effect": 0.333333,
3792 "access_type": "scan",
3793 "using_join_cache": true,
3794 "buffers_needed": 1,
3795 "resulting_rows": 1,
3796 "cost": 0.801311,
3797 "chosen": true
3798 }
3799 ] /* considered_access_paths */
3800 } /* best_access_path */
3801 }
3802 ] /* tables */
3803 } /* recalculate_access_paths_and_cost */
3804 }
3805 ] /* considered_execution_plans */
3806 },
3807 {
3808 "attaching_conditions_to_tables": {
3809 "original_condition": "((`t1`.`c1` = 1) and (`t2`.`c2` = 1) and (`t2`.`c2` = 1))",
3810 "attached_conditions_computation": [
3811 ] /* attached_conditions_computation */,
3812 "attached_conditions_summary": [
3813 {
3814 "table": "`t1`",
3815 "attached": "(`t1`.`c1` = 1)"
3816 },
3817 {
3818 "table": "`t2`",
3819 "attached": "(`t2`.`c2` = 1)"
3820 },
3821 {
3822 "table": "`t2`",
3823 "attached": "(`t2`.`c2` = 1)"
3824 }
3825 ] /* attached_conditions_summary */
3826 } /* attaching_conditions_to_tables */
3827 },
3828 {
3829 "finalizing_table_conditions": [
3830 {
3831 "table": "`t1`",
3832 "original_table_condition": "(`t1`.`c1` = 1)",
3833 "final_table_condition ": "(`t1`.`c1` = 1)"
3834 },
3835 {
3836 "table": "`t2`",
3837 "original_table_condition": "(`t2`.`c2` = 1)",
3838 "final_table_condition ": "(`t2`.`c2` = 1)"
3839 },
3840 {
3841 "table": "`t2`",
3842 "original_table_condition": "(`t2`.`c2` = 1)",
3843 "final_table_condition ": "(`t2`.`c2` = 1)"
3844 }
3845 ] /* finalizing_table_conditions */
3846 },
3847 {
3848 "refine_plan": [
3849 {
3850 "table": "`t1`"
3851 },
3852 {
3853 "table": "`t2`"
3854 },
3855 {
3856 "table": "`t2`"
3857 }
3858 ] /* refine_plan */
3859 }
3860 ] /* steps */
3861 } /* join_optimization */
3862 },
3863 {
3864 "join_execution": {
3865 "select#": 1,
3866 "steps": [
3867 ] /* steps */
3868 } /* join_execution */
3869 }
3870 ] /* steps */
3871 } 0 0
3872 SELECT * FROM t1 WHERE c1=5 UNION SELECT * FROM t2 WHERE c2=5;
3873 c1
3874 5
3875 select * from information_schema.OPTIMIZER_TRACE;
3876 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
3877 SELECT * FROM t1 WHERE c1=5 UNION SELECT * FROM t2 WHERE c2=5 {
3878 "steps": [
3879 {
3880 "join_optimization": {
3881 "select#": 1,
3882 "steps": [
3883 {
3884 "condition_processing": {
3885 "condition": "WHERE",
3886 "original_condition": "(`t1`.`c1` = 5)",
3887 "steps": [
3888 {
3889 "transformation": "equality_propagation",
3890 "resulting_condition": "multiple equal(5, `t1`.`c1`)"
3891 },
3892 {
3893 "transformation": "constant_propagation",
3894 "resulting_condition": "multiple equal(5, `t1`.`c1`)"
3895 },
3896 {
3897 "transformation": "trivial_condition_removal",
3898 "resulting_condition": "multiple equal(5, `t1`.`c1`)"
3899 }
3900 ] /* steps */
3901 } /* condition_processing */
3902 },
3903 {
3904 "substitute_generated_columns": {
3905 } /* substitute_generated_columns */
3906 },
3907 {
3908 "table_dependencies": [
3909 {
3910 "table": "`t1`",
3911 "row_may_be_null": false,
3912 "map_bit": 0,
3913 "depends_on_map_bits": [
3914 ] /* depends_on_map_bits */
3915 }
3916 ] /* table_dependencies */
3917 },
3918 {
3919 "ref_optimizer_key_uses": [
3920 ] /* ref_optimizer_key_uses */
3921 },
3922 {
3923 "rows_estimation": [
3924 {
3925 "table": "`t1`",
3926 "table_scan": {
3927 "rows": 3,
3928 "cost": 0.501282
3929 } /* table_scan */
3930 }
3931 ] /* rows_estimation */
3932 },
3933 {
3934 "considered_execution_plans": [
3935 {
3936 "plan_prefix": [
3937 ] /* plan_prefix */,
3938 "table": "`t1`",
3939 "best_access_path": {
3940 "considered_access_paths": [
3941 {
3942 "rows_to_scan": 3,
3943 "access_type": "scan",
3944 "resulting_rows": 3,
3945 "cost": 0.801282,
3946 "chosen": true
3947 }
3948 ] /* considered_access_paths */
3949 } /* best_access_path */,
3950 "condition_filtering_pct": 100,
3951 "rows_for_plan": 3,
3952 "cost_for_plan": 0.801282,
3953 "chosen": true
3954 }
3955 ] /* considered_execution_plans */
3956 },
3957 {
3958 "attaching_conditions_to_tables": {
3959 "original_condition": "(`t1`.`c1` = 5)",
3960 "attached_conditions_computation": [
3961 ] /* attached_conditions_computation */,
3962 "attached_conditions_summary": [
3963 {
3964 "table": "`t1`",
3965 "attached": "(`t1`.`c1` = 5)"
3966 }
3967 ] /* attached_conditions_summary */
3968 } /* attaching_conditions_to_tables */
3969 },
3970 {
3971 "finalizing_table_conditions": [
3972 {
3973 "table": "`t1`",
3974 "original_table_condition": "(`t1`.`c1` = 5)",
3975 "final_table_condition ": "(`t1`.`c1` = 5)"
3976 }
3977 ] /* finalizing_table_conditions */
3978 },
3979 {
3980 "refine_plan": [
3981 {
3982 "table": "`t1`"
3983 }
3984 ] /* refine_plan */
3985 }
3986 ] /* steps */
3987 } /* join_optimization */
3988 },
3989 {
3990 "join_optimization": {
3991 "select#": 2,
3992 "steps": [
3993 {
3994 "condition_processing": {
3995 "condition": "WHERE",
3996 "original_condition": "(`t2`.`c2` = 5)",
3997 "steps": [
3998 {
3999 "transformation": "equality_propagation",
4000 "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4001 },
4002 {
4003 "transformation": "constant_propagation",
4004 "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4005 },
4006 {
4007 "transformation": "trivial_condition_removal",
4008 "resulting_condition": "multiple equal(5, `t2`.`c2`)"
4009 }
4010 ] /* steps */
4011 } /* condition_processing */
4012 },
4013 {
4014 "substitute_generated_columns": {
4015 } /* substitute_generated_columns */
4016 },
4017 {
4018 "table_dependencies": [
4019 {
4020 "table": "`t2`",
4021 "row_may_be_null": false,
4022 "map_bit": 0,
4023 "depends_on_map_bits": [
4024 ] /* depends_on_map_bits */
4025 }
4026 ] /* table_dependencies */
4027 },
4028 {
4029 "ref_optimizer_key_uses": [
4030 ] /* ref_optimizer_key_uses */
4031 },
4032 {
4033 "rows_estimation": [
4034 {
4035 "table": "`t2`",
4036 "table_scan": {
4037 "rows": 3,
4038 "cost": 0.501282
4039 } /* table_scan */
4040 }
4041 ] /* rows_estimation */
4042 },
4043 {
4044 "considered_execution_plans": [
4045 {
4046 "plan_prefix": [
4047 ] /* plan_prefix */,
4048 "table": "`t2`",
4049 "best_access_path": {
4050 "considered_access_paths": [
4051 {
4052 "rows_to_scan": 3,
4053 "access_type": "scan",
4054 "resulting_rows": 3,
4055 "cost": 0.801282,
4056 "chosen": true
4057 }
4058 ] /* considered_access_paths */
4059 } /* best_access_path */,
4060 "condition_filtering_pct": 100,
4061 "rows_for_plan": 3,
4062 "cost_for_plan": 0.801282,
4063 "chosen": true
4064 }
4065 ] /* considered_execution_plans */
4066 },
4067 {
4068 "attaching_conditions_to_tables": {
4069 "original_condition": "(`t2`.`c2` = 5)",
4070 "attached_conditions_computation": [
4071 ] /* attached_conditions_computation */,
4072 "attached_conditions_summary": [
4073 {
4074 "table": "`t2`",
4075 "attached": "(`t2`.`c2` = 5)"
4076 }
4077 ] /* attached_conditions_summary */
4078 } /* attaching_conditions_to_tables */
4079 },
4080 {
4081 "finalizing_table_conditions": [
4082 {
4083 "table": "`t2`",
4084 "original_table_condition": "(`t2`.`c2` = 5)",
4085 "final_table_condition ": "(`t2`.`c2` = 5)"
4086 }
4087 ] /* finalizing_table_conditions */
4088 },
4089 {
4090 "refine_plan": [
4091 {
4092 "table": "`t2`"
4093 }
4094 ] /* refine_plan */
4095 }
4096 ] /* steps */
4097 } /* join_optimization */
4098 },
4099 {
4100 "creating_tmp_table": {
4101 "tmp_table_info": {
4102 "table": "<union temporary>",
4103 "columns": 1,
4104 "row_length": 5,
4105 "key_length": 5,
4106 "unique_constraint": false,
4107 "makes_grouped_rows": false,
4108 "cannot_insert_duplicates": true,
4109 "location": "TempTable"
4110 } /* tmp_table_info */
4111 } /* creating_tmp_table */
4112 },
4113 {
4114 "join_optimization": {
4115 "select#": 3,
4116 "steps": [
4117 {
4118 "table_dependencies": [
4119 {
4120 "table": "``",
4121 "row_may_be_null": false,
4122 "map_bit": 0,
4123 "depends_on_map_bits": [
4124 ] /* depends_on_map_bits */
4125 }
4126 ] /* table_dependencies */
4127 },
4128 {
4129 "rows_estimation": [
4130 {
4131 "table": "``",
4132 "table_scan": {
4133 "rows": 0,
4134 "cost": 2.5
4135 } /* table_scan */
4136 }
4137 ] /* rows_estimation */
4138 },
4139 {
4140 "considered_execution_plans": [
4141 {
4142 "plan_prefix": [
4143 ] /* plan_prefix */,
4144 "table": "``",
4145 "best_access_path": {
4146 "considered_access_paths": [
4147 {
4148 "rows_to_scan": 0,
4149 "access_type": "scan",
4150 "resulting_rows": 0,
4151 "cost": 2.5,
4152 "chosen": true
4153 }
4154 ] /* considered_access_paths */
4155 } /* best_access_path */,
4156 "condition_filtering_pct": 100,
4157 "rows_for_plan": 0,
4158 "cost_for_plan": 2.5,
4159 "chosen": true
4160 }
4161 ] /* considered_execution_plans */
4162 },
4163 {
4164 "attaching_conditions_to_tables": {
4165 "original_condition": null,
4166 "attached_conditions_computation": [
4167 ] /* attached_conditions_computation */,
4168 "attached_conditions_summary": [
4169 {
4170 "table": "``",
4171 "attached": null
4172 }
4173 ] /* attached_conditions_summary */
4174 } /* attaching_conditions_to_tables */
4175 },
4176 {
4177 "finalizing_table_conditions": [
4178 ] /* finalizing_table_conditions */
4179 },
4180 {
4181 "refine_plan": [
4182 {
4183 "table": "``"
4184 }
4185 ] /* refine_plan */
4186 }
4187 ] /* steps */
4188 } /* join_optimization */
4189 },
4190 {
4191 "join_execution": {
4192 "steps": [
4193 {
4194 "materialize": {
4195 "select#": 1,
4196 "steps": [
4197 ] /* steps */
4198 } /* materialize */
4199 },
4200 {
4201 "materialize": {
4202 "select#": 2,
4203 "steps": [
4204 ] /* steps */
4205 } /* materialize */
4206 }
4207 ] /* steps */
4208 } /* join_execution */
4209 }
4210 ] /* steps */
4211 } 0 0
4212 explain
4213 select * from t1
4214 where concat(c1,'x') IN
4215 (select left(c2,8) from t2)
4216 and
4217 concat(c1,'y') IN
4218 (select left(c2,9) from t2);
4219 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
4220 1 PRIMARY t1 NULL ALL NULL NULL NULL NULL 3 100.00 Using where
4221 3 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
4222 2 SUBQUERY t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
4223 Warnings:
4224 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)`))))))
4225 select * from information_schema.OPTIMIZER_TRACE;
4226 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
4227 explain
4228 select * from t1
4229 where concat(c1,'x') IN
4230 (select left(c2,8) from t2)
4231 and
4232 concat(c1,'y') IN
4233 (select left(c2,9) from t2) {
4234 "steps": [
4235 {
4236 "join_preparation": {
4237 "select#": 1,
4238 "steps": [
4239 {
4240 "join_preparation": {
4241 "select#": 2,
4242 "steps": [
4243 {
4244 "expanded_query": "/* select#2 */ select left(`t2`.`c2`,8) from `t2`"
4245 },
4246 {
4247 "transformation": {
4248 "select#": 2,
4249 "from": "IN (SELECT)",
4250 "to": "EXISTS (CORRELATED SELECT)",
4251 "chosen": true,
4252 "evaluating_constant_where_conditions": [
4253 ] /* evaluating_constant_where_conditions */
4254 } /* transformation */
4255 }
4256 ] /* steps */
4257 } /* join_preparation */
4258 },
4259 {
4260 "join_preparation": {
4261 "select#": 3,
4262 "steps": [
4263 {
4264 "expanded_query": "/* select#3 */ select left(`t2`.`c2`,9) from `t2`"
4265 },
4266 {
4267 "transformation": {
4268 "select#": 3,
4269 "from": "IN (SELECT)",
4270 "to": "EXISTS (CORRELATED SELECT)",
4271 "chosen": true,
4272 "evaluating_constant_where_conditions": [
4273 ] /* evaluating_constant_where_conditions */
4274 } /* transformation */
4275 }
4276 ] /* steps */
4277 } /* join_preparation */
4278 },
4279 {
4280 "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)))))"
4281 }
4282 ] /* steps */
4283 } /* join_preparation */
4284 },
4285 {
4286 "join_optimization": {
4287 "select#": 1,
4288 "steps": [
4289 {
4290 "condition_processing": {
4291 "condition": "WHERE",
4292 "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)))))",
4293 "steps": [
4294 {
4295 "transformation": "equality_propagation",
4296 "subselect_evaluation": [
4297 ] /* subselect_evaluation */,
4298 "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)))))"
4299 },
4300 {
4301 "transformation": "constant_propagation",
4302 "subselect_evaluation": [
4303 ] /* subselect_evaluation */,
4304 "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)))))"
4305 },
4306 {
4307 "transformation": "trivial_condition_removal",
4308 "subselect_evaluation": [
4309 ] /* subselect_evaluation */,
4310 "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)))))"
4311 }
4312 ] /* steps */
4313 } /* condition_processing */
4314 },
4315 {
4316 "substitute_generated_columns": {
4317 } /* substitute_generated_columns */
4318 },
4319 {
4320 "table_dependencies": [
4321 {
4322 "table": "`t1`",
4323 "row_may_be_null": false,
4324 "map_bit": 0,
4325 "depends_on_map_bits": [
4326 ] /* depends_on_map_bits */
4327 }
4328 ] /* table_dependencies */
4329 },
4330 {
4331 "ref_optimizer_key_uses": [
4332 ] /* ref_optimizer_key_uses */
4333 },
4334 {
4335 "rows_estimation": [
4336 {
4337 "table": "`t1`",
4338 "table_scan": {
4339 "rows": 3,
4340 "cost": 0.501282
4341 } /* table_scan */
4342 }
4343 ] /* rows_estimation */
4344 },
4345 {
4346 "considered_execution_plans": [
4347 {
4348 "plan_prefix": [
4349 ] /* plan_prefix */,
4350 "table": "`t1`",
4351 "best_access_path": {
4352 "considered_access_paths": [
4353 {
4354 "rows_to_scan": 3,
4355 "filtering_effect": [
4356 ] /* filtering_effect */,
4357 "final_filtering_effect": 1,
4358 "access_type": "scan",
4359 "resulting_rows": 3,
4360 "cost": 0.801282,
4361 "chosen": true
4362 }
4363 ] /* considered_access_paths */
4364 } /* best_access_path */,
4365 "condition_filtering_pct": 100,
4366 "rows_for_plan": 3,
4367 "cost_for_plan": 0.801282,
4368 "chosen": true
4369 }
4370 ] /* considered_execution_plans */
4371 },
4372 {
4373 "attaching_conditions_to_tables": {
4374 "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)))))",
4375 "attached_conditions_computation": [
4376 ] /* attached_conditions_computation */,
4377 "attached_conditions_summary": [
4378 {
4379 "table": "`t1`",
4380 "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)))))"
4381 }
4382 ] /* attached_conditions_summary */
4383 } /* attaching_conditions_to_tables */
4384 },
4385 {
4386 "finalizing_table_conditions": [
4387 {
4388 "table": "`t1`",
4389 "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)))))",
4390 "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)))))"
4391 }
4392 ] /* finalizing_table_conditions */
4393 },
4394 {
4395 "refine_plan": [
4396 {
4397 "table": "`t1`"
4398 }
4399 ] /* refine_plan */
4400 }
4401 ] /* steps */
4402 } /* join_optimization */
4403 },
4404 {
4405 "join_optimization": {
4406 "select#": 3,
4407 "steps": [
4408 {
4409 "condition_processing": {
4410 "condition": "WHERE",
4411 "original_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))",
4412 "steps": [
4413 {
4414 "transformation": "equality_propagation",
4415 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4416 },
4417 {
4418 "transformation": "constant_propagation",
4419 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4420 },
4421 {
4422 "transformation": "trivial_condition_removal",
4423 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'y')) = left(`t2`.`c2`,9))"
4424 }
4425 ] /* steps */
4426 } /* condition_processing */
4427 },
4428 {
4429 "substitute_generated_columns": {
4430 } /* substitute_generated_columns */
4431 },
4432 {
4433 "table_dependencies": [
4434 {
4435 "table": "`t2`",
4436 "row_may_be_null": false,
4437 "map_bit": 0,
4438 "depends_on_map_bits": [
4439 ] /* depends_on_map_bits */
4440 }
4441 ] /* table_dependencies */
4442 },
4443 {
4444 "ref_optimizer_key_uses": [
4445 ] /* ref_optimizer_key_uses */
4446 },
4447 {
4448 "rows_estimation": [
4449 {
4450 "table": "`t2`",
4451 "table_scan": {
4452 "rows": 3,
4453 "cost": 0.501282
4454 } /* table_scan */
4455 }
4456 ] /* rows_estimation */
4457 },
4458 {
4459 "considered_execution_plans": [
4460 {
4461 "plan_prefix": [
4462 ] /* plan_prefix */,
4463 "table": "`t2`",
4464 "best_access_path": {
4465 "considered_access_paths": [
4466 {
4467 "rows_to_scan": 3,
4468 "filtering_effect": [
4469 ] /* filtering_effect */,
4470 "final_filtering_effect": 1,
4471 "access_type": "scan",
4472 "resulting_rows": 3,
4473 "cost": 0.801282,
4474 "chosen": true
4475 }
4476 ] /* considered_access_paths */
4477 } /* best_access_path */,
4478 "condition_filtering_pct": 100,
4479 "rows_for_plan": 3,
4480 "cost_for_plan": 0.801282,
4481 "chosen": true
4482 }
4483 ] /* considered_execution_plans */
4484 },
4485 {
4486 "transformation": {
4487 "select#": 3,
4488 "from": "IN (SELECT)",
4489 "to": "materialization",
4490 "has_nullable_expressions": true,
4491 "treat_UNKNOWN_as_FALSE": true,
4492 "possible": true
4493 } /* transformation */
4494 },
4495 {
4496 "execution_plan_for_potential_materialization": {
4497 "steps": [
4498 {
4499 "considered_execution_plans": [
4500 {
4501 "plan_prefix": [
4502 ] /* plan_prefix */,
4503 "table": "`t2`",
4504 "best_access_path": {
4505 "considered_access_paths": [
4506 {
4507 "rows_to_scan": 3,
4508 "filtering_effect": [
4509 ] /* filtering_effect */,
4510 "final_filtering_effect": 1,
4511 "access_type": "scan",
4512 "resulting_rows": 3,
4513 "cost": 0.801282,
4514 "chosen": true
4515 }
4516 ] /* considered_access_paths */
4517 } /* best_access_path */,
4518 "condition_filtering_pct": 100,
4519 "rows_for_plan": 3,
4520 "cost_for_plan": 0.801282,
4521 "chosen": true
4522 }
4523 ] /* considered_execution_plans */
4524 }
4525 ] /* steps */,
4526 "subq_mat_decision": {
4527 "parent_fanouts": [
4528 {
4529 "select#": 1,
4530 "subq_attached_to_table": true,
4531 "table": "`t1`",
4532 "fanout": 3,
4533 "cacheable": true
4534 }
4535 ] /* parent_fanouts */,
4536 "cost_to_create_and_fill_materialized_table": 2.10028,
4537 "cost_of_one_EXISTS": 0.800282,
4538 "number_of_subquery_evaluations": 3,
4539 "cost_of_materialization": 2.40028,
4540 "cost_of_EXISTS": 2.40085,
4541 "chosen": true
4542 } /* subq_mat_decision */
4543 } /* execution_plan_for_potential_materialization */
4544 },
4545 {
4546 "transformation": {
4547 "select#": 3,
4548 "from": "IN (SELECT)",
4549 "to": "materialization",
4550 "chosen": true,
4551 "unknown_key_1": {
4552 "creating_tmp_table": {
4553 "tmp_table_info": {
4554 "table": "<materialized_subquery>",
4555 "columns": 1,
4556 "row_length": 38,
4557 "key_length": 39,
4558 "unique_constraint": false,
4559 "makes_grouped_rows": false,
4560 "cannot_insert_duplicates": true,
4561 "location": "TempTable"
4562 } /* tmp_table_info */
4563 } /* creating_tmp_table */
4564 }
4565 } /* transformation */
4566 },
4567 {
4568 "attaching_conditions_to_tables": {
4569 "original_condition": null,
4570 "attached_conditions_computation": [
4571 ] /* attached_conditions_computation */,
4572 "attached_conditions_summary": [
4573 {
4574 "table": "`t2`",
4575 "attached": null
4576 }
4577 ] /* attached_conditions_summary */
4578 } /* attaching_conditions_to_tables */
4579 },
4580 {
4581 "finalizing_table_conditions": [
4582 ] /* finalizing_table_conditions */
4583 },
4584 {
4585 "refine_plan": [
4586 {
4587 "table": "`t2`"
4588 }
4589 ] /* refine_plan */
4590 }
4591 ] /* steps */
4592 } /* join_optimization */
4593 },
4594 {
4595 "join_optimization": {
4596 "select#": 2,
4597 "steps": [
4598 {
4599 "condition_processing": {
4600 "condition": "WHERE",
4601 "original_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))",
4602 "steps": [
4603 {
4604 "transformation": "equality_propagation",
4605 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4606 },
4607 {
4608 "transformation": "constant_propagation",
4609 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4610 },
4611 {
4612 "transformation": "trivial_condition_removal",
4613 "resulting_condition": "(<cache>(concat(`t1`.`c1`,'x')) = left(`t2`.`c2`,8))"
4614 }
4615 ] /* steps */
4616 } /* condition_processing */
4617 },
4618 {
4619 "substitute_generated_columns": {
4620 } /* substitute_generated_columns */
4621 },
4622 {
4623 "table_dependencies": [
4624 {
4625 "table": "`t2`",
4626 "row_may_be_null": false,
4627 "map_bit": 0,
4628 "depends_on_map_bits": [
4629 ] /* depends_on_map_bits */
4630 }
4631 ] /* table_dependencies */
4632 },
4633 {
4634 "ref_optimizer_key_uses": [
4635 ] /* ref_optimizer_key_uses */
4636 },
4637 {
4638 "rows_estimation": [
4639 {
4640 "table": "`t2`",
4641 "table_scan": {
4642 "rows": 3,
4643 "cost": 0.501282
4644 } /* table_scan */
4645 }
4646 ] /* rows_estimation */
4647 },
4648 {
4649 "considered_execution_plans": [
4650 {
4651 "plan_prefix": [
4652 ] /* plan_prefix */,
4653 "table": "`t2`",
4654 "best_access_path": {
4655 "considered_access_paths": [
4656 {
4657 "rows_to_scan": 3,
4658 "filtering_effect": [
4659 ] /* filtering_effect */,
4660 "final_filtering_effect": 1,
4661 "access_type": "scan",
4662 "resulting_rows": 3,
4663 "cost": 0.801282,
4664 "chosen": true
4665 }
4666 ] /* considered_access_paths */
4667 } /* best_access_path */,
4668 "condition_filtering_pct": 100,
4669 "rows_for_plan": 3,
4670 "cost_for_plan": 0.801282,
4671 "chosen": true
4672 }
4673 ] /* considered_execution_plans */
4674 },
4675 {
4676 "transformation": {
4677 "select#": 2,
4678 "from": "IN (SELECT)",
4679 "to": "materialization",
4680 "has_nullable_expressions": true,
4681 "treat_UNKNOWN_as_FALSE": true,
4682 "possible": true
4683 } /* transformation */
4684 },
4685 {
4686 "execution_plan_for_potential_materialization": {
4687 "steps": [
4688 {
4689 "considered_execution_plans": [
4690 {
4691 "plan_prefix": [
4692 ] /* plan_prefix */,
4693 "table": "`t2`",
4694 "best_access_path": {
4695 "considered_access_paths": [
4696 {
4697 "rows_to_scan": 3,
4698 "filtering_effect": [
4699 ] /* filtering_effect */,
4700 "final_filtering_effect": 1,
4701 "access_type": "scan",
4702 "resulting_rows": 3,
4703 "cost": 0.801282,
4704 "chosen": true
4705 }
4706 ] /* considered_access_paths */
4707 } /* best_access_path */,
4708 "condition_filtering_pct": 100,
4709 "rows_for_plan": 3,
4710 "cost_for_plan": 0.801282,
4711 "chosen": true
4712 }
4713 ] /* considered_execution_plans */
4714 }
4715 ] /* steps */,
4716 "subq_mat_decision": {
4717 "parent_fanouts": [
4718 {
4719 "select#": 1,
4720 "subq_attached_to_table": true,
4721 "table": "`t1`",
4722 "fanout": 3,
4723 "cacheable": true
4724 }
4725 ] /* parent_fanouts */,
4726 "cost_to_create_and_fill_materialized_table": 2.10028,
4727 "cost_of_one_EXISTS": 0.800282,
4728 "number_of_subquery_evaluations": 3,
4729 "cost_of_materialization": 2.40028,
4730 "cost_of_EXISTS": 2.40085,
4731 "chosen": true
4732 } /* subq_mat_decision */
4733 } /* execution_plan_for_potential_materialization */
4734 },
4735 {
4736 "transformation": {
4737 "select#": 2,
4738 "from": "IN (SELECT)",
4739 "to": "materialization",
4740 "chosen": true,
4741 "unknown_key_2": {
4742 "creating_tmp_table": {
4743 "tmp_table_info": {
4744 "table": "<materialized_subquery>",
4745 "columns": 1,
4746 "row_length": 34,
4747 "key_length": 35,
4748 "unique_constraint": false,
4749 "makes_grouped_rows": false,
4750 "cannot_insert_duplicates": true,
4751 "location": "TempTable"
4752 } /* tmp_table_info */
4753 } /* creating_tmp_table */
4754 }
4755 } /* transformation */
4756 },
4757 {
4758 "attaching_conditions_to_tables": {
4759 "original_condition": null,
4760 "attached_conditions_computation": [
4761 ] /* attached_conditions_computation */,
4762 "attached_conditions_summary": [
4763 {
4764 "table": "`t2`",
4765 "attached": null
4766 }
4767 ] /* attached_conditions_summary */
4768 } /* attaching_conditions_to_tables */
4769 },
4770 {
4771 "finalizing_table_conditions": [
4772 ] /* finalizing_table_conditions */
4773 },
4774 {
4775 "refine_plan": [
4776 {
4777 "table": "`t2`"
4778 }
4779 ] /* refine_plan */
4780 }
4781 ] /* steps */
4782 } /* join_optimization */
4783 },
4784 {
4785 "join_explain": {
4786 "select#": 1,
4787 "steps": [
4788 {
4789 "join_explain": {
4790 "select#": 3,
4791 "steps": [
4792 ] /* steps */
4793 } /* join_explain */
4794 },
4795 {
4796 "join_explain": {
4797 "select#": 2,
4798 "steps": [
4799 ] /* steps */
4800 } /* join_explain */
4801 }
4802 ] /* steps */
4803 } /* join_explain */
4804 }
4805 ] /* steps */
4806 } 0 0
4807 set optimizer_switch=@old_opt_switch;
4808 DROP TABLE t1,t2;
4809 create table t1 (a int);
4810 insert into t1 values(1);
4811 create table t2 (a int);
4812 insert into t2 values(1);
4813 select * from t1,t2;
4814 a a
4815 1 1
4816 select * from information_schema.OPTIMIZER_TRACE;
4817 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
4818 select * from t1,t2 {
4819 "steps": [
4820 {
4821 "join_optimization": {
4822 "select#": 1,
4823 "steps": [
4824 {
4825 "table_dependencies": [
4826 {
4827 "table": "`t1`",
4828 "row_may_be_null": false,
4829 "map_bit": 0,
4830 "depends_on_map_bits": [
4831 ] /* depends_on_map_bits */
4832 },
4833 {
4834 "table": "`t2`",
4835 "row_may_be_null": false,
4836 "map_bit": 1,
4837 "depends_on_map_bits": [
4838 ] /* depends_on_map_bits */
4839 }
4840 ] /* table_dependencies */
4841 },
4842 {
4843 "rows_estimation": [
4844 {
4845 "table": "`t1`",
4846 "rows": 1,
4847 "cost": 1,
4848 "table_type": "system",
4849 "empty": false
4850 },
4851 {
4852 "table": "`t2`",
4853 "rows": 1,
4854 "cost": 1,
4855 "table_type": "system",
4856 "empty": false
4857 }
4858 ] /* rows_estimation */
4859 },
4860 {
4861 "attaching_conditions_to_tables": {
4862 "original_condition": null,
4863 "attached_conditions_computation": [
4864 ] /* attached_conditions_computation */,
4865 "attached_conditions_summary": [
4866 ] /* attached_conditions_summary */
4867 } /* attaching_conditions_to_tables */
4868 },
4869 {
4870 "refine_plan": [
4871 ] /* refine_plan */
4872 }
4873 ] /* steps */
4874 } /* join_optimization */
4875 },
4876 {
4877 "join_execution": {
4878 "select#": 1,
4879 "steps": [
4880 ] /* steps */
4881 } /* join_execution */
4882 }
4883 ] /* steps */
4884 } 0 0
4885 create table t3 (a int, b int);
4886 create table t4 (a int primary key);
4887 insert into t4 values(1),(2);
4888 prepare stmt from 'select * from t3 where (a,a,b) in (select * from t1,t2,t4)';
4889 select trace from information_schema.OPTIMIZER_TRACE;
4890 trace
4891 {
4892 "steps": [
4893 {
4894 "join_preparation": {
4895 "select#": 1,
4896 "steps": [
4897 {
4898 "join_preparation": {
4899 "select#": 2,
4900 "steps": [
4901 {
4902 "expanded_query": "/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4`"
4903 }
4904 ] /* steps */
4905 } /* join_preparation */
4906 },
4907 {
4908 "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`)"
4909 },
4910 {
4911 "transformation": {
4912 "select#": 2,
4913 "from": "IN (SELECT)",
4914 "to": "semijoin",
4915 "chosen": true,
4916 "transformation_to_semi_join": {
4917 "subquery_predicate": "(`t3`.`a`,`t3`.`a`,`t3`.`b`) in (/* select#2 */ select `t1`.`a`,`t2`.`a`,`t4`.`a` from `t1` join `t2` join `t4`)",
4918 "embedded in": "WHERE",
4919 "evaluating_constant_semijoin_conditions": [
4920 ] /* evaluating_constant_semijoin_conditions */,
4921 "semi-join condition": "((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))",
4922 "decorrelated_predicates": [
4923 {
4924 "outer": "`t3`.`a`",
4925 "inner": "`t1`.`a`"
4926 },
4927 {
4928 "outer": "`t3`.`a`",
4929 "inner": "`t2`.`a`"
4930 },
4931 {
4932 "outer": "`t3`.`b`",
4933 "inner": "`t4`.`a`"
4934 }
4935 ] /* decorrelated_predicates */
4936 } /* transformation_to_semi_join */
4937 } /* transformation */
4938 },
4939 {
4940 "transformations_to_nested_joins": {
4941 "transformations": [
4942 "semijoin"
4943 ] /* transformations */,
4944 "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`))"
4945 } /* transformations_to_nested_joins */
4946 }
4947 ] /* steps */
4948 } /* join_preparation */
4949 }
4950 ] /* steps */
4951 }
4952 execute stmt;
4953 a b
4954 select trace from information_schema.OPTIMIZER_TRACE;
4955 trace
4956 {
4957 "steps": [
4958 {
4959 "join_optimization": {
4960 "select#": 1,
4961 "steps": [
4962 {
4963 "condition_processing": {
4964 "condition": "WHERE",
4965 "original_condition": "((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))",
4966 "steps": [
4967 {
4968 "transformation": "equality_propagation",
4969 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
4970 },
4971 {
4972 "transformation": "constant_propagation",
4973 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
4974 },
4975 {
4976 "transformation": "trivial_condition_removal",
4977 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
4978 }
4979 ] /* steps */
4980 } /* condition_processing */
4981 },
4982 {
4983 "substitute_generated_columns": {
4984 } /* substitute_generated_columns */
4985 },
4986 {
4987 "table_dependencies": [
4988 {
4989 "table": "`t3`",
4990 "row_may_be_null": false,
4991 "map_bit": 0,
4992 "depends_on_map_bits": [
4993 ] /* depends_on_map_bits */
4994 },
4995 {
4996 "table": "`t1`",
4997 "row_may_be_null": false,
4998 "map_bit": 1,
4999 "depends_on_map_bits": [
5000 ] /* depends_on_map_bits */
5001 },
5002 {
5003 "table": "`t2`",
5004 "row_may_be_null": false,
5005 "map_bit": 2,
5006 "depends_on_map_bits": [
5007 ] /* depends_on_map_bits */
5008 },
5009 {
5010 "table": "`t4`",
5011 "row_may_be_null": false,
5012 "map_bit": 3,
5013 "depends_on_map_bits": [
5014 ] /* depends_on_map_bits */
5015 }
5016 ] /* table_dependencies */
5017 },
5018 {
5019 "ref_optimizer_key_uses": [
5020 {
5021 "table": "`t4`",
5022 "field": "a",
5023 "equals": "`t3`.`b`",
5024 "null_rejecting": true
5025 }
5026 ] /* ref_optimizer_key_uses */
5027 },
5028 {
5029 "pulled_out_semijoin_tables": [
5030 {
5031 "table": "`t4`",
5032 "functionally_dependent": true
5033 }
5034 ] /* pulled_out_semijoin_tables */
5035 },
5036 {
5037 "rows_estimation": [
5038 {
5039 "table": "`t3`",
5040 "rows": 1,
5041 "cost": 1,
5042 "table_type": "system",
5043 "empty": true
5044 },
5045 {
5046 "table": "`t1`",
5047 "table_scan": {
5048 "rows": 1,
5049 "cost": 0.500427
5050 } /* table_scan */
5051 },
5052 {
5053 "table": "`t2`",
5054 "table_scan": {
5055 "rows": 1,
5056 "cost": 0.500427
5057 } /* table_scan */
5058 },
5059 {
5060 "table": "`t4`",
5061 "table_scan": {
5062 "rows": 2,
5063 "cost": 0.500854
5064 } /* table_scan */
5065 }
5066 ] /* rows_estimation */
5067 },
5068 {
5069 "execution_plan_for_potential_materialization": {
5070 "steps": [
5071 ] /* steps */
5072 } /* execution_plan_for_potential_materialization */
5073 },
5074 {
5075 "considered_execution_plans": [
5076 {
5077 "plan_prefix": [
5078 "`t3`"
5079 ] /* plan_prefix */,
5080 "table": "`t1`",
5081 "best_access_path": {
5082 "considered_access_paths": [
5083 {
5084 "rows_to_scan": 1,
5085 "filtering_effect": [
5086 ] /* filtering_effect */,
5087 "final_filtering_effect": 1,
5088 "access_type": "scan",
5089 "resulting_rows": 1,
5090 "cost": 0.600427,
5091 "chosen": true
5092 }
5093 ] /* considered_access_paths */
5094 } /* best_access_path */,
5095 "condition_filtering_pct": 100,
5096 "rows_for_plan": 1,
5097 "cost_for_plan": 0.600427,
5098 "semijoin_strategy_choice": [
5099 ] /* semijoin_strategy_choice */,
5100 "rest_of_plan": [
5101 {
5102 "plan_prefix": [
5103 "`t3`",
5104 "`t1`"
5105 ] /* plan_prefix */,
5106 "table": "`t2`",
5107 "best_access_path": {
5108 "considered_access_paths": [
5109 {
5110 "rows_to_scan": 1,
5111 "filtering_effect": [
5112 ] /* filtering_effect */,
5113 "final_filtering_effect": 1,
5114 "access_type": "scan",
5115 "using_join_cache": true,
5116 "buffers_needed": 1,
5117 "resulting_rows": 1,
5118 "cost": 0.600437,
5119 "chosen": true
5120 }
5121 ] /* considered_access_paths */
5122 } /* best_access_path */,
5123 "condition_filtering_pct": 100,
5124 "rows_for_plan": 1,
5125 "cost_for_plan": 1.20086,
5126 "semijoin_strategy_choice": [
5127 ] /* semijoin_strategy_choice */,
5128 "rest_of_plan": [
5129 {
5130 "plan_prefix": [
5131 "`t3`",
5132 "`t1`",
5133 "`t2`"
5134 ] /* plan_prefix */,
5135 "table": "`t4`",
5136 "best_access_path": {
5137 "considered_access_paths": [
5138 {
5139 "access_type": "eq_ref",
5140 "index": "PRIMARY",
5141 "rows": 1,
5142 "cost": 0.1,
5143 "chosen": true
5144 },
5145 {
5146 "access_type": "scan",
5147 "cost": 0.700854,
5148 "rows": 2,
5149 "chosen": false,
5150 "cause": "cost"
5151 }
5152 ] /* considered_access_paths */
5153 } /* best_access_path */,
5154 "condition_filtering_pct": 100,
5155 "rows_for_plan": 1,
5156 "cost_for_plan": 1.30086,
5157 "semijoin_strategy_choice": [
5158 {
5159 "strategy": "DuplicatesWeedout",
5160 "cost": 2.50086,
5161 "rows": 1,
5162 "duplicate_tables_left": true,
5163 "chosen": true
5164 }
5165 ] /* semijoin_strategy_choice */,
5166 "chosen": true
5167 }
5168 ] /* rest_of_plan */
5169 },
5170 {
5171 "plan_prefix": [
5172 "`t3`",
5173 "`t1`"
5174 ] /* plan_prefix */,
5175 "table": "`t4`",
5176 "best_access_path": {
5177 "considered_access_paths": [
5178 {
5179 "access_type": "eq_ref",
5180 "index": "PRIMARY",
5181 "rows": 1,
5182 "cost": 0.1,
5183 "chosen": true
5184 },
5185 {
5186 "access_type": "scan",
5187 "cost": 0.700854,
5188 "rows": 2,
5189 "chosen": false,
5190 "cause": "cost"
5191 }
5192 ] /* considered_access_paths */
5193 } /* best_access_path */,
5194 "condition_filtering_pct": 100,
5195 "rows_for_plan": 1,
5196 "cost_for_plan": 0.700427,
5197 "semijoin_strategy_choice": [
5198 ] /* semijoin_strategy_choice */,
5199 "rest_of_plan": [
5200 {
5201 "plan_prefix": [
5202 "`t3`",
5203 "`t1`",
5204 "`t4`"
5205 ] /* plan_prefix */,
5206 "table": "`t2`",
5207 "best_access_path": {
5208 "considered_access_paths": [
5209 {
5210 "rows_to_scan": 1,
5211 "filtering_effect": [
5212 ] /* filtering_effect */,
5213 "final_filtering_effect": 1,
5214 "access_type": "scan",
5215 "using_join_cache": true,
5216 "buffers_needed": 1,
5217 "resulting_rows": 1,
5218 "cost": 0.600444,
5219 "chosen": true
5220 }
5221 ] /* considered_access_paths */
5222 } /* best_access_path */,
5223 "condition_filtering_pct": 100,
5224 "rows_for_plan": 1,
5225 "cost_for_plan": 1.30087,
5226 "semijoin_strategy_choice": [
5227 {
5228 "strategy": "DuplicatesWeedout",
5229 "cost": 2.50087,
5230 "rows": 1,
5231 "duplicate_tables_left": true,
5232 "chosen": true
5233 }
5234 ] /* semijoin_strategy_choice */,
5235 "pruned_by_cost": true
5236 }
5237 ] /* rest_of_plan */
5238 }
5239 ] /* rest_of_plan */
5240 },
5241 {
5242 "plan_prefix": [
5243 "`t3`"
5244 ] /* plan_prefix */,
5245 "table": "`t2`",
5246 "best_access_path": {
5247 "considered_access_paths": [
5248 {
5249 "rows_to_scan": 1,
5250 "filtering_effect": [
5251 ] /* filtering_effect */,
5252 "final_filtering_effect": 1,
5253 "access_type": "scan",
5254 "resulting_rows": 1,
5255 "cost": 0.600427,
5256 "chosen": true
5257 }
5258 ] /* considered_access_paths */
5259 } /* best_access_path */,
5260 "condition_filtering_pct": 100,
5261 "rows_for_plan": 1,
5262 "cost_for_plan": 0.600427,
5263 "semijoin_strategy_choice": [
5264 ] /* semijoin_strategy_choice */,
5265 "pruned_by_heuristic": true
5266 },
5267 {
5268 "plan_prefix": [
5269 "`t3`"
5270 ] /* plan_prefix */,
5271 "table": "`t4`",
5272 "best_access_path": {
5273 "considered_access_paths": [
5274 {
5275 "access_type": "eq_ref",
5276 "index": "PRIMARY",
5277 "rows": 1,
5278 "cost": 0.1,
5279 "chosen": true
5280 },
5281 {
5282 "access_type": "scan",
5283 "cost": 0.700854,
5284 "rows": 2,
5285 "chosen": false,
5286 "cause": "cost"
5287 }
5288 ] /* considered_access_paths */
5289 } /* best_access_path */,
5290 "condition_filtering_pct": 100,
5291 "rows_for_plan": 1,
5292 "cost_for_plan": 0.1,
5293 "semijoin_strategy_choice": [
5294 ] /* semijoin_strategy_choice */,
5295 "rest_of_plan": [
5296 {
5297 "plan_prefix": [
5298 "`t3`",
5299 "`t4`"
5300 ] /* plan_prefix */,
5301 "table": "`t1`",
5302 "best_access_path": {
5303 "considered_access_paths": [
5304 {
5305 "rows_to_scan": 1,
5306 "filtering_effect": [
5307 ] /* filtering_effect */,
5308 "final_filtering_effect": 1,
5309 "access_type": "scan",
5310 "using_join_cache": true,
5311 "buffers_needed": 1,
5312 "resulting_rows": 1,
5313 "cost": 0.600435,
5314 "chosen": true
5315 }
5316 ] /* considered_access_paths */
5317 } /* best_access_path */,
5318 "condition_filtering_pct": 100,
5319 "rows_for_plan": 1,
5320 "cost_for_plan": 0.700435,
5321 "semijoin_strategy_choice": [
5322 ] /* semijoin_strategy_choice */,
5323 "rest_of_plan": [
5324 {
5325 "plan_prefix": [
5326 "`t3`",
5327 "`t4`",
5328 "`t1`"
5329 ] /* plan_prefix */,
5330 "table": "`t2`",
5331 "best_access_path": {
5332 "considered_access_paths": [
5333 {
5334 "rows_to_scan": 1,
5335 "filtering_effect": [
5336 ] /* filtering_effect */,
5337 "final_filtering_effect": 1,
5338 "access_type": "scan",
5339 "using_join_cache": true,
5340 "buffers_needed": 1,
5341 "resulting_rows": 1,
5342 "cost": 0.600444,
5343 "chosen": true
5344 }
5345 ] /* considered_access_paths */
5346 } /* best_access_path */,
5347 "condition_filtering_pct": 100,
5348 "rows_for_plan": 1,
5349 "cost_for_plan": 1.30088,
5350 "semijoin_strategy_choice": [
5351 {
5352 "strategy": "FirstMatch",
5353 "recalculate_access_paths_and_cost": {
5354 "tables": [
5355 {
5356 "table": "`t1`",
5357 "best_access_path": {
5358 "considered_access_paths": [
5359 {
5360 "rows_to_scan": 1,
5361 "filtering_effect": [
5362 ] /* filtering_effect */,
5363 "final_filtering_effect": 1,
5364 "access_type": "scan",
5365 "resulting_rows": 1,
5366 "cost": 0.600427,
5367 "chosen": true
5368 }
5369 ] /* considered_access_paths */
5370 } /* best_access_path */
5371 },
5372 {
5373 "table": "`t2`",
5374 "best_access_path": {
5375 "considered_access_paths": [
5376 {
5377 "rows_to_scan": 1,
5378 "filtering_effect": [
5379 ] /* filtering_effect */,
5380 "final_filtering_effect": 1,
5381 "access_type": "scan",
5382 "resulting_rows": 1,
5383 "cost": 0.600427,
5384 "chosen": true
5385 }
5386 ] /* considered_access_paths */
5387 } /* best_access_path */
5388 }
5389 ] /* tables */
5390 } /* recalculate_access_paths_and_cost */,
5391 "cost": 1.30085,
5392 "rows": 1,
5393 "chosen": true
5394 },
5395 {
5396 "strategy": "DuplicatesWeedout",
5397 "cost": 2.50088,
5398 "rows": 1,
5399 "duplicate_tables_left": false,
5400 "chosen": false
5401 }
5402 ] /* semijoin_strategy_choice */,
5403 "chosen": true
5404 }
5405 ] /* rest_of_plan */
5406 },
5407 {
5408 "plan_prefix": [
5409 "`t3`",
5410 "`t4`"
5411 ] /* plan_prefix */,
5412 "table": "`t2`",
5413 "best_access_path": {
5414 "considered_access_paths": [
5415 {
5416 "rows_to_scan": 1,
5417 "filtering_effect": [
5418 ] /* filtering_effect */,
5419 "final_filtering_effect": 1,
5420 "access_type": "scan",
5421 "using_join_cache": true,
5422 "buffers_needed": 1,
5423 "resulting_rows": 1,
5424 "cost": 0.600435,
5425 "chosen": true
5426 }
5427 ] /* considered_access_paths */
5428 } /* best_access_path */,
5429 "condition_filtering_pct": 100,
5430 "rows_for_plan": 1,
5431 "cost_for_plan": 0.700435,
5432 "semijoin_strategy_choice": [
5433 ] /* semijoin_strategy_choice */,
5434 "pruned_by_heuristic": true
5435 }
5436 ] /* rest_of_plan */
5437 },
5438 {
5439 "final_semijoin_strategy": "FirstMatch",
5440 "recalculate_access_paths_and_cost": {
5441 "tables": [
5442 {
5443 "table": "`t1`",
5444 "best_access_path": {
5445 "considered_access_paths": [
5446 {
5447 "rows_to_scan": 1,
5448 "filtering_effect": [
5449 ] /* filtering_effect */,
5450 "final_filtering_effect": 1,
5451 "access_type": "scan",
5452 "resulting_rows": 1,
5453 "cost": 0.600427,
5454 "chosen": true
5455 }
5456 ] /* considered_access_paths */
5457 } /* best_access_path */
5458 },
5459 {
5460 "table": "`t2`",
5461 "best_access_path": {
5462 "considered_access_paths": [
5463 {
5464 "rows_to_scan": 1,
5465 "filtering_effect": [
5466 ] /* filtering_effect */,
5467 "final_filtering_effect": 1,
5468 "access_type": "scan",
5469 "resulting_rows": 1,
5470 "cost": 0.600427,
5471 "chosen": true
5472 }
5473 ] /* considered_access_paths */
5474 } /* best_access_path */
5475 }
5476 ] /* tables */
5477 } /* recalculate_access_paths_and_cost */
5478 }
5479 ] /* considered_execution_plans */
5480 }
5481 ] /* steps */,
5482 "empty_result": {
5483 "cause": "no matching row in const table"
5484 } /* empty_result */
5485 } /* join_optimization */
5486 },
5487 {
5488 "join_execution": {
5489 "select#": 1,
5490 "steps": [
5491 ] /* steps */
5492 } /* join_execution */
5493 }
5494 ] /* steps */
5495 }
5496 execute stmt;
5497 a b
5498 select trace from information_schema.OPTIMIZER_TRACE;
5499 trace
5500 {
5501 "steps": [
5502 {
5503 "join_optimization": {
5504 "select#": 1,
5505 "steps": [
5506 {
5507 "condition_processing": {
5508 "condition": "WHERE",
5509 "original_condition": "((`t3`.`a` = `t1`.`a`) and (`t3`.`a` = `t2`.`a`) and (`t3`.`b` = `t4`.`a`))",
5510 "steps": [
5511 {
5512 "transformation": "equality_propagation",
5513 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5514 },
5515 {
5516 "transformation": "constant_propagation",
5517 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5518 },
5519 {
5520 "transformation": "trivial_condition_removal",
5521 "resulting_condition": "(multiple equal(`t3`.`a`, `t1`.`a`, `t2`.`a`) and multiple equal(`t3`.`b`, `t4`.`a`))"
5522 }
5523 ] /* steps */
5524 } /* condition_processing */
5525 },
5526 {
5527 "substitute_generated_columns": {
5528 } /* substitute_generated_columns */
5529 },
5530 {
5531 "table_dependencies": [
5532 {
5533 "table": "`t3`",
5534 "row_may_be_null": false,
5535 "map_bit": 0,
5536 "depends_on_map_bits": [
5537 ] /* depends_on_map_bits */
5538 },
5539 {
5540 "table": "`t1`",
5541 "row_may_be_null": false,
5542 "map_bit": 1,
5543 "depends_on_map_bits": [
5544 ] /* depends_on_map_bits */
5545 },
5546 {
5547 "table": "`t2`",
5548 "row_may_be_null": false,
5549 "map_bit": 2,
5550 "depends_on_map_bits": [
5551 ] /* depends_on_map_bits */
5552 },
5553 {
5554 "table": "`t4`",
5555 "row_may_be_null": false,
5556 "map_bit": 3,
5557 "depends_on_map_bits": [
5558 ] /* depends_on_map_bits */
5559 }
5560 ] /* table_dependencies */
5561 },
5562 {
5563 "ref_optimizer_key_uses": [
5564 {
5565 "table": "`t4`",
5566 "field": "a",
5567 "equals": "`t3`.`b`",
5568 "null_rejecting": true
5569 }
5570 ] /* ref_optimizer_key_uses */
5571 },
5572 {
5573 "rows_estimation": [
5574 {
5575 "table": "`t3`",
5576 "rows": 1,
5577 "cost": 1,
5578 "table_type": "system",
5579 "empty": true
5580 },
5581 {
5582 "table": "`t1`",
5583 "table_scan": {
5584 "rows": 1,
5585 "cost": 0.500427
5586 } /* table_scan */
5587 },
5588 {
5589 "table": "`t2`",
5590 "table_scan": {
5591 "rows": 1,
5592 "cost": 0.500427
5593 } /* table_scan */
5594 },
5595 {
5596 "table": "`t4`",
5597 "table_scan": {
5598 "rows": 2,
5599 "cost": 0.500854
5600 } /* table_scan */
5601 }
5602 ] /* rows_estimation */
5603 },
5604 {
5605 "execution_plan_for_potential_materialization": {
5606 "steps": [
5607 ] /* steps */
5608 } /* execution_plan_for_potential_materialization */
5609 },
5610 {
5611 "considered_execution_plans": [
5612 {
5613 "plan_prefix": [
5614 "`t3`"
5615 ] /* plan_prefix */,
5616 "table": "`t1`",
5617 "best_access_path": {
5618 "considered_access_paths": [
5619 {
5620 "rows_to_scan": 1,
5621 "filtering_effect": [
5622 ] /* filtering_effect */,
5623 "final_filtering_effect": 1,
5624 "access_type": "scan",
5625 "resulting_rows": 1,
5626 "cost": 0.600427,
5627 "chosen": true
5628 }
5629 ] /* considered_access_paths */
5630 } /* best_access_path */,
5631 "condition_filtering_pct": 100,
5632 "rows_for_plan": 1,
5633 "cost_for_plan": 0.600427,
5634 "semijoin_strategy_choice": [
5635 ] /* semijoin_strategy_choice */,
5636 "rest_of_plan": [
5637 {
5638 "plan_prefix": [
5639 "`t3`",
5640 "`t1`"
5641 ] /* plan_prefix */,
5642 "table": "`t2`",
5643 "best_access_path": {
5644 "considered_access_paths": [
5645 {
5646 "rows_to_scan": 1,
5647 "filtering_effect": [
5648 ] /* filtering_effect */,
5649 "final_filtering_effect": 1,
5650 "access_type": "scan",
5651 "using_join_cache": true,
5652 "buffers_needed": 1,
5653 "resulting_rows": 1,
5654 "cost": 0.600437,
5655 "chosen": true
5656 }
5657 ] /* considered_access_paths */
5658 } /* best_access_path */,
5659 "condition_filtering_pct": 100,
5660 "rows_for_plan": 1,
5661 "cost_for_plan": 1.20086,
5662 "semijoin_strategy_choice": [
5663 ] /* semijoin_strategy_choice */,
5664 "rest_of_plan": [
5665 {
5666 "plan_prefix": [
5667 "`t3`",
5668 "`t1`",
5669 "`t2`"
5670 ] /* plan_prefix */,
5671 "table": "`t4`",
5672 "best_access_path": {
5673 "considered_access_paths": [
5674 {
5675 "access_type": "eq_ref",
5676 "index": "PRIMARY",
5677 "rows": 1,
5678 "cost": 0.1,
5679 "chosen": true
5680 },
5681 {
5682 "access_type": "scan",
5683 "cost": 0.700854,
5684 "rows": 2,
5685 "chosen": false,
5686 "cause": "cost"
5687 }
5688 ] /* considered_access_paths */
5689 } /* best_access_path */,
5690 "condition_filtering_pct": 100,
5691 "rows_for_plan": 1,
5692 "cost_for_plan": 1.30086,
5693 "semijoin_strategy_choice": [
5694 {
5695 "strategy": "DuplicatesWeedout",
5696 "cost": 2.50086,
5697 "rows": 1,
5698 "duplicate_tables_left": true,
5699 "chosen": true
5700 }
5701 ] /* semijoin_strategy_choice */,
5702 "chosen": true
5703 }
5704 ] /* rest_of_plan */
5705 },
5706 {
5707 "plan_prefix": [
5708 "`t3`",
5709 "`t1`"
5710 ] /* plan_prefix */,
5711 "table": "`t4`",
5712 "best_access_path": {
5713 "considered_access_paths": [
5714 {
5715 "access_type": "eq_ref",
5716 "index": "PRIMARY",
5717 "rows": 1,
5718 "cost": 0.1,
5719 "chosen": true
5720 },
5721 {
5722 "access_type": "scan",
5723 "cost": 0.700854,
5724 "rows": 2,
5725 "chosen": false,
5726 "cause": "cost"
5727 }
5728 ] /* considered_access_paths */
5729 } /* best_access_path */,
5730 "condition_filtering_pct": 100,
5731 "rows_for_plan": 1,
5732 "cost_for_plan": 0.700427,
5733 "semijoin_strategy_choice": [
5734 ] /* semijoin_strategy_choice */,
5735 "rest_of_plan": [
5736 {
5737 "plan_prefix": [
5738 "`t3`",
5739 "`t1`",
5740 "`t4`"
5741 ] /* plan_prefix */,
5742 "table": "`t2`",
5743 "best_access_path": {
5744 "considered_access_paths": [
5745 {
5746 "rows_to_scan": 1,
5747 "filtering_effect": [
5748 ] /* filtering_effect */,
5749 "final_filtering_effect": 1,
5750 "access_type": "scan",
5751 "using_join_cache": true,
5752 "buffers_needed": 1,
5753 "resulting_rows": 1,
5754 "cost": 0.600444,
5755 "chosen": true
5756 }
5757 ] /* considered_access_paths */
5758 } /* best_access_path */,
5759 "condition_filtering_pct": 100,
5760 "rows_for_plan": 1,
5761 "cost_for_plan": 1.30087,
5762 "semijoin_strategy_choice": [
5763 {
5764 "strategy": "DuplicatesWeedout",
5765 "cost": 2.50087,
5766 "rows": 1,
5767 "duplicate_tables_left": true,
5768 "chosen": true
5769 }
5770 ] /* semijoin_strategy_choice */,
5771 "pruned_by_cost": true
5772 }
5773 ] /* rest_of_plan */
5774 }
5775 ] /* rest_of_plan */
5776 },
5777 {
5778 "plan_prefix": [
5779 "`t3`"
5780 ] /* plan_prefix */,
5781 "table": "`t2`",
5782 "best_access_path": {
5783 "considered_access_paths": [
5784 {
5785 "rows_to_scan": 1,
5786 "filtering_effect": [
5787 ] /* filtering_effect */,
5788 "final_filtering_effect": 1,
5789 "access_type": "scan",
5790 "resulting_rows": 1,
5791 "cost": 0.600427,
5792 "chosen": true
5793 }
5794 ] /* considered_access_paths */
5795 } /* best_access_path */,
5796 "condition_filtering_pct": 100,
5797 "rows_for_plan": 1,
5798 "cost_for_plan": 0.600427,
5799 "semijoin_strategy_choice": [
5800 ] /* semijoin_strategy_choice */,
5801 "pruned_by_heuristic": true
5802 },
5803 {
5804 "plan_prefix": [
5805 "`t3`"
5806 ] /* plan_prefix */,
5807 "table": "`t4`",
5808 "best_access_path": {
5809 "considered_access_paths": [
5810 {
5811 "access_type": "eq_ref",
5812 "index": "PRIMARY",
5813 "rows": 1,
5814 "cost": 0.1,
5815 "chosen": true
5816 },
5817 {
5818 "access_type": "scan",
5819 "cost": 0.700854,
5820 "rows": 2,
5821 "chosen": false,
5822 "cause": "cost"
5823 }
5824 ] /* considered_access_paths */
5825 } /* best_access_path */,
5826 "condition_filtering_pct": 100,
5827 "rows_for_plan": 1,
5828 "cost_for_plan": 0.1,
5829 "semijoin_strategy_choice": [
5830 ] /* semijoin_strategy_choice */,
5831 "rest_of_plan": [
5832 {
5833 "plan_prefix": [
5834 "`t3`",
5835 "`t4`"
5836 ] /* plan_prefix */,
5837 "table": "`t1`",
5838 "best_access_path": {
5839 "considered_access_paths": [
5840 {
5841 "rows_to_scan": 1,
5842 "filtering_effect": [
5843 ] /* filtering_effect */,
5844 "final_filtering_effect": 1,
5845 "access_type": "scan",
5846 "using_join_cache": true,
5847 "buffers_needed": 1,
5848 "resulting_rows": 1,
5849 "cost": 0.600435,
5850 "chosen": true
5851 }
5852 ] /* considered_access_paths */
5853 } /* best_access_path */,
5854 "condition_filtering_pct": 100,
5855 "rows_for_plan": 1,
5856 "cost_for_plan": 0.700435,
5857 "semijoin_strategy_choice": [
5858 ] /* semijoin_strategy_choice */,
5859 "rest_of_plan": [
5860 {
5861 "plan_prefix": [
5862 "`t3`",
5863 "`t4`",
5864 "`t1`"
5865 ] /* plan_prefix */,
5866 "table": "`t2`",
5867 "best_access_path": {
5868 "considered_access_paths": [
5869 {
5870 "rows_to_scan": 1,
5871 "filtering_effect": [
5872 ] /* filtering_effect */,
5873 "final_filtering_effect": 1,
5874 "access_type": "scan",
5875 "using_join_cache": true,
5876 "buffers_needed": 1,
5877 "resulting_rows": 1,
5878 "cost": 0.600444,
5879 "chosen": true
5880 }
5881 ] /* considered_access_paths */
5882 } /* best_access_path */,
5883 "condition_filtering_pct": 100,
5884 "rows_for_plan": 1,
5885 "cost_for_plan": 1.30088,
5886 "semijoin_strategy_choice": [
5887 {
5888 "strategy": "FirstMatch",
5889 "recalculate_access_paths_and_cost": {
5890 "tables": [
5891 {
5892 "table": "`t1`",
5893 "best_access_path": {
5894 "considered_access_paths": [
5895 {
5896 "rows_to_scan": 1,
5897 "filtering_effect": [
5898 ] /* filtering_effect */,
5899 "final_filtering_effect": 1,
5900 "access_type": "scan",
5901 "resulting_rows": 1,
5902 "cost": 0.600427,
5903 "chosen": true
5904 }
5905 ] /* considered_access_paths */
5906 } /* best_access_path */
5907 },
5908 {
5909 "table": "`t2`",
5910 "best_access_path": {
5911 "considered_access_paths": [
5912 {
5913 "rows_to_scan": 1,
5914 "filtering_effect": [
5915 ] /* filtering_effect */,
5916 "final_filtering_effect": 1,
5917 "access_type": "scan",
5918 "resulting_rows": 1,
5919 "cost": 0.600427,
5920 "chosen": true
5921 }
5922 ] /* considered_access_paths */
5923 } /* best_access_path */
5924 }
5925 ] /* tables */
5926 } /* recalculate_access_paths_and_cost */,
5927 "cost": 1.30085,
5928 "rows": 1,
5929 "chosen": true
5930 },
5931 {
5932 "strategy": "DuplicatesWeedout",
5933 "cost": 2.50088,
5934 "rows": 1,
5935 "duplicate_tables_left": false,
5936 "chosen": false
5937 }
5938 ] /* semijoin_strategy_choice */,
5939 "chosen": true
5940 }
5941 ] /* rest_of_plan */
5942 },
5943 {
5944 "plan_prefix": [
5945 "`t3`",
5946 "`t4`"
5947 ] /* plan_prefix */,
5948 "table": "`t2`",
5949 "best_access_path": {
5950 "considered_access_paths": [
5951 {
5952 "rows_to_scan": 1,
5953 "filtering_effect": [
5954 ] /* filtering_effect */,
5955 "final_filtering_effect": 1,
5956 "access_type": "scan",
5957 "using_join_cache": true,
5958 "buffers_needed": 1,
5959 "resulting_rows": 1,
5960 "cost": 0.600435,
5961 "chosen": true
5962 }
5963 ] /* considered_access_paths */
5964 } /* best_access_path */,
5965 "condition_filtering_pct": 100,
5966 "rows_for_plan": 1,
5967 "cost_for_plan": 0.700435,
5968 "semijoin_strategy_choice": [
5969 ] /* semijoin_strategy_choice */,
5970 "pruned_by_heuristic": true
5971 }
5972 ] /* rest_of_plan */
5973 },
5974 {
5975 "final_semijoin_strategy": "FirstMatch",
5976 "recalculate_access_paths_and_cost": {
5977 "tables": [
5978 {
5979 "table": "`t1`",
5980 "best_access_path": {
5981 "considered_access_paths": [
5982 {
5983 "rows_to_scan": 1,
5984 "filtering_effect": [
5985 ] /* filtering_effect */,
5986 "final_filtering_effect": 1,
5987 "access_type": "scan",
5988 "resulting_rows": 1,
5989 "cost": 0.600427,
5990 "chosen": true
5991 }
5992 ] /* considered_access_paths */
5993 } /* best_access_path */
5994 },
5995 {
5996 "table": "`t2`",
5997 "best_access_path": {
5998 "considered_access_paths": [
5999 {
6000 "rows_to_scan": 1,
6001 "filtering_effect": [
6002 ] /* filtering_effect */,
6003 "final_filtering_effect": 1,
6004 "access_type": "scan",
6005 "resulting_rows": 1,
6006 "cost": 0.600427,
6007 "chosen": true
6008 }
6009 ] /* considered_access_paths */
6010 } /* best_access_path */
6011 }
6012 ] /* tables */
6013 } /* recalculate_access_paths_and_cost */
6014 }
6015 ] /* considered_execution_plans */
6016 }
6017 ] /* steps */,
6018 "empty_result": {
6019 "cause": "no matching row in const table"
6020 } /* empty_result */
6021 } /* join_optimization */
6022 },
6023 {
6024 "join_execution": {
6025 "select#": 1,
6026 "steps": [
6027 ] /* steps */
6028 } /* join_execution */
6029 }
6030 ] /* steps */
6031 }
6032 DROP TABLE t1,t2,t3,t4;
6033 create table t1(a int);
6034 insert into t1 values(1),(1);
6035 create table t2(a int);
6036 insert into t2 values(1),(1);
6037 select * from t1 left join t2 on t2.a=500 where t2.a is NULL;
6038 a a
6039 1 NULL
6040 1 NULL
6041 select * from information_schema.OPTIMIZER_TRACE;
6042 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
6043 select * from t1 left join t2 on t2.a=500 where t2.a is NULL {
6044 "steps": [
6045 {
6046 "join_optimization": {
6047 "select#": 1,
6048 "steps": [
6049 {
6050 "condition_processing": {
6051 "condition": "WHERE",
6052 "original_condition": "(`t2`.`a` is null)",
6053 "steps": [
6054 {
6055 "transformation": "equality_propagation",
6056 "resulting_condition": "(`t2`.`a` is null)"
6057 },
6058 {
6059 "transformation": "constant_propagation",
6060 "resulting_condition": "(`t2`.`a` is null)"
6061 },
6062 {
6063 "transformation": "trivial_condition_removal",
6064 "resulting_condition": "(`t2`.`a` is null)"
6065 }
6066 ] /* steps */
6067 } /* condition_processing */
6068 },
6069 {
6070 "substitute_generated_columns": {
6071 } /* substitute_generated_columns */
6072 },
6073 {
6074 "table_dependencies": [
6075 {
6076 "table": "`t1`",
6077 "row_may_be_null": false,
6078 "map_bit": 0,
6079 "depends_on_map_bits": [
6080 ] /* depends_on_map_bits */
6081 },
6082 {
6083 "table": "`t2`",
6084 "row_may_be_null": true,
6085 "map_bit": 1,
6086 "depends_on_map_bits": [
6087 0
6088 ] /* depends_on_map_bits */
6089 }
6090 ] /* table_dependencies */
6091 },
6092 {
6093 "ref_optimizer_key_uses": [
6094 ] /* ref_optimizer_key_uses */
6095 },
6096 {
6097 "rows_estimation": [
6098 {
6099 "table": "`t1`",
6100 "table_scan": {
6101 "rows": 2,
6102 "cost": 0.500854
6103 } /* table_scan */
6104 },
6105 {
6106 "table": "`t2`",
6107 "table_scan": {
6108 "rows": 2,
6109 "cost": 0.500854
6110 } /* table_scan */
6111 }
6112 ] /* rows_estimation */
6113 },
6114 {
6115 "considered_execution_plans": [
6116 {
6117 "plan_prefix": [
6118 ] /* plan_prefix */,
6119 "table": "`t1`",
6120 "best_access_path": {
6121 "considered_access_paths": [
6122 {
6123 "rows_to_scan": 2,
6124 "access_type": "scan",
6125 "resulting_rows": 2,
6126 "cost": 0.700854,
6127 "chosen": true
6128 }
6129 ] /* considered_access_paths */
6130 } /* best_access_path */,
6131 "condition_filtering_pct": 100,
6132 "rows_for_plan": 2,
6133 "cost_for_plan": 0.700854,
6134 "rest_of_plan": [
6135 {
6136 "plan_prefix": [
6137 "`t1`"
6138 ] /* plan_prefix */,
6139 "table": "`t2`",
6140 "best_access_path": {
6141 "considered_access_paths": [
6142 {
6143 "rows_to_scan": 2,
6144 "filtering_effect": [
6145 ] /* filtering_effect */,
6146 "final_filtering_effect": 0.5,
6147 "access_type": "scan",
6148 "using_join_cache": true,
6149 "buffers_needed": 1,
6150 "resulting_rows": 1,
6151 "cost": 0.800877,
6152 "chosen": true
6153 }
6154 ] /* considered_access_paths */
6155 } /* best_access_path */,
6156 "condition_filtering_pct": 100,
6157 "rows_for_plan": 2,
6158 "cost_for_plan": 1.50173,
6159 "chosen": true
6160 }
6161 ] /* rest_of_plan */
6162 }
6163 ] /* considered_execution_plans */
6164 },
6165 {
6166 "attaching_conditions_to_tables": {
6167 "original_condition": "(`t2`.`a` is null)",
6168 "attached_conditions_computation": [
6169 ] /* attached_conditions_computation */,
6170 "attached_conditions_summary": [
6171 {
6172 "table": "`t1`",
6173 "attached": null
6174 },
6175 {
6176 "table": "`t2`",
6177 "attached": "(<if>(found_match(t2), (`t2`.`a` is null), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))"
6178 }
6179 ] /* attached_conditions_summary */
6180 } /* attaching_conditions_to_tables */
6181 },
6182 {
6183 "finalizing_table_conditions": [
6184 {
6185 "table": "`t2`",
6186 "original_table_condition": "(<if>(found_match(t2), (`t2`.`a` is null), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))",
6187 "final_table_condition ": "(<if>(found_match(t2), (`t2`.`a` is null), true) and <if>(is_not_null_compl(t2), (`t2`.`a` = 500), true))"
6188 }
6189 ] /* finalizing_table_conditions */
6190 },
6191 {
6192 "refine_plan": [
6193 {
6194 "table": "`t1`"
6195 },
6196 {
6197 "table": "`t2`"
6198 }
6199 ] /* refine_plan */
6200 }
6201 ] /* steps */
6202 } /* join_optimization */
6203 },
6204 {
6205 "join_execution": {
6206 "select#": 1,
6207 "steps": [
6208 ] /* steps */
6209 } /* join_execution */
6210 }
6211 ] /* steps */
6212 } 0 0
6213 drop table t1,t2;
6214 create table t1(a int, b int);
6215 insert into t1 values(1,NULL),(NULL,2);
6216 create table t2(c int, d int);
6217 insert into t2 values(1,1),(2,2);
6218 select * from t1 where (t1.a,t1.b) not in (select c,d from t2 where c>0);
6219 a b
6220 select * from information_schema.OPTIMIZER_TRACE;
6221 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
6222 select * from t1 where (t1.a,t1.b) not in (select c,d from t2 where c>0) {
6223 "steps": [
6224 {
6225 "join_optimization": {
6226 "select#": 1,
6227 "steps": [
6228 {
6229 "condition_processing": {
6230 "condition": "WHERE",
6231 "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)",
6232 "steps": [
6233 {
6234 "transformation": "equality_propagation",
6235 "subselect_evaluation": [
6236 ] /* subselect_evaluation */,
6237 "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)"
6238 },
6239 {
6240 "transformation": "constant_propagation",
6241 "subselect_evaluation": [
6242 ] /* subselect_evaluation */,
6243 "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)"
6244 },
6245 {
6246 "transformation": "trivial_condition_removal",
6247 "subselect_evaluation": [
6248 ] /* subselect_evaluation */,
6249 "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)"
6250 }
6251 ] /* steps */
6252 } /* condition_processing */
6253 },
6254 {
6255 "substitute_generated_columns": {
6256 } /* substitute_generated_columns */
6257 },
6258 {
6259 "table_dependencies": [
6260 {
6261 "table": "`t1`",
6262 "row_may_be_null": false,
6263 "map_bit": 0,
6264 "depends_on_map_bits": [
6265 ] /* depends_on_map_bits */
6266 }
6267 ] /* table_dependencies */
6268 },
6269 {
6270 "ref_optimizer_key_uses": [
6271 ] /* ref_optimizer_key_uses */
6272 },
6273 {
6274 "rows_estimation": [
6275 {
6276 "table": "`t1`",
6277 "table_scan": {
6278 "rows": 2,
6279 "cost": 0.501099
6280 } /* table_scan */
6281 }
6282 ] /* rows_estimation */
6283 },
6284 {
6285 "considered_execution_plans": [
6286 {
6287 "plan_prefix": [
6288 ] /* plan_prefix */,
6289 "table": "`t1`",
6290 "best_access_path": {
6291 "considered_access_paths": [
6292 {
6293 "rows_to_scan": 2,
6294 "access_type": "scan",
6295 "resulting_rows": 2,
6296 "cost": 0.701099,
6297 "chosen": true
6298 }
6299 ] /* considered_access_paths */
6300 } /* best_access_path */,
6301 "condition_filtering_pct": 100,
6302 "rows_for_plan": 2,
6303 "cost_for_plan": 0.701099,
6304 "chosen": true
6305 }
6306 ] /* considered_execution_plans */
6307 },
6308 {
6309 "attaching_conditions_to_tables": {
6310 "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)",
6311 "attached_conditions_computation": [
6312 ] /* attached_conditions_computation */,
6313 "attached_conditions_summary": [
6314 {
6315 "table": "`t1`",
6316 "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)"
6317 }
6318 ] /* attached_conditions_summary */
6319 } /* attaching_conditions_to_tables */
6320 },
6321 {
6322 "finalizing_table_conditions": [
6323 {
6324 "table": "`t1`",
6325 "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)",
6326 "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)"
6327 }
6328 ] /* finalizing_table_conditions */
6329 },
6330 {
6331 "refine_plan": [
6332 {
6333 "table": "`t1`"
6334 }
6335 ] /* refine_plan */
6336 }
6337 ] /* steps */
6338 } /* join_optimization */
6339 },
6340 {
6341 "join_optimization": {
6342 "select#": 2,
6343 "steps": [
6344 {
6345 "condition_processing": {
6346 "condition": "WHERE",
6347 "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))",
6348 "steps": [
6349 {
6350 "transformation": "equality_propagation",
6351 "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))"
6352 },
6353 {
6354 "transformation": "constant_propagation",
6355 "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))"
6356 },
6357 {
6358 "transformation": "trivial_condition_removal",
6359 "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))"
6360 }
6361 ] /* steps */
6362 } /* condition_processing */
6363 },
6364 {
6365 "condition_processing": {
6366 "condition": "HAVING",
6367 "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))",
6368 "steps": [
6369 {
6370 "transformation": "constant_propagation",
6371 "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))"
6372 },
6373 {
6374 "transformation": "trivial_condition_removal",
6375 "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))"
6376 }
6377 ] /* steps */
6378 } /* condition_processing */
6379 },
6380 {
6381 "substitute_generated_columns": {
6382 } /* substitute_generated_columns */
6383 },
6384 {
6385 "table_dependencies": [
6386 {
6387 "table": "`t2`",
6388 "row_may_be_null": false,
6389 "map_bit": 0,
6390 "depends_on_map_bits": [
6391 ] /* depends_on_map_bits */
6392 }
6393 ] /* table_dependencies */
6394 },
6395 {
6396 "ref_optimizer_key_uses": [
6397 ] /* ref_optimizer_key_uses */
6398 },
6399 {
6400 "rows_estimation": [
6401 {
6402 "table": "`t2`",
6403 "table_scan": {
6404 "rows": 2,
6405 "cost": 0.501099
6406 } /* table_scan */
6407 }
6408 ] /* rows_estimation */
6409 },
6410 {
6411 "considered_execution_plans": [
6412 {
6413 "plan_prefix": [
6414 ] /* plan_prefix */,
6415 "table": "`t2`",
6416 "best_access_path": {
6417 "considered_access_paths": [
6418 {
6419 "rows_to_scan": 2,
6420 "filtering_effect": [
6421 ] /* filtering_effect */,
6422 "final_filtering_effect": 0.5,
6423 "access_type": "scan",
6424 "resulting_rows": 1,
6425 "cost": 0.701099,
6426 "chosen": true
6427 }
6428 ] /* considered_access_paths */
6429 } /* best_access_path */,
6430 "condition_filtering_pct": 100,
6431 "rows_for_plan": 1,
6432 "cost_for_plan": 0.701099,
6433 "chosen": true
6434 }
6435 ] /* considered_execution_plans */
6436 },
6437 {
6438 "transformation": {
6439 "select#": 2,
6440 "from": "IN (SELECT)",
6441 "to": "materialization",
6442 "has_nullable_expressions": true,
6443 "treat_UNKNOWN_as_FALSE": false,
6444 "possible": false,
6445 "cause": "cannot_handle_partial_matches"
6446 } /* transformation */
6447 },
6448 {
6449 "attaching_conditions_to_tables": {
6450 "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))",
6451 "attached_conditions_computation": [
6452 ] /* attached_conditions_computation */,
6453 "attached_conditions_summary": [
6454 {
6455 "table": "`t2`",
6456 "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))"
6457 }
6458 ] /* attached_conditions_summary */
6459 } /* attaching_conditions_to_tables */
6460 },
6461 {
6462 "finalizing_table_conditions": [
6463 {
6464 "table": "`t2`",
6465 "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))",
6466 "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))"
6467 }
6468 ] /* finalizing_table_conditions */
6469 },
6470 {
6471 "refine_plan": [
6472 {
6473 "table": "`t2`"
6474 }
6475 ] /* refine_plan */
6476 }
6477 ] /* steps */
6478 } /* join_optimization */
6479 },
6480 {
6481 "join_execution": {
6482 "select#": 1,
6483 "steps": [
6484 {
6485 "subselect_execution": {
6486 "select#": 2,
6487 "steps": [
6488 {
6489 "join_execution": {
6490 "select#": 2,
6491 "steps": [
6492 ] /* steps */
6493 } /* join_execution */
6494 }
6495 ] /* steps */
6496 } /* subselect_execution */
6497 },
6498 {
6499 "subselect_execution": {
6500 "select#": 2,
6501 "steps": [
6502 {
6503 "join_execution": {
6504 "select#": 2,
6505 "steps": [
6506 ] /* steps */
6507 } /* join_execution */
6508 }
6509 ] /* steps */
6510 } /* subselect_execution */
6511 }
6512 ] /* steps */
6513 } /* join_execution */
6514 }
6515 ] /* steps */
6516 } 0 0
6517 select t1.a,avg(t2.c) as moyenne from t1, t2 where t2.c>-1
6518 group by t1.a having moyenne<>0;
6519 a moyenne
6520 1 1.5000
6521 NULL 1.5000
6522 select trace from information_schema.OPTIMIZER_TRACE;
6523 trace
6524 {
6525 "steps": [
6526 {
6527 "join_optimization": {
6528 "select#": 1,
6529 "steps": [
6530 {
6531 "condition_processing": {
6532 "condition": "WHERE",
6533 "original_condition": "(`t2`.`c` > -(1))",
6534 "steps": [
6535 {
6536 "transformation": "equality_propagation",
6537 "resulting_condition": "(`t2`.`c` > -(1))"
6538 },
6539 {
6540 "transformation": "constant_propagation",
6541 "resulting_condition": "(`t2`.`c` > -(1))"
6542 },
6543 {
6544 "transformation": "trivial_condition_removal",
6545 "resulting_condition": "(`t2`.`c` > -(1))"
6546 }
6547 ] /* steps */
6548 } /* condition_processing */
6549 },
6550 {
6551 "condition_processing": {
6552 "condition": "HAVING",
6553 "original_condition": "(`moyenne` <> 0)",
6554 "steps": [
6555 {
6556 "transformation": "constant_propagation",
6557 "resulting_condition": "(`moyenne` <> 0)"
6558 },
6559 {
6560 "transformation": "trivial_condition_removal",
6561 "resulting_condition": "(`moyenne` <> 0)"
6562 }
6563 ] /* steps */
6564 } /* condition_processing */
6565 },
6566 {
6567 "substitute_generated_columns": {
6568 } /* substitute_generated_columns */
6569 },
6570 {
6571 "table_dependencies": [
6572 {
6573 "table": "`t1`",
6574 "row_may_be_null": false,
6575 "map_bit": 0,
6576 "depends_on_map_bits": [
6577 ] /* depends_on_map_bits */
6578 },
6579 {
6580 "table": "`t2`",
6581 "row_may_be_null": false,
6582 "map_bit": 1,
6583 "depends_on_map_bits": [
6584 ] /* depends_on_map_bits */
6585 }
6586 ] /* table_dependencies */
6587 },
6588 {
6589 "ref_optimizer_key_uses": [
6590 ] /* ref_optimizer_key_uses */
6591 },
6592 {
6593 "rows_estimation": [
6594 {
6595 "table": "`t1`",
6596 "table_scan": {
6597 "rows": 2,
6598 "cost": 0.501099
6599 } /* table_scan */
6600 },
6601 {
6602 "table": "`t2`",
6603 "table_scan": {
6604 "rows": 2,
6605 "cost": 0.501099
6606 } /* table_scan */
6607 }
6608 ] /* rows_estimation */
6609 },
6610 {
6611 "considered_execution_plans": [
6612 {
6613 "plan_prefix": [
6614 ] /* plan_prefix */,
6615 "table": "`t1`",
6616 "best_access_path": {
6617 "considered_access_paths": [
6618 {
6619 "rows_to_scan": 2,
6620 "access_type": "scan",
6621 "resulting_rows": 2,
6622 "cost": 0.701099,
6623 "chosen": true,
6624 "use_tmp_table": true
6625 }
6626 ] /* considered_access_paths */
6627 } /* best_access_path */,
6628 "condition_filtering_pct": 100,
6629 "rows_for_plan": 2,
6630 "cost_for_plan": 0.701099,
6631 "rest_of_plan": [
6632 {
6633 "plan_prefix": [
6634 "`t1`"
6635 ] /* plan_prefix */,
6636 "table": "`t2`",
6637 "best_access_path": {
6638 "considered_access_paths": [
6639 {
6640 "rows_to_scan": 2,
6641 "filtering_effect": [
6642 ] /* filtering_effect */,
6643 "final_filtering_effect": 0.5,
6644 "access_type": "scan",
6645 "using_join_cache": true,
6646 "buffers_needed": 1,
6647 "resulting_rows": 1,
6648 "cost": 0.801122,
6649 "chosen": true
6650 }
6651 ] /* considered_access_paths */
6652 } /* best_access_path */,
6653 "condition_filtering_pct": 100,
6654 "rows_for_plan": 2,
6655 "cost_for_plan": 1.50222,
6656 "sort_cost": 2,
6657 "new_cost_for_plan": 3.50222,
6658 "chosen": true
6659 }
6660 ] /* rest_of_plan */
6661 },
6662 {
6663 "plan_prefix": [
6664 ] /* plan_prefix */,
6665 "table": "`t2`",
6666 "best_access_path": {
6667 "considered_access_paths": [
6668 {
6669 "rows_to_scan": 2,
6670 "filtering_effect": [
6671 ] /* filtering_effect */,
6672 "final_filtering_effect": 0.5,
6673 "access_type": "scan",
6674 "resulting_rows": 1,
6675 "cost": 0.701099,
6676 "chosen": true
6677 }
6678 ] /* considered_access_paths */
6679 } /* best_access_path */,
6680 "condition_filtering_pct": 100,
6681 "rows_for_plan": 1,
6682 "cost_for_plan": 0.701099,
6683 "rest_of_plan": [
6684 {
6685 "plan_prefix": [
6686 "`t2`"
6687 ] /* plan_prefix */,
6688 "table": "`t1`",
6689 "best_access_path": {
6690 "considered_access_paths": [
6691 {
6692 "rows_to_scan": 2,
6693 "access_type": "scan",
6694 "using_join_cache": true,
6695 "buffers_needed": 1,
6696 "resulting_rows": 2,
6697 "cost": 0.701108,
6698 "chosen": true
6699 }
6700 ] /* considered_access_paths */
6701 } /* best_access_path */,
6702 "condition_filtering_pct": 100,
6703 "rows_for_plan": 2,
6704 "cost_for_plan": 1.40221,
6705 "sort_cost": 2,
6706 "new_cost_for_plan": 3.40221,
6707 "chosen": true
6708 }
6709 ] /* rest_of_plan */
6710 }
6711 ] /* considered_execution_plans */
6712 },
6713 {
6714 "attaching_conditions_to_tables": {
6715 "original_condition": "(`t2`.`c` > -(1))",
6716 "attached_conditions_computation": [
6717 ] /* attached_conditions_computation */,
6718 "attached_conditions_summary": [
6719 {
6720 "table": "`t2`",
6721 "attached": "(`t2`.`c` > -(1))"
6722 },
6723 {
6724 "table": "`t1`",
6725 "attached": null
6726 }
6727 ] /* attached_conditions_summary */
6728 } /* attaching_conditions_to_tables */
6729 },
6730 {
6731 "optimizing_distinct_group_by_order_by": {
6732 "simplifying_group_by": {
6733 "original_clause": "`t1`.`a`",
6734 "items": [
6735 {
6736 "item": "`t1`.`a`"
6737 }
6738 ] /* items */,
6739 "resulting_clause_is_simple": false,
6740 "resulting_clause": "`t1`.`a`"
6741 } /* simplifying_group_by */
6742 } /* optimizing_distinct_group_by_order_by */
6743 },
6744 {
6745 "finalizing_table_conditions": [
6746 {
6747 "table": "`t2`",
6748 "original_table_condition": "(`t2`.`c` > -(1))",
6749 "final_table_condition ": "(`t2`.`c` > <cache>(-(1)))"
6750 }
6751 ] /* finalizing_table_conditions */
6752 },
6753 {
6754 "refine_plan": [
6755 {
6756 "table": "`t2`"
6757 },
6758 {
6759 "table": "`t1`"
6760 }
6761 ] /* refine_plan */
6762 },
6763 {
6764 "considering_tmp_tables": [
6765 {
6766 "adding_tmp_table_in_plan_at_position": 2,
6767 "write_method": "continuously_update_group_row"
6768 }
6769 ] /* considering_tmp_tables */
6770 }
6771 ] /* steps */
6772 } /* join_optimization */
6773 },
6774 {
6775 "join_execution": {
6776 "select#": 1,
6777 "steps": [
6778 {
6779 "temp_table_aggregate": {
6780 "select#": 1,
6781 "steps": [
6782 {
6783 "creating_tmp_table": {
6784 "tmp_table_info": {
6785 "table": "<temporary>",
6786 "in_plan_at_position": 2,
6787 "columns": 2,
6788 "row_length": 30,
6789 "key_length": 5,
6790 "unique_constraint": false,
6791 "makes_grouped_rows": true,
6792 "cannot_insert_duplicates": false,
6793 "location": "TempTable"
6794 } /* tmp_table_info */
6795 } /* creating_tmp_table */
6796 }
6797 ] /* steps */
6798 } /* temp_table_aggregate */
6799 }
6800 ] /* steps */
6801 } /* join_execution */
6802 }
6803 ] /* steps */
6804 }
6805 select t1.a,avg(t2.c) as moyenne from t1, t2 where t2.c>-1
6806 group by t1.a having 4=5;
6807 a moyenne
6808 select trace from information_schema.OPTIMIZER_TRACE;
6809 trace
6810 {
6811 "steps": [
6812 {
6813 "join_optimization": {
6814 "select#": 1,
6815 "steps": [
6816 {
6817 "condition_processing": {
6818 "condition": "WHERE",
6819 "original_condition": "(`t2`.`c` > -(1))",
6820 "steps": [
6821 {
6822 "transformation": "equality_propagation",
6823 "resulting_condition": "(`t2`.`c` > -(1))"
6824 },
6825 {
6826 "transformation": "constant_propagation",
6827 "resulting_condition": "(`t2`.`c` > -(1))"
6828 },
6829 {
6830 "transformation": "trivial_condition_removal",
6831 "resulting_condition": "(`t2`.`c` > -(1))"
6832 }
6833 ] /* steps */
6834 } /* condition_processing */
6835 },
6836 {
6837 "condition_processing": {
6838 "condition": "HAVING",
6839 "original_condition": "false",
6840 "steps": [
6841 {
6842 "transformation": "constant_propagation",
6843 "resulting_condition": "false"
6844 },
6845 {
6846 "transformation": "trivial_condition_removal",
6847 "resulting_condition": null
6848 }
6849 ] /* steps */
6850 } /* condition_processing */
6851 }
6852 ] /* steps */,
6853 "empty_result": {
6854 "cause": "Impossible HAVING"
6855 } /* empty_result */
6856 } /* join_optimization */
6857 },
6858 {
6859 "join_execution": {
6860 "select#": 1,
6861 "steps": [
6862 ] /* steps */
6863 } /* join_execution */
6864 }
6865 ] /* steps */
6866 }
6867 drop table t1,t2;
6868 update t6 set d=5 where d is NULL;
6869 select * from information_schema.OPTIMIZER_TRACE;
6870 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
6871 update t6 set d=5 where d is NULL {
6872 "steps": [
6873 {
6874 "substitute_generated_columns": {
6875 } /* substitute_generated_columns */
6876 },
6877 {
6878 "condition_processing": {
6879 "condition": "WHERE",
6880 "original_condition": "(`t6`.`d` is null)",
6881 "steps": [
6882 {
6883 "transformation": "equality_propagation",
6884 "resulting_condition": "(`t6`.`d` is null)"
6885 },
6886 {
6887 "transformation": "constant_propagation",
6888 "resulting_condition": "(`t6`.`d` is null)"
6889 },
6890 {
6891 "transformation": "trivial_condition_removal",
6892 "resulting_condition": "(`t6`.`d` is null)"
6893 }
6894 ] /* steps */
6895 } /* condition_processing */
6896 },
6897 {
6898 "table": "`t6`",
6899 "range_analysis": {
6900 "table_scan": {
6901 "rows": 2,
6902 "cost": 2.80085
6903 } /* table_scan */,
6904 "potential_range_indexes": [
6905 {
6906 "index": "d",
6907 "usable": true,
6908 "key_parts": [
6909 "d"
6910 ] /* key_parts */
6911 }
6912 ] /* potential_range_indexes */,
6913 "setup_range_conditions": [
6914 ] /* setup_range_conditions */,
6915 "group_index_range": {
6916 "chosen": false,
6917 "cause": "no_join"
6918 } /* group_index_range */,
6919 "skip_scan_range": {
6920 "chosen": false,
6921 "cause": "no_join"
6922 } /* skip_scan_range */,
6923 "analyzing_range_alternatives": {
6924 "range_scan_alternatives": [
6925 {
6926 "index": "d",
6927 "ranges": [
6928 "d = NULL"
6929 ] /* ranges */,
6930 "index_dives_for_eq_ranges": true,
6931 "rowid_ordered": true,
6932 "using_mrr": false,
6933 "index_only": false,
6934 "in_memory": -1,
6935 "rows": 1,
6936 "cost": 0.61,
6937 "chosen": true
6938 }
6939 ] /* range_scan_alternatives */,
6940 "analyzing_roworder_intersect": {
6941 "usable": false,
6942 "cause": "too_few_roworder_scans"
6943 } /* analyzing_roworder_intersect */
6944 } /* analyzing_range_alternatives */,
6945 "chosen_range_access_summary": {
6946 "range_access_plan": {
6947 "type": "range_scan",
6948 "index": "d",
6949 "rows": 1,
6950 "ranges": [
6951 "d = NULL"
6952 ] /* ranges */
6953 } /* range_access_plan */,
6954 "rows_for_plan": 1,
6955 "cost_for_plan": 0.61,
6956 "chosen": true
6957 } /* chosen_range_access_summary */
6958 } /* range_analysis */
6959 }
6960 ] /* steps */
6961 } 0 0
6962 delete from t6 where d=5;
6963 select * from information_schema.OPTIMIZER_TRACE;
6964 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
6965 delete from t6 where d=5 {
6966 "steps": [
6967 {
6968 "substitute_generated_columns": {
6969 } /* substitute_generated_columns */
6970 },
6971 {
6972 "condition_processing": {
6973 "condition": "WHERE",
6974 "original_condition": "(`t6`.`d` = 5)",
6975 "steps": [
6976 {
6977 "transformation": "equality_propagation",
6978 "resulting_condition": "multiple equal(5, `t6`.`d`)"
6979 },
6980 {
6981 "transformation": "constant_propagation",
6982 "resulting_condition": "multiple equal(5, `t6`.`d`)"
6983 },
6984 {
6985 "transformation": "trivial_condition_removal",
6986 "resulting_condition": "multiple equal(5, `t6`.`d`)"
6987 }
6988 ] /* steps */
6989 } /* condition_processing */
6990 },
6991 {
6992 "table": "`t6`",
6993 "range_analysis": {
6994 "table_scan": {
6995 "rows": 2,
6996 "cost": 2.80085
6997 } /* table_scan */,
6998 "potential_range_indexes": [
6999 {
7000 "index": "d",
7001 "usable": true,
7002 "key_parts": [
7003 "d"
7004 ] /* key_parts */
7005 }
7006 ] /* potential_range_indexes */,
7007 "setup_range_conditions": [
7008 ] /* setup_range_conditions */,
7009 "group_index_range": {
7010 "chosen": false,
7011 "cause": "no_join"
7012 } /* group_index_range */,
7013 "skip_scan_range": {
7014 "chosen": false,
7015 "cause": "no_join"
7016 } /* skip_scan_range */,
7017 "analyzing_range_alternatives": {
7018 "range_scan_alternatives": [
7019 {
7020 "index": "d",
7021 "ranges": [
7022 "d = 5"
7023 ] /* ranges */,
7024 "index_dives_for_eq_ranges": true,
7025 "rowid_ordered": true,
7026 "using_mrr": false,
7027 "index_only": false,
7028 "in_memory": -1,
7029 "rows": 1,
7030 "cost": 0.61,
7031 "chosen": true
7032 }
7033 ] /* range_scan_alternatives */
7034 } /* analyzing_range_alternatives */,
7035 "chosen_range_access_summary": {
7036 "range_access_plan": {
7037 "type": "range_scan",
7038 "index": "d",
7039 "rows": 1,
7040 "ranges": [
7041 "d = 5"
7042 ] /* ranges */
7043 } /* range_access_plan */,
7044 "rows_for_plan": 1,
7045 "cost_for_plan": 0.61,
7046 "chosen": true
7047 } /* chosen_range_access_summary */
7048 } /* range_analysis */
7049 }
7050 ] /* steps */
7051 } 0 0
7052 insert into t6 values(6),(7),(8);
7053 select * from information_schema.OPTIMIZER_TRACE;
7054 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7055 insert into t6 values(6),(7),(8) {
7056 "steps": [
7057 ] /* steps */
7058 } 0 0
7059 insert into t6 select * from t6 where d>7;
7060 select * from information_schema.OPTIMIZER_TRACE;
7061 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7062 insert into t6 select * from t6 where d>7 {
7063 "steps": [
7064 {
7065 "join_optimization": {
7066 "select#": 1,
7067 "steps": [
7068 {
7069 "condition_processing": {
7070 "condition": "WHERE",
7071 "original_condition": "(`t6`.`d` > 7)",
7072 "steps": [
7073 {
7074 "transformation": "equality_propagation",
7075 "resulting_condition": "(`t6`.`d` > 7)"
7076 },
7077 {
7078 "transformation": "constant_propagation",
7079 "resulting_condition": "(`t6`.`d` > 7)"
7080 },
7081 {
7082 "transformation": "trivial_condition_removal",
7083 "resulting_condition": "(`t6`.`d` > 7)"
7084 }
7085 ] /* steps */
7086 } /* condition_processing */
7087 },
7088 {
7089 "substitute_generated_columns": {
7090 } /* substitute_generated_columns */
7091 },
7092 {
7093 "table_dependencies": [
7094 {
7095 "table": "`t6`",
7096 "row_may_be_null": false,
7097 "map_bit": 0,
7098 "depends_on_map_bits": [
7099 ] /* depends_on_map_bits */
7100 }
7101 ] /* table_dependencies */
7102 },
7103 {
7104 "ref_optimizer_key_uses": [
7105 ] /* ref_optimizer_key_uses */
7106 },
7107 {
7108 "rows_estimation": [
7109 {
7110 "table": "`t6`",
7111 "range_analysis": {
7112 "table_scan": {
7113 "rows": 3,
7114 "cost": 2.90128
7115 } /* table_scan */,
7116 "potential_range_indexes": [
7117 {
7118 "index": "d",
7119 "usable": true,
7120 "key_parts": [
7121 "d"
7122 ] /* key_parts */
7123 }
7124 ] /* potential_range_indexes */,
7125 "best_covering_index_scan": {
7126 "index": "d",
7127 "cost": 0.561628,
7128 "chosen": true
7129 } /* best_covering_index_scan */,
7130 "setup_range_conditions": [
7131 ] /* setup_range_conditions */,
7132 "group_index_range": {
7133 "chosen": false,
7134 "cause": "not_group_by_or_distinct"
7135 } /* group_index_range */,
7136 "skip_scan_range": {
7137 "potential_skip_scan_indexes": [
7138 {
7139 "index": "d",
7140 "usable": false,
7141 "cause": "prefix_not_const_equality"
7142 }
7143 ] /* potential_skip_scan_indexes */
7144 } /* skip_scan_range */,
7145 "analyzing_range_alternatives": {
7146 "range_scan_alternatives": [
7147 {
7148 "index": "d",
7149 "ranges": [
7150 "7 < d"
7151 ] /* ranges */,
7152 "index_dives_for_eq_ranges": true,
7153 "rowid_ordered": false,
7154 "using_mrr": false,
7155 "index_only": true,
7156 "in_memory": -1,
7157 "rows": 2,
7158 "cost": 0.465814,
7159 "chosen": true
7160 }
7161 ] /* range_scan_alternatives */,
7162 "analyzing_roworder_intersect": {
7163 "usable": false,
7164 "cause": "too_few_roworder_scans"
7165 } /* analyzing_roworder_intersect */
7166 } /* analyzing_range_alternatives */,
7167 "chosen_range_access_summary": {
7168 "range_access_plan": {
7169 "type": "range_scan",
7170 "index": "d",
7171 "rows": 2,
7172 "ranges": [
7173 "7 < d"
7174 ] /* ranges */
7175 } /* range_access_plan */,
7176 "rows_for_plan": 2,
7177 "cost_for_plan": 0.465814,
7178 "chosen": true
7179 } /* chosen_range_access_summary */
7180 } /* range_analysis */
7181 }
7182 ] /* rows_estimation */
7183 },
7184 {
7185 "considered_execution_plans": [
7186 {
7187 "plan_prefix": [
7188 ] /* plan_prefix */,
7189 "table": "`t6`",
7190 "best_access_path": {
7191 "considered_access_paths": [
7192 {
7193 "rows_to_scan": 2,
7194 "access_type": "range",
7195 "range_details": {
7196 "used_index": "d"
7197 } /* range_details */,
7198 "resulting_rows": 2,
7199 "cost": 0.665814,
7200 "chosen": true
7201 }
7202 ] /* considered_access_paths */
7203 } /* best_access_path */,
7204 "condition_filtering_pct": 100,
7205 "rows_for_plan": 2,
7206 "cost_for_plan": 0.665814,
7207 "chosen": true
7208 }
7209 ] /* considered_execution_plans */
7210 },
7211 {
7212 "attaching_conditions_to_tables": {
7213 "original_condition": "(`t6`.`d` > 7)",
7214 "attached_conditions_computation": [
7215 ] /* attached_conditions_computation */,
7216 "attached_conditions_summary": [
7217 {
7218 "table": "`t6`",
7219 "attached": "(`t6`.`d` > 7)"
7220 }
7221 ] /* attached_conditions_summary */
7222 } /* attaching_conditions_to_tables */
7223 },
7224 {
7225 "finalizing_table_conditions": [
7226 {
7227 "table": "`t6`",
7228 "original_table_condition": "(`t6`.`d` > 7)",
7229 "final_table_condition ": "(`t6`.`d` > 7)"
7230 }
7231 ] /* finalizing_table_conditions */
7232 },
7233 {
7234 "refine_plan": [
7235 {
7236 "table": "`t6`"
7237 }
7238 ] /* refine_plan */
7239 },
7240 {
7241 "considering_tmp_tables": [
7242 {
7243 "adding_tmp_table_in_plan_at_position": 1,
7244 "write_method": "write_all_rows"
7245 }
7246 ] /* considering_tmp_tables */
7247 }
7248 ] /* steps */
7249 } /* join_optimization */
7250 },
7251 {
7252 "join_execution": {
7253 "select#": 1,
7254 "steps": [
7255 {
7256 "creating_tmp_table": {
7257 "tmp_table_info": {
7258 "table": "<temporary>",
7259 "in_plan_at_position": 1,
7260 "columns": 1,
7261 "row_length": 5,
7262 "key_length": 0,
7263 "unique_constraint": false,
7264 "makes_grouped_rows": false,
7265 "cannot_insert_duplicates": false,
7266 "location": "TempTable"
7267 } /* tmp_table_info */
7268 } /* creating_tmp_table */
7269 },
7270 {
7271 "materialize": {
7272 "select#": 1,
7273 "steps": [
7274 ] /* steps */
7275 } /* materialize */
7276 }
7277 ] /* steps */
7278 } /* join_execution */
7279 }
7280 ] /* steps */
7281 } 0 0
7282 update t5, t6 set t6.d=t6.d+t5.c+4-t5.c-4 where d>7000;
7283 select * from information_schema.OPTIMIZER_TRACE;
7284 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7285 update t5, t6 set t6.d=t6.d+t5.c+4-t5.c-4 where d>7000 {
7286 "steps": [
7287 {
7288 "join_optimization": {
7289 "select#": 1,
7290 "steps": [
7291 {
7292 "condition_processing": {
7293 "condition": "WHERE",
7294 "original_condition": "(`t6`.`d` > 7000)",
7295 "steps": [
7296 {
7297 "transformation": "equality_propagation",
7298 "resulting_condition": "(`t6`.`d` > 7000)"
7299 },
7300 {
7301 "transformation": "constant_propagation",
7302 "resulting_condition": "(`t6`.`d` > 7000)"
7303 },
7304 {
7305 "transformation": "trivial_condition_removal",
7306 "resulting_condition": "(`t6`.`d` > 7000)"
7307 }
7308 ] /* steps */
7309 } /* condition_processing */
7310 },
7311 {
7312 "substitute_generated_columns": {
7313 } /* substitute_generated_columns */
7314 },
7315 {
7316 "table_dependencies": [
7317 {
7318 "table": "`t5`",
7319 "row_may_be_null": false,
7320 "map_bit": 0,
7321 "depends_on_map_bits": [
7322 ] /* depends_on_map_bits */
7323 },
7324 {
7325 "table": "`t6`",
7326 "row_may_be_null": false,
7327 "map_bit": 1,
7328 "depends_on_map_bits": [
7329 ] /* depends_on_map_bits */
7330 }
7331 ] /* table_dependencies */
7332 },
7333 {
7334 "ref_optimizer_key_uses": [
7335 ] /* ref_optimizer_key_uses */
7336 },
7337 {
7338 "rows_estimation": [
7339 {
7340 "table": "`t5`",
7341 "rows": 1,
7342 "cost": 1,
7343 "table_type": "system",
7344 "empty": false
7345 },
7346 {
7347 "table": "`t6`",
7348 "range_analysis": {
7349 "table_scan": {
7350 "rows": 4,
7351 "cost": 3.00171
7352 } /* table_scan */,
7353 "potential_range_indexes": [
7354 {
7355 "index": "d",
7356 "usable": true,
7357 "key_parts": [
7358 "d"
7359 ] /* key_parts */
7360 }
7361 ] /* potential_range_indexes */,
7362 "setup_range_conditions": [
7363 ] /* setup_range_conditions */,
7364 "group_index_range": {
7365 "chosen": false,
7366 "cause": "not_single_table"
7367 } /* group_index_range */,
7368 "skip_scan_range": {
7369 "chosen": false,
7370 "cause": "not_single_table"
7371 } /* skip_scan_range */,
7372 "analyzing_range_alternatives": {
7373 "range_scan_alternatives": [
7374 {
7375 "index": "d",
7376 "ranges": [
7377 "7000 < d"
7378 ] /* ranges */,
7379 "index_dives_for_eq_ranges": true,
7380 "rowid_ordered": false,
7381 "using_mrr": false,
7382 "index_only": false,
7383 "in_memory": -1,
7384 "rows": 1,
7385 "cost": 0.61,
7386 "chosen": true
7387 }
7388 ] /* range_scan_alternatives */,
7389 "analyzing_roworder_intersect": {
7390 "usable": false,
7391 "cause": "too_few_roworder_scans"
7392 } /* analyzing_roworder_intersect */
7393 } /* analyzing_range_alternatives */,
7394 "chosen_range_access_summary": {
7395 "range_access_plan": {
7396 "type": "range_scan",
7397 "index": "d",
7398 "rows": 1,
7399 "ranges": [
7400 "7000 < d"
7401 ] /* ranges */
7402 } /* range_access_plan */,
7403 "rows_for_plan": 1,
7404 "cost_for_plan": 0.61,
7405 "chosen": true
7406 } /* chosen_range_access_summary */
7407 } /* range_analysis */
7408 }
7409 ] /* rows_estimation */
7410 },
7411 {
7412 "considered_execution_plans": [
7413 {
7414 "plan_prefix": [
7415 "`t5`"
7416 ] /* plan_prefix */,
7417 "table": "`t6`",
7418 "best_access_path": {
7419 "considered_access_paths": [
7420 {
7421 "rows_to_scan": 1,
7422 "filtering_effect": [
7423 ] /* filtering_effect */,
7424 "final_filtering_effect": 1,
7425 "access_type": "range",
7426 "range_details": {
7427 "used_index": "d"
7428 } /* range_details */,
7429 "resulting_rows": 1,
7430 "cost": 0.71,
7431 "chosen": true
7432 }
7433 ] /* considered_access_paths */
7434 } /* best_access_path */,
7435 "condition_filtering_pct": 100,
7436 "rows_for_plan": 1,
7437 "cost_for_plan": 0.71,
7438 "chosen": true
7439 }
7440 ] /* considered_execution_plans */
7441 },
7442 {
7443 "attaching_conditions_to_tables": {
7444 "original_condition": "(`t6`.`d` > 7000)",
7445 "attached_conditions_computation": [
7446 ] /* attached_conditions_computation */,
7447 "attached_conditions_summary": [
7448 {
7449 "table": "`t6`",
7450 "attached": "(`t6`.`d` > 7000)"
7451 }
7452 ] /* attached_conditions_summary */
7453 } /* attaching_conditions_to_tables */
7454 },
7455 {
7456 "finalizing_table_conditions": [
7457 {
7458 "table": "`t6`",
7459 "original_table_condition": "(`t6`.`d` > 7000)",
7460 "final_table_condition ": "(`t6`.`d` > 7000)"
7461 }
7462 ] /* finalizing_table_conditions */
7463 },
7464 {
7465 "refine_plan": [
7466 {
7467 "table": "`t6`"
7468 }
7469 ] /* refine_plan */
7470 }
7471 ] /* steps */
7472 } /* join_optimization */
7473 },
7474 {
7475 "creating_tmp_table": {
7476 "tmp_table_info": {
7477 "table": "intermediate_tmp_table",
7478 "columns": 2,
7479 "row_length": 13,
7480 "key_length": 9,
7481 "unique_constraint": false,
7482 "makes_grouped_rows": true,
7483 "cannot_insert_duplicates": false,
7484 "location": "TempTable"
7485 } /* tmp_table_info */
7486 } /* creating_tmp_table */
7487 },
7488 {
7489 "join_execution": {
7490 "select#": 1,
7491 "steps": [
7492 ] /* steps */
7493 } /* join_execution */
7494 }
7495 ] /* steps */
7496 } 0 0
7497 delete t6 from t5, t6 where d>7000;
7498 select * from information_schema.OPTIMIZER_TRACE;
7499 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7500 delete t6 from t5, t6 where d>7000 {
7501 "steps": [
7502 {
7503 "join_optimization": {
7504 "select#": 1,
7505 "steps": [
7506 {
7507 "condition_processing": {
7508 "condition": "WHERE",
7509 "original_condition": "(`t6`.`d` > 7000)",
7510 "steps": [
7511 {
7512 "transformation": "equality_propagation",
7513 "resulting_condition": "(`t6`.`d` > 7000)"
7514 },
7515 {
7516 "transformation": "constant_propagation",
7517 "resulting_condition": "(`t6`.`d` > 7000)"
7518 },
7519 {
7520 "transformation": "trivial_condition_removal",
7521 "resulting_condition": "(`t6`.`d` > 7000)"
7522 }
7523 ] /* steps */
7524 } /* condition_processing */
7525 },
7526 {
7527 "substitute_generated_columns": {
7528 } /* substitute_generated_columns */
7529 },
7530 {
7531 "table_dependencies": [
7532 {
7533 "table": "`t5`",
7534 "row_may_be_null": false,
7535 "map_bit": 0,
7536 "depends_on_map_bits": [
7537 ] /* depends_on_map_bits */
7538 },
7539 {
7540 "table": "`t6`",
7541 "row_may_be_null": false,
7542 "map_bit": 1,
7543 "depends_on_map_bits": [
7544 ] /* depends_on_map_bits */
7545 }
7546 ] /* table_dependencies */
7547 },
7548 {
7549 "ref_optimizer_key_uses": [
7550 ] /* ref_optimizer_key_uses */
7551 },
7552 {
7553 "rows_estimation": [
7554 {
7555 "table": "`t5`",
7556 "rows": 1,
7557 "cost": 1,
7558 "table_type": "system",
7559 "empty": false
7560 },
7561 {
7562 "table": "`t6`",
7563 "range_analysis": {
7564 "table_scan": {
7565 "rows": 4,
7566 "cost": 3.00171
7567 } /* table_scan */,
7568 "potential_range_indexes": [
7569 {
7570 "index": "d",
7571 "usable": true,
7572 "key_parts": [
7573 "d"
7574 ] /* key_parts */
7575 }
7576 ] /* potential_range_indexes */,
7577 "best_covering_index_scan": {
7578 "index": "d",
7579 "cost": 0.667442,
7580 "chosen": true
7581 } /* best_covering_index_scan */,
7582 "setup_range_conditions": [
7583 ] /* setup_range_conditions */,
7584 "group_index_range": {
7585 "chosen": false,
7586 "cause": "not_single_table"
7587 } /* group_index_range */,
7588 "skip_scan_range": {
7589 "chosen": false,
7590 "cause": "not_single_table"
7591 } /* skip_scan_range */,
7592 "analyzing_range_alternatives": {
7593 "range_scan_alternatives": [
7594 {
7595 "index": "d",
7596 "ranges": [
7597 "7000 < d"
7598 ] /* ranges */,
7599 "index_dives_for_eq_ranges": true,
7600 "rowid_ordered": false,
7601 "using_mrr": false,
7602 "index_only": true,
7603 "in_memory": -1,
7604 "rows": 1,
7605 "cost": 0.36,
7606 "chosen": true
7607 }
7608 ] /* range_scan_alternatives */,
7609 "analyzing_roworder_intersect": {
7610 "usable": false,
7611 "cause": "too_few_roworder_scans"
7612 } /* analyzing_roworder_intersect */
7613 } /* analyzing_range_alternatives */,
7614 "chosen_range_access_summary": {
7615 "range_access_plan": {
7616 "type": "range_scan",
7617 "index": "d",
7618 "rows": 1,
7619 "ranges": [
7620 "7000 < d"
7621 ] /* ranges */
7622 } /* range_access_plan */,
7623 "rows_for_plan": 1,
7624 "cost_for_plan": 0.36,
7625 "chosen": true
7626 } /* chosen_range_access_summary */
7627 } /* range_analysis */
7628 }
7629 ] /* rows_estimation */
7630 },
7631 {
7632 "considered_execution_plans": [
7633 {
7634 "plan_prefix": [
7635 "`t5`"
7636 ] /* plan_prefix */,
7637 "table": "`t6`",
7638 "best_access_path": {
7639 "considered_access_paths": [
7640 {
7641 "rows_to_scan": 1,
7642 "filtering_effect": [
7643 ] /* filtering_effect */,
7644 "final_filtering_effect": 1,
7645 "access_type": "range",
7646 "range_details": {
7647 "used_index": "d"
7648 } /* range_details */,
7649 "resulting_rows": 1,
7650 "cost": 0.46,
7651 "chosen": true
7652 }
7653 ] /* considered_access_paths */
7654 } /* best_access_path */,
7655 "condition_filtering_pct": 100,
7656 "rows_for_plan": 1,
7657 "cost_for_plan": 0.46,
7658 "chosen": true
7659 }
7660 ] /* considered_execution_plans */
7661 },
7662 {
7663 "attaching_conditions_to_tables": {
7664 "original_condition": "(`t6`.`d` > 7000)",
7665 "attached_conditions_computation": [
7666 ] /* attached_conditions_computation */,
7667 "attached_conditions_summary": [
7668 {
7669 "table": "`t6`",
7670 "attached": "(`t6`.`d` > 7000)"
7671 }
7672 ] /* attached_conditions_summary */
7673 } /* attaching_conditions_to_tables */
7674 },
7675 {
7676 "finalizing_table_conditions": [
7677 {
7678 "table": "`t6`",
7679 "original_table_condition": "(`t6`.`d` > 7000)",
7680 "final_table_condition ": "(`t6`.`d` > 7000)"
7681 }
7682 ] /* finalizing_table_conditions */
7683 },
7684 {
7685 "refine_plan": [
7686 {
7687 "table": "`t6`"
7688 }
7689 ] /* refine_plan */
7690 }
7691 ] /* steps */
7692 } /* join_optimization */
7693 },
7694 {
7695 "join_execution": {
7696 "select#": 1,
7697 "steps": [
7698 ] /* steps */
7699 } /* join_execution */
7700 }
7701 ] /* steps */
7702 } 0 0
7703 set optimizer_trace_offset=2,optimizer_trace_limit=2;
7704 select * from information_schema.OPTIMIZER_TRACE;
7705 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7706 select 1;
7707 1
7708 1
7709 select 2;
7710 2
7711 2
7712 select 3;
7713 3
7714 3
7715 select 4;
7716 4
7717 4
7718 select 5;
7719 5
7720 5
7721 select * from information_schema.OPTIMIZER_TRACE;
7722 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7723 select 2 {
7724 "steps": [
7725 {
7726 "join_preparation": {
7727 "select#": 1,
7728 "steps": [
7729 {
7730 "expanded_query": "/* select#1 */ select 2 AS `2`"
7731 }
7732 ] /* steps */
7733 } /* join_preparation */
7734 }
7735 ] /* steps */
7736 } 0 0
7737 select 2 {
7738 "steps": [
7739 {
7740 "join_optimization": {
7741 "select#": 1,
7742 "steps": [
7743 ] /* steps */
7744 } /* join_optimization */
7745 },
7746 {
7747 "join_execution": {
7748 "select#": 1,
7749 "steps": [
7750 ] /* steps */
7751 } /* join_execution */
7752 }
7753 ] /* steps */
7754 } 0 0
7755 set optimizer_trace_offset=-2,optimizer_trace_limit=2;
7756 select * from information_schema.OPTIMIZER_TRACE;
7757 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7758 select 1;
7759 1
7760 1
7761 select 2;
7762 2
7763 2
7764 select 3;
7765 3
7766 3
7767 select 4;
7768 4
7769 4
7770 select 5;
7771 5
7772 5
7773 select * from information_schema.OPTIMIZER_TRACE;
7774 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7775 select 5 {
7776 "steps": [
7777 {
7778 "join_preparation": {
7779 "select#": 1,
7780 "steps": [
7781 {
7782 "expanded_query": "/* select#1 */ select 5 AS `5`"
7783 }
7784 ] /* steps */
7785 } /* join_preparation */
7786 }
7787 ] /* steps */
7788 } 0 0
7789 select 5 {
7790 "steps": [
7791 {
7792 "join_optimization": {
7793 "select#": 1,
7794 "steps": [
7795 ] /* steps */
7796 } /* join_optimization */
7797 },
7798 {
7799 "join_execution": {
7800 "select#": 1,
7801 "steps": [
7802 ] /* steps */
7803 } /* join_execution */
7804 }
7805 ] /* steps */
7806 } 0 0
7807 set optimizer_trace_offset=default,optimizer_trace_limit=default;
7808 select * from information_schema.OPTIMIZER_TRACE;
7809 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7810 create table t1 (
7811 id char(16) not null default '',
7812 data int not null
7813 ) charset utf8mb4;
7814 create table t2 (
7815 s char(16),
7816 i int,
7817 d double
7818 ) charset utf8mb4;
7819 insert into t1 values ("a", 1), ("b", 2) |
7820 insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0), ("d", 4, 4.0) |
7821 create function f1() returns int
7822 begin
7823 declare ret int;
7824 insert into t1 values("z",0);
7825 delete from t1 where id="z";
7826 select sum(data) into ret from t1;
7827 return ret;
7828 end|
7829 select f1()|
7830 f1()
7831 3
7832 select * from information_schema.OPTIMIZER_TRACE|
7833 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7834 freturn 3 ret@0 {
7835 "steps": [
7836 ] /* steps */
7837 } 0 0
7838 select s, f1() from t2 order by s desc|
7839 s f1()
7840 d 3
7841 c 3
7842 b 3
7843 a 3
7844 select * from information_schema.OPTIMIZER_TRACE|
7845 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7846 freturn 3 ret@0 {
7847 "steps": [
7848 ] /* steps */
7849 } 0 0
7850 select * from t6 where d in (select f1() from t2 where s="c")|
7851 d
7852 select * from information_schema.OPTIMIZER_TRACE|
7853 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7854 freturn 3 ret@0 {
7855 "steps": [
7856 ] /* steps */
7857 } 0 0
7858 set @old_opt_switch=@@optimizer_switch;
7859 # Test was created when sj-mat-scan could not handle this query...
7860 set optimizer_switch="materialization=off";
7861 set optimizer_trace_offset=-60, optimizer_trace_limit=60|
7862 select * from t6 where d in (select f1() from t2 where s="c")|
7863 d
7864 select * from information_schema.OPTIMIZER_TRACE|
7865 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
7866 select * from t6 where d in (select f1() from t2 where s="c") {
7867 "steps": [
7868 {
7869 "join_preparation": {
7870 "select#": 1,
7871 "steps": [
7872 {
7873 "join_preparation": {
7874 "select#": 2,
7875 "steps": [
7876 {
7877 "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = 'c')"
7878 }
7879 ] /* steps */
7880 } /* join_preparation */
7881 },
7882 {
7883 "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'))"
7884 },
7885 {
7886 "transformation": {
7887 "select#": 2,
7888 "from": "IN (SELECT)",
7889 "to": "semijoin",
7890 "chosen": true,
7891 "transformation_to_semi_join": {
7892 "subquery_predicate": "`t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = 'c'))",
7893 "embedded in": "WHERE",
7894 "evaluating_constant_semijoin_conditions": [
7895 ] /* evaluating_constant_semijoin_conditions */,
7896 "semi-join condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
7897 "decorrelated_predicates": [
7898 {
7899 "outer": "`t6`.`d`",
7900 "inner": "`f1`()"
7901 }
7902 ] /* decorrelated_predicates */
7903 } /* transformation_to_semi_join */
7904 } /* transformation */
7905 },
7906 {
7907 "transformations_to_nested_joins": {
7908 "transformations": [
7909 "semijoin"
7910 ] /* transformations */,
7911 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` semi join (`t2`) where ((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
7912 } /* transformations_to_nested_joins */
7913 }
7914 ] /* steps */
7915 } /* join_preparation */
7916 }
7917 ] /* steps */
7918 } 0 0
7919 select * from t6 where d in (select f1() from t2 where s="c") {
7920 "steps": [
7921 {
7922 "join_optimization": {
7923 "select#": 1,
7924 "steps": [
7925 {
7926 "condition_processing": {
7927 "condition": "WHERE",
7928 "original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
7929 "steps": [
7930 {
7931 "transformation": "equality_propagation",
7932 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal('c', `t2`.`s`))"
7933 },
7934 {
7935 "transformation": "constant_propagation",
7936 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal('c', `t2`.`s`))"
7937 },
7938 {
7939 "transformation": "trivial_condition_removal",
7940 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal('c', `t2`.`s`))"
7941 }
7942 ] /* steps */
7943 } /* condition_processing */
7944 },
7945 {
7946 "substitute_generated_columns": {
7947 } /* substitute_generated_columns */
7948 },
7949 {
7950 "table_dependencies": [
7951 {
7952 "table": "`t6`",
7953 "row_may_be_null": false,
7954 "map_bit": 0,
7955 "depends_on_map_bits": [
7956 ] /* depends_on_map_bits */
7957 },
7958 {
7959 "table": "`t2`",
7960 "row_may_be_null": false,
7961 "map_bit": 1,
7962 "depends_on_map_bits": [
7963 ] /* depends_on_map_bits */
7964 }
7965 ] /* table_dependencies */
7966 },
7967 {
7968 "ref_optimizer_key_uses": [
7969 ] /* ref_optimizer_key_uses */
7970 },
7971 {
7972 "pulled_out_semijoin_tables": [
7973 ] /* pulled_out_semijoin_tables */
7974 },
7975 {
7976 "rows_estimation": [
7977 {
7978 "table": "`t6`",
7979 "table_scan": {
7980 "rows": 4,
7981 "cost": 0.501709
7982 } /* table_scan */
7983 },
7984 {
7985 "table": "`t2`",
7986 "table_scan": {
7987 "rows": 4,
7988 "cost": 0.518799
7989 } /* table_scan */
7990 }
7991 ] /* rows_estimation */
7992 },
7993 {
7994 "considered_execution_plans": [
7995 {
7996 "plan_prefix": [
7997 ] /* plan_prefix */,
7998 "table": "`t6`",
7999 "best_access_path": {
8000 "considered_access_paths": [
8001 {
8002 "rows_to_scan": 4,
8003 "filtering_effect": [
8004 ] /* filtering_effect */,
8005 "final_filtering_effect": 1,
8006 "access_type": "scan",
8007 "resulting_rows": 4,
8008 "cost": 0.901709,
8009 "chosen": true
8010 }
8011 ] /* considered_access_paths */
8012 } /* best_access_path */,
8013 "condition_filtering_pct": 25,
8014 "rows_for_plan": 1,
8015 "cost_for_plan": 0.901709,
8016 "semijoin_strategy_choice": [
8017 ] /* semijoin_strategy_choice */,
8018 "rest_of_plan": [
8019 {
8020 "plan_prefix": [
8021 "`t6`"
8022 ] /* plan_prefix */,
8023 "table": "`t2`",
8024 "best_access_path": {
8025 "considered_access_paths": [
8026 {
8027 "rows_to_scan": 4,
8028 "filtering_effect": [
8029 ] /* filtering_effect */,
8030 "final_filtering_effect": 0.25,
8031 "access_type": "scan",
8032 "using_join_cache": true,
8033 "buffers_needed": 1,
8034 "resulting_rows": 1,
8035 "cost": 0.918814,
8036 "chosen": true
8037 }
8038 ] /* considered_access_paths */
8039 } /* best_access_path */,
8040 "condition_filtering_pct": 100,
8041 "rows_for_plan": 1,
8042 "cost_for_plan": 1.82052,
8043 "semijoin_strategy_choice": [
8044 {
8045 "strategy": "FirstMatch",
8046 "recalculate_access_paths_and_cost": {
8047 "tables": [
8048 {
8049 "table": "`t2`",
8050 "best_access_path": {
8051 "considered_access_paths": [
8052 {
8053 "rows_to_scan": 4,
8054 "filtering_effect": [
8055 ] /* filtering_effect */,
8056 "final_filtering_effect": 0.25,
8057 "access_type": "scan",
8058 "using_join_cache": true,
8059 "buffers_needed": 1,
8060 "resulting_rows": 1,
8061 "cost": 0.918814,
8062 "chosen": true
8063 }
8064 ] /* considered_access_paths */
8065 } /* best_access_path */
8066 }
8067 ] /* tables */
8068 } /* recalculate_access_paths_and_cost */,
8069 "cost": 1.82052,
8070 "rows": 1,
8071 "chosen": true
8072 },
8073 {
8074 "strategy": "DuplicatesWeedout",
8075 "cost": 3.02052,
8076 "rows": 1,
8077 "duplicate_tables_left": false,
8078 "chosen": false
8079 }
8080 ] /* semijoin_strategy_choice */,
8081 "chosen": true
8082 }
8083 ] /* rest_of_plan */
8084 },
8085 {
8086 "plan_prefix": [
8087 ] /* plan_prefix */,
8088 "table": "`t2`",
8089 "best_access_path": {
8090 "considered_access_paths": [
8091 {
8092 "rows_to_scan": 4,
8093 "filtering_effect": [
8094 ] /* filtering_effect */,
8095 "final_filtering_effect": 0.25,
8096 "access_type": "scan",
8097 "resulting_rows": 1,
8098 "cost": 0.918799,
8099 "chosen": true
8100 }
8101 ] /* considered_access_paths */
8102 } /* best_access_path */,
8103 "condition_filtering_pct": 100,
8104 "rows_for_plan": 1,
8105 "cost_for_plan": 0.918799,
8106 "semijoin_strategy_choice": [
8107 ] /* semijoin_strategy_choice */,
8108 "pruned_by_heuristic": true
8109 },
8110 {
8111 "final_semijoin_strategy": "FirstMatch",
8112 "recalculate_access_paths_and_cost": {
8113 "tables": [
8114 {
8115 "table": "`t2`",
8116 "best_access_path": {
8117 "considered_access_paths": [
8118 {
8119 "rows_to_scan": 4,
8120 "filtering_effect": [
8121 ] /* filtering_effect */,
8122 "final_filtering_effect": 0.25,
8123 "access_type": "scan",
8124 "using_join_cache": true,
8125 "buffers_needed": 1,
8126 "resulting_rows": 1,
8127 "cost": 0.918814,
8128 "chosen": true
8129 }
8130 ] /* considered_access_paths */
8131 } /* best_access_path */
8132 }
8133 ] /* tables */
8134 } /* recalculate_access_paths_and_cost */
8135 }
8136 ] /* considered_execution_plans */
8137 },
8138 {
8139 "attaching_conditions_to_tables": {
8140 "original_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
8141 "attached_conditions_computation": [
8142 ] /* attached_conditions_computation */,
8143 "attached_conditions_summary": [
8144 {
8145 "table": "`t6`",
8146 "attached": null
8147 },
8148 {
8149 "table": "`t2`",
8150 "attached": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
8151 }
8152 ] /* attached_conditions_summary */
8153 } /* attaching_conditions_to_tables */
8154 },
8155 {
8156 "finalizing_table_conditions": [
8157 {
8158 "table": "`t2`",
8159 "original_table_condition": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))",
8160 "final_table_condition ": "((`t2`.`s` = 'c') and (`t6`.`d` = `f1`()))"
8161 }
8162 ] /* finalizing_table_conditions */
8163 },
8164 {
8165 "refine_plan": [
8166 {
8167 "table": "`t6`"
8168 },
8169 {
8170 "table": "`t2`"
8171 }
8172 ] /* refine_plan */
8173 }
8174 ] /* steps */
8175 } /* join_optimization */
8176 },
8177 {
8178 "join_execution": {
8179 "select#": 1,
8180 "steps": [
8181 ] /* steps */
8182 } /* join_execution */
8183 }
8184 ] /* steps */
8185 } 0 0
8186 set ret@0 NULL {
8187 "steps": [
8188 ] /* steps */
8189 } 0 0
8190 insert into t1 values("z",0) {
8191 "steps": [
8192 ] /* steps */
8193 } 0 0
8194 delete from t1 where id="z" {
8195 "steps": [
8196 {
8197 "substitute_generated_columns": {
8198 } /* substitute_generated_columns */
8199 },
8200 {
8201 "condition_processing": {
8202 "condition": "WHERE",
8203 "original_condition": "(`t1`.`id` = 'z')",
8204 "steps": [
8205 {
8206 "transformation": "equality_propagation",
8207 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8208 },
8209 {
8210 "transformation": "constant_propagation",
8211 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8212 },
8213 {
8214 "transformation": "trivial_condition_removal",
8215 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8216 }
8217 ] /* steps */
8218 } /* condition_processing */
8219 },
8220 {
8221 "table": "`t1`",
8222 "range_analysis": {
8223 "table_scan": {
8224 "rows": 3,
8225 "cost": 2.91263
8226 } /* table_scan */
8227 } /* range_analysis */
8228 }
8229 ] /* steps */
8230 } 0 0
8231 select sum(data) into ret from t1 {
8232 "steps": [
8233 {
8234 "join_optimization": {
8235 "select#": 1,
8236 "steps": [
8237 {
8238 "table_dependencies": [
8239 {
8240 "table": "`t1`",
8241 "row_may_be_null": false,
8242 "map_bit": 0,
8243 "depends_on_map_bits": [
8244 ] /* depends_on_map_bits */
8245 }
8246 ] /* table_dependencies */
8247 },
8248 {
8249 "rows_estimation": [
8250 {
8251 "table": "`t1`",
8252 "table_scan": {
8253 "rows": 2,
8254 "cost": 0.512634
8255 } /* table_scan */
8256 }
8257 ] /* rows_estimation */
8258 },
8259 {
8260 "considered_execution_plans": [
8261 {
8262 "plan_prefix": [
8263 ] /* plan_prefix */,
8264 "table": "`t1`",
8265 "best_access_path": {
8266 "considered_access_paths": [
8267 {
8268 "rows_to_scan": 2,
8269 "access_type": "scan",
8270 "resulting_rows": 2,
8271 "cost": 0.712634,
8272 "chosen": true
8273 }
8274 ] /* considered_access_paths */
8275 } /* best_access_path */,
8276 "condition_filtering_pct": 100,
8277 "rows_for_plan": 2,
8278 "cost_for_plan": 0.712634,
8279 "chosen": true
8280 }
8281 ] /* considered_execution_plans */
8282 },
8283 {
8284 "attaching_conditions_to_tables": {
8285 "original_condition": null,
8286 "attached_conditions_computation": [
8287 ] /* attached_conditions_computation */,
8288 "attached_conditions_summary": [
8289 {
8290 "table": "`t1`",
8291 "attached": null
8292 }
8293 ] /* attached_conditions_summary */
8294 } /* attaching_conditions_to_tables */
8295 },
8296 {
8297 "optimizing_distinct_group_by_order_by": {
8298 } /* optimizing_distinct_group_by_order_by */
8299 },
8300 {
8301 "finalizing_table_conditions": [
8302 ] /* finalizing_table_conditions */
8303 },
8304 {
8305 "refine_plan": [
8306 {
8307 "table": "`t1`"
8308 }
8309 ] /* refine_plan */
8310 },
8311 {
8312 "considering_tmp_tables": [
8313 ] /* considering_tmp_tables */
8314 }
8315 ] /* steps */
8316 } /* join_optimization */
8317 },
8318 {
8319 "join_execution": {
8320 "select#": 1,
8321 "steps": [
8322 ] /* steps */
8323 } /* join_execution */
8324 }
8325 ] /* steps */
8326 } 0 0
8327 freturn 3 ret@0 {
8328 "steps": [
8329 ] /* steps */
8330 } 0 0
8331 set ret@0 NULL {
8332 "steps": [
8333 ] /* steps */
8334 } 0 0
8335 insert into t1 values("z",0) {
8336 "steps": [
8337 ] /* steps */
8338 } 0 0
8339 delete from t1 where id="z" {
8340 "steps": [
8341 {
8342 "substitute_generated_columns": {
8343 } /* substitute_generated_columns */
8344 },
8345 {
8346 "condition_processing": {
8347 "condition": "WHERE",
8348 "original_condition": "(`t1`.`id` = 'z')",
8349 "steps": [
8350 {
8351 "transformation": "equality_propagation",
8352 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8353 },
8354 {
8355 "transformation": "constant_propagation",
8356 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8357 },
8358 {
8359 "transformation": "trivial_condition_removal",
8360 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8361 }
8362 ] /* steps */
8363 } /* condition_processing */
8364 },
8365 {
8366 "table": "`t1`",
8367 "range_analysis": {
8368 "table_scan": {
8369 "rows": 3,
8370 "cost": 2.91263
8371 } /* table_scan */
8372 } /* range_analysis */
8373 }
8374 ] /* steps */
8375 } 0 0
8376 select sum(data) into ret from t1 {
8377 "steps": [
8378 {
8379 "join_optimization": {
8380 "select#": 1,
8381 "steps": [
8382 {
8383 "table_dependencies": [
8384 {
8385 "table": "`t1`",
8386 "row_may_be_null": false,
8387 "map_bit": 0,
8388 "depends_on_map_bits": [
8389 ] /* depends_on_map_bits */
8390 }
8391 ] /* table_dependencies */
8392 },
8393 {
8394 "rows_estimation": [
8395 {
8396 "table": "`t1`",
8397 "table_scan": {
8398 "rows": 2,
8399 "cost": 0.512634
8400 } /* table_scan */
8401 }
8402 ] /* rows_estimation */
8403 },
8404 {
8405 "considered_execution_plans": [
8406 {
8407 "plan_prefix": [
8408 ] /* plan_prefix */,
8409 "table": "`t1`",
8410 "best_access_path": {
8411 "considered_access_paths": [
8412 {
8413 "rows_to_scan": 2,
8414 "access_type": "scan",
8415 "resulting_rows": 2,
8416 "cost": 0.712634,
8417 "chosen": true
8418 }
8419 ] /* considered_access_paths */
8420 } /* best_access_path */,
8421 "condition_filtering_pct": 100,
8422 "rows_for_plan": 2,
8423 "cost_for_plan": 0.712634,
8424 "chosen": true
8425 }
8426 ] /* considered_execution_plans */
8427 },
8428 {
8429 "attaching_conditions_to_tables": {
8430 "original_condition": null,
8431 "attached_conditions_computation": [
8432 ] /* attached_conditions_computation */,
8433 "attached_conditions_summary": [
8434 {
8435 "table": "`t1`",
8436 "attached": null
8437 }
8438 ] /* attached_conditions_summary */
8439 } /* attaching_conditions_to_tables */
8440 },
8441 {
8442 "optimizing_distinct_group_by_order_by": {
8443 } /* optimizing_distinct_group_by_order_by */
8444 },
8445 {
8446 "finalizing_table_conditions": [
8447 ] /* finalizing_table_conditions */
8448 },
8449 {
8450 "refine_plan": [
8451 {
8452 "table": "`t1`"
8453 }
8454 ] /* refine_plan */
8455 },
8456 {
8457 "considering_tmp_tables": [
8458 ] /* considering_tmp_tables */
8459 }
8460 ] /* steps */
8461 } /* join_optimization */
8462 },
8463 {
8464 "join_execution": {
8465 "select#": 1,
8466 "steps": [
8467 ] /* steps */
8468 } /* join_execution */
8469 }
8470 ] /* steps */
8471 } 0 0
8472 freturn 3 ret@0 {
8473 "steps": [
8474 ] /* steps */
8475 } 0 0
8476 set ret@0 NULL {
8477 "steps": [
8478 ] /* steps */
8479 } 0 0
8480 insert into t1 values("z",0) {
8481 "steps": [
8482 ] /* steps */
8483 } 0 0
8484 delete from t1 where id="z" {
8485 "steps": [
8486 {
8487 "substitute_generated_columns": {
8488 } /* substitute_generated_columns */
8489 },
8490 {
8491 "condition_processing": {
8492 "condition": "WHERE",
8493 "original_condition": "(`t1`.`id` = 'z')",
8494 "steps": [
8495 {
8496 "transformation": "equality_propagation",
8497 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8498 },
8499 {
8500 "transformation": "constant_propagation",
8501 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8502 },
8503 {
8504 "transformation": "trivial_condition_removal",
8505 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8506 }
8507 ] /* steps */
8508 } /* condition_processing */
8509 },
8510 {
8511 "table": "`t1`",
8512 "range_analysis": {
8513 "table_scan": {
8514 "rows": 3,
8515 "cost": 2.91263
8516 } /* table_scan */
8517 } /* range_analysis */
8518 }
8519 ] /* steps */
8520 } 0 0
8521 select sum(data) into ret from t1 {
8522 "steps": [
8523 {
8524 "join_optimization": {
8525 "select#": 1,
8526 "steps": [
8527 {
8528 "table_dependencies": [
8529 {
8530 "table": "`t1`",
8531 "row_may_be_null": false,
8532 "map_bit": 0,
8533 "depends_on_map_bits": [
8534 ] /* depends_on_map_bits */
8535 }
8536 ] /* table_dependencies */
8537 },
8538 {
8539 "rows_estimation": [
8540 {
8541 "table": "`t1`",
8542 "table_scan": {
8543 "rows": 2,
8544 "cost": 0.512634
8545 } /* table_scan */
8546 }
8547 ] /* rows_estimation */
8548 },
8549 {
8550 "considered_execution_plans": [
8551 {
8552 "plan_prefix": [
8553 ] /* plan_prefix */,
8554 "table": "`t1`",
8555 "best_access_path": {
8556 "considered_access_paths": [
8557 {
8558 "rows_to_scan": 2,
8559 "access_type": "scan",
8560 "resulting_rows": 2,
8561 "cost": 0.712634,
8562 "chosen": true
8563 }
8564 ] /* considered_access_paths */
8565 } /* best_access_path */,
8566 "condition_filtering_pct": 100,
8567 "rows_for_plan": 2,
8568 "cost_for_plan": 0.712634,
8569 "chosen": true
8570 }
8571 ] /* considered_execution_plans */
8572 },
8573 {
8574 "attaching_conditions_to_tables": {
8575 "original_condition": null,
8576 "attached_conditions_computation": [
8577 ] /* attached_conditions_computation */,
8578 "attached_conditions_summary": [
8579 {
8580 "table": "`t1`",
8581 "attached": null
8582 }
8583 ] /* attached_conditions_summary */
8584 } /* attaching_conditions_to_tables */
8585 },
8586 {
8587 "optimizing_distinct_group_by_order_by": {
8588 } /* optimizing_distinct_group_by_order_by */
8589 },
8590 {
8591 "finalizing_table_conditions": [
8592 ] /* finalizing_table_conditions */
8593 },
8594 {
8595 "refine_plan": [
8596 {
8597 "table": "`t1`"
8598 }
8599 ] /* refine_plan */
8600 },
8601 {
8602 "considering_tmp_tables": [
8603 ] /* considering_tmp_tables */
8604 }
8605 ] /* steps */
8606 } /* join_optimization */
8607 },
8608 {
8609 "join_execution": {
8610 "select#": 1,
8611 "steps": [
8612 ] /* steps */
8613 } /* join_execution */
8614 }
8615 ] /* steps */
8616 } 0 0
8617 freturn 3 ret@0 {
8618 "steps": [
8619 ] /* steps */
8620 } 0 0
8621 set ret@0 NULL {
8622 "steps": [
8623 ] /* steps */
8624 } 0 0
8625 insert into t1 values("z",0) {
8626 "steps": [
8627 ] /* steps */
8628 } 0 0
8629 delete from t1 where id="z" {
8630 "steps": [
8631 {
8632 "substitute_generated_columns": {
8633 } /* substitute_generated_columns */
8634 },
8635 {
8636 "condition_processing": {
8637 "condition": "WHERE",
8638 "original_condition": "(`t1`.`id` = 'z')",
8639 "steps": [
8640 {
8641 "transformation": "equality_propagation",
8642 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8643 },
8644 {
8645 "transformation": "constant_propagation",
8646 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8647 },
8648 {
8649 "transformation": "trivial_condition_removal",
8650 "resulting_condition": "multiple equal('z', `t1`.`id`)"
8651 }
8652 ] /* steps */
8653 } /* condition_processing */
8654 },
8655 {
8656 "table": "`t1`",
8657 "range_analysis": {
8658 "table_scan": {
8659 "rows": 3,
8660 "cost": 2.91263
8661 } /* table_scan */
8662 } /* range_analysis */
8663 }
8664 ] /* steps */
8665 } 0 0
8666 select sum(data) into ret from t1 {
8667 "steps": [
8668 {
8669 "join_optimization": {
8670 "select#": 1,
8671 "steps": [
8672 {
8673 "table_dependencies": [
8674 {
8675 "table": "`t1`",
8676 "row_may_be_null": false,
8677 "map_bit": 0,
8678 "depends_on_map_bits": [
8679 ] /* depends_on_map_bits */
8680 }
8681 ] /* table_dependencies */
8682 },
8683 {
8684 "rows_estimation": [
8685 {
8686 "table": "`t1`",
8687 "table_scan": {
8688 "rows": 2,
8689 "cost": 0.512634
8690 } /* table_scan */
8691 }
8692 ] /* rows_estimation */
8693 },
8694 {
8695 "considered_execution_plans": [
8696 {
8697 "plan_prefix": [
8698 ] /* plan_prefix */,
8699 "table": "`t1`",
8700 "best_access_path": {
8701 "considered_access_paths": [
8702 {
8703 "rows_to_scan": 2,
8704 "access_type": "scan",
8705 "resulting_rows": 2,
8706 "cost": 0.712634,
8707 "chosen": true
8708 }
8709 ] /* considered_access_paths */
8710 } /* best_access_path */,
8711 "condition_filtering_pct": 100,
8712 "rows_for_plan": 2,
8713 "cost_for_plan": 0.712634,
8714 "chosen": true
8715 }
8716 ] /* considered_execution_plans */
8717 },
8718 {
8719 "attaching_conditions_to_tables": {
8720 "original_condition": null,
8721 "attached_conditions_computation": [
8722 ] /* attached_conditions_computation */,
8723 "attached_conditions_summary": [
8724 {
8725 "table": "`t1`",
8726 "attached": null
8727 }
8728 ] /* attached_conditions_summary */
8729 } /* attaching_conditions_to_tables */
8730 },
8731 {
8732 "optimizing_distinct_group_by_order_by": {
8733 } /* optimizing_distinct_group_by_order_by */
8734 },
8735 {
8736 "finalizing_table_conditions": [
8737 ] /* finalizing_table_conditions */
8738 },
8739 {
8740 "refine_plan": [
8741 {
8742 "table": "`t1`"
8743 }
8744 ] /* refine_plan */
8745 },
8746 {
8747 "considering_tmp_tables": [
8748 ] /* considering_tmp_tables */
8749 }
8750 ] /* steps */
8751 } /* join_optimization */
8752 },
8753 {
8754 "join_execution": {
8755 "select#": 1,
8756 "steps": [
8757 ] /* steps */
8758 } /* join_execution */
8759 }
8760 ] /* steps */
8761 } 0 0
8762 freturn 3 ret@0 {
8763 "steps": [
8764 ] /* steps */
8765 } 0 0
8766 select count(*) from information_schema.OPTIMIZER_TRACE|
8767 count(*)
8768 22
8769 set optimizer_trace_offset=3, optimizer_trace_limit=1|
8770 select * from t6 where d in (select f1() from t2 where s="c")|
8771 d
8772 select * from information_schema.OPTIMIZER_TRACE|
8773 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8774 insert into t1 values("z",0) {
8775 "steps": [
8776 ] /* steps */
8777 } 0 0
8778 set @@optimizer_switch=@old_opt_switch;
8779 # Stored procedures
8780 create procedure p1(arg char(1) charset utf8mb4)
8781 begin
8782 declare res int;
8783 select d into res from t6 where d in (select f1() from t2 where s=arg);
8784 select d+1 into res from t6 where d=res+1;
8785 end|
8786 set @old_opt_switch=@@optimizer_switch;
8787 # Test was created when sj-mat-scan could not handle this query...
8788 set optimizer_switch="materialization=off";
8789 set optimizer_trace_offset=0, optimizer_trace_limit=100;
8790 call p1("c")|
8791 Warnings:
8792 Warning 1329 No data - zero rows fetched, selected, or processed
8793 select * from information_schema.OPTIMIZER_TRACE|
8794 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
8795 call p1("c") {
8796 "steps": [
8797 ] /* steps */
8798 } 0 0
8799 set res@1 NULL {
8800 "steps": [
8801 ] /* steps */
8802 } 0 0
8803 select d into res from t6 where d in (select f1() from t2 where s=arg) {
8804 "steps": [
8805 {
8806 "join_preparation": {
8807 "select#": 1,
8808 "steps": [
8809 {
8810 "join_preparation": {
8811 "select#": 2,
8812 "steps": [
8813 {
8814 "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0)"
8815 }
8816 ] /* steps */
8817 } /* join_preparation */
8818 },
8819 {
8820 "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))"
8821 },
8822 {
8823 "transformation": {
8824 "select#": 2,
8825 "from": "IN (SELECT)",
8826 "to": "semijoin",
8827 "chosen": true,
8828 "transformation_to_semi_join": {
8829 "subquery_predicate": "`t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0))",
8830 "embedded in": "WHERE",
8831 "evaluating_constant_semijoin_conditions": [
8832 ] /* evaluating_constant_semijoin_conditions */,
8833 "semi-join condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
8834 "decorrelated_predicates": [
8835 {
8836 "outer": "`t6`.`d`",
8837 "inner": "`f1`()"
8838 }
8839 ] /* decorrelated_predicates */
8840 } /* transformation_to_semi_join */
8841 } /* transformation */
8842 },
8843 {
8844 "transformations_to_nested_joins": {
8845 "transformations": [
8846 "semijoin"
8847 ] /* transformations */,
8848 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` semi join (`t2`) where ((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
8849 } /* transformations_to_nested_joins */
8850 }
8851 ] /* steps */
8852 } /* join_preparation */
8853 },
8854 {
8855 "join_optimization": {
8856 "select#": 1,
8857 "steps": [
8858 {
8859 "condition_processing": {
8860 "condition": "WHERE",
8861 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
8862 "steps": [
8863 {
8864 "transformation": "equality_propagation",
8865 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
8866 },
8867 {
8868 "transformation": "constant_propagation",
8869 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
8870 },
8871 {
8872 "transformation": "trivial_condition_removal",
8873 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
8874 }
8875 ] /* steps */
8876 } /* condition_processing */
8877 },
8878 {
8879 "substitute_generated_columns": {
8880 } /* substitute_generated_columns */
8881 },
8882 {
8883 "table_dependencies": [
8884 {
8885 "table": "`t6`",
8886 "row_may_be_null": false,
8887 "map_bit": 0,
8888 "depends_on_map_bits": [
8889 ] /* depends_on_map_bits */
8890 },
8891 {
8892 "table": "`t2`",
8893 "row_may_be_null": false,
8894 "map_bit": 1,
8895 "depends_on_map_bits": [
8896 ] /* depends_on_map_bits */
8897 }
8898 ] /* table_dependencies */
8899 },
8900 {
8901 "ref_optimizer_key_uses": [
8902 ] /* ref_optimizer_key_uses */
8903 },
8904 {
8905 "pulled_out_semijoin_tables": [
8906 ] /* pulled_out_semijoin_tables */
8907 },
8908 {
8909 "rows_estimation": [
8910 {
8911 "table": "`t6`",
8912 "table_scan": {
8913 "rows": 4,
8914 "cost": 0.501709
8915 } /* table_scan */
8916 },
8917 {
8918 "table": "`t2`",
8919 "table_scan": {
8920 "rows": 4,
8921 "cost": 0.518799
8922 } /* table_scan */
8923 }
8924 ] /* rows_estimation */
8925 },
8926 {
8927 "considered_execution_plans": [
8928 {
8929 "plan_prefix": [
8930 ] /* plan_prefix */,
8931 "table": "`t6`",
8932 "best_access_path": {
8933 "considered_access_paths": [
8934 {
8935 "rows_to_scan": 4,
8936 "filtering_effect": [
8937 ] /* filtering_effect */,
8938 "final_filtering_effect": 1,
8939 "access_type": "scan",
8940 "resulting_rows": 4,
8941 "cost": 0.901709,
8942 "chosen": true
8943 }
8944 ] /* considered_access_paths */
8945 } /* best_access_path */,
8946 "condition_filtering_pct": 25,
8947 "rows_for_plan": 1,
8948 "cost_for_plan": 0.901709,
8949 "semijoin_strategy_choice": [
8950 ] /* semijoin_strategy_choice */,
8951 "rest_of_plan": [
8952 {
8953 "plan_prefix": [
8954 "`t6`"
8955 ] /* plan_prefix */,
8956 "table": "`t2`",
8957 "best_access_path": {
8958 "considered_access_paths": [
8959 {
8960 "rows_to_scan": 4,
8961 "filtering_effect": [
8962 ] /* filtering_effect */,
8963 "final_filtering_effect": 0.25,
8964 "access_type": "scan",
8965 "using_join_cache": true,
8966 "buffers_needed": 1,
8967 "resulting_rows": 1,
8968 "cost": 0.918814,
8969 "chosen": true
8970 }
8971 ] /* considered_access_paths */
8972 } /* best_access_path */,
8973 "condition_filtering_pct": 100,
8974 "rows_for_plan": 1,
8975 "cost_for_plan": 1.82052,
8976 "semijoin_strategy_choice": [
8977 {
8978 "strategy": "FirstMatch",
8979 "recalculate_access_paths_and_cost": {
8980 "tables": [
8981 {
8982 "table": "`t2`",
8983 "best_access_path": {
8984 "considered_access_paths": [
8985 {
8986 "rows_to_scan": 4,
8987 "filtering_effect": [
8988 ] /* filtering_effect */,
8989 "final_filtering_effect": 0.25,
8990 "access_type": "scan",
8991 "using_join_cache": true,
8992 "buffers_needed": 1,
8993 "resulting_rows": 1,
8994 "cost": 0.918814,
8995 "chosen": true
8996 }
8997 ] /* considered_access_paths */
8998 } /* best_access_path */
8999 }
9000 ] /* tables */
9001 } /* recalculate_access_paths_and_cost */,
9002 "cost": 1.82052,
9003 "rows": 1,
9004 "chosen": true
9005 },
9006 {
9007 "strategy": "DuplicatesWeedout",
9008 "cost": 3.02052,
9009 "rows": 1,
9010 "duplicate_tables_left": false,
9011 "chosen": false
9012 }
9013 ] /* semijoin_strategy_choice */,
9014 "chosen": true
9015 }
9016 ] /* rest_of_plan */
9017 },
9018 {
9019 "plan_prefix": [
9020 ] /* plan_prefix */,
9021 "table": "`t2`",
9022 "best_access_path": {
9023 "considered_access_paths": [
9024 {
9025 "rows_to_scan": 4,
9026 "filtering_effect": [
9027 ] /* filtering_effect */,
9028 "final_filtering_effect": 0.25,
9029 "access_type": "scan",
9030 "resulting_rows": 1,
9031 "cost": 0.918799,
9032 "chosen": true
9033 }
9034 ] /* considered_access_paths */
9035 } /* best_access_path */,
9036 "condition_filtering_pct": 100,
9037 "rows_for_plan": 1,
9038 "cost_for_plan": 0.918799,
9039 "semijoin_strategy_choice": [
9040 ] /* semijoin_strategy_choice */,
9041 "pruned_by_heuristic": true
9042 },
9043 {
9044 "final_semijoin_strategy": "FirstMatch",
9045 "recalculate_access_paths_and_cost": {
9046 "tables": [
9047 {
9048 "table": "`t2`",
9049 "best_access_path": {
9050 "considered_access_paths": [
9051 {
9052 "rows_to_scan": 4,
9053 "filtering_effect": [
9054 ] /* filtering_effect */,
9055 "final_filtering_effect": 0.25,
9056 "access_type": "scan",
9057 "using_join_cache": true,
9058 "buffers_needed": 1,
9059 "resulting_rows": 1,
9060 "cost": 0.918814,
9061 "chosen": true
9062 }
9063 ] /* considered_access_paths */
9064 } /* best_access_path */
9065 }
9066 ] /* tables */
9067 } /* recalculate_access_paths_and_cost */
9068 }
9069 ] /* considered_execution_plans */
9070 },
9071 {
9072 "attaching_conditions_to_tables": {
9073 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
9074 "attached_conditions_computation": [
9075 ] /* attached_conditions_computation */,
9076 "attached_conditions_summary": [
9077 {
9078 "table": "`t6`",
9079 "attached": null
9080 },
9081 {
9082 "table": "`t2`",
9083 "attached": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
9084 }
9085 ] /* attached_conditions_summary */
9086 } /* attaching_conditions_to_tables */
9087 },
9088 {
9089 "finalizing_table_conditions": [
9090 {
9091 "table": "`t2`",
9092 "original_table_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
9093 "final_table_condition ": "((`t2`.`s` = <cache>(arg@0)) and (`t6`.`d` = `f1`()))"
9094 }
9095 ] /* finalizing_table_conditions */
9096 },
9097 {
9098 "refine_plan": [
9099 {
9100 "table": "`t6`"
9101 },
9102 {
9103 "table": "`t2`"
9104 }
9105 ] /* refine_plan */
9106 }
9107 ] /* steps */
9108 } /* join_optimization */
9109 },
9110 {
9111 "join_execution": {
9112 "select#": 1,
9113 "steps": [
9114 ] /* steps */
9115 } /* join_execution */
9116 }
9117 ] /* steps */
9118 } 0 0
9119 set ret@0 NULL {
9120 "steps": [
9121 ] /* steps */
9122 } 0 0
9123 insert into t1 values("z",0) {
9124 "steps": [
9125 ] /* steps */
9126 } 0 0
9127 delete from t1 where id="z" {
9128 "steps": [
9129 {
9130 "delete_preparation": {
9131 "select#": 1,
9132 "steps": [
9133 "delete from `t1` where (`t1`.`id` = 'z')"
9134 ] /* steps */
9135 } /* delete_preparation */
9136 },
9137 {
9138 "substitute_generated_columns": {
9139 } /* substitute_generated_columns */
9140 },
9141 {
9142 "condition_processing": {
9143 "condition": "WHERE",
9144 "original_condition": "(`t1`.`id` = 'z')",
9145 "steps": [
9146 {
9147 "transformation": "equality_propagation",
9148 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9149 },
9150 {
9151 "transformation": "constant_propagation",
9152 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9153 },
9154 {
9155 "transformation": "trivial_condition_removal",
9156 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9157 }
9158 ] /* steps */
9159 } /* condition_processing */
9160 },
9161 {
9162 "table": "`t1`",
9163 "range_analysis": {
9164 "table_scan": {
9165 "rows": 3,
9166 "cost": 2.91263
9167 } /* table_scan */
9168 } /* range_analysis */
9169 }
9170 ] /* steps */
9171 } 0 0
9172 select sum(data) into ret from t1 {
9173 "steps": [
9174 {
9175 "join_preparation": {
9176 "select#": 1,
9177 "steps": [
9178 {
9179 "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
9180 }
9181 ] /* steps */
9182 } /* join_preparation */
9183 },
9184 {
9185 "join_optimization": {
9186 "select#": 1,
9187 "steps": [
9188 {
9189 "table_dependencies": [
9190 {
9191 "table": "`t1`",
9192 "row_may_be_null": false,
9193 "map_bit": 0,
9194 "depends_on_map_bits": [
9195 ] /* depends_on_map_bits */
9196 }
9197 ] /* table_dependencies */
9198 },
9199 {
9200 "rows_estimation": [
9201 {
9202 "table": "`t1`",
9203 "table_scan": {
9204 "rows": 2,
9205 "cost": 0.512634
9206 } /* table_scan */
9207 }
9208 ] /* rows_estimation */
9209 },
9210 {
9211 "considered_execution_plans": [
9212 {
9213 "plan_prefix": [
9214 ] /* plan_prefix */,
9215 "table": "`t1`",
9216 "best_access_path": {
9217 "considered_access_paths": [
9218 {
9219 "rows_to_scan": 2,
9220 "access_type": "scan",
9221 "resulting_rows": 2,
9222 "cost": 0.712634,
9223 "chosen": true
9224 }
9225 ] /* considered_access_paths */
9226 } /* best_access_path */,
9227 "condition_filtering_pct": 100,
9228 "rows_for_plan": 2,
9229 "cost_for_plan": 0.712634,
9230 "chosen": true
9231 }
9232 ] /* considered_execution_plans */
9233 },
9234 {
9235 "attaching_conditions_to_tables": {
9236 "original_condition": null,
9237 "attached_conditions_computation": [
9238 ] /* attached_conditions_computation */,
9239 "attached_conditions_summary": [
9240 {
9241 "table": "`t1`",
9242 "attached": null
9243 }
9244 ] /* attached_conditions_summary */
9245 } /* attaching_conditions_to_tables */
9246 },
9247 {
9248 "optimizing_distinct_group_by_order_by": {
9249 } /* optimizing_distinct_group_by_order_by */
9250 },
9251 {
9252 "finalizing_table_conditions": [
9253 ] /* finalizing_table_conditions */
9254 },
9255 {
9256 "refine_plan": [
9257 {
9258 "table": "`t1`"
9259 }
9260 ] /* refine_plan */
9261 },
9262 {
9263 "considering_tmp_tables": [
9264 ] /* considering_tmp_tables */
9265 }
9266 ] /* steps */
9267 } /* join_optimization */
9268 },
9269 {
9270 "join_execution": {
9271 "select#": 1,
9272 "steps": [
9273 ] /* steps */
9274 } /* join_execution */
9275 }
9276 ] /* steps */
9277 } 0 0
9278 freturn 3 ret@0 {
9279 "steps": [
9280 ] /* steps */
9281 } 0 0
9282 set ret@0 NULL {
9283 "steps": [
9284 ] /* steps */
9285 } 0 0
9286 insert into t1 values("z",0) {
9287 "steps": [
9288 ] /* steps */
9289 } 0 0
9290 delete from t1 where id="z" {
9291 "steps": [
9292 {
9293 "substitute_generated_columns": {
9294 } /* substitute_generated_columns */
9295 },
9296 {
9297 "condition_processing": {
9298 "condition": "WHERE",
9299 "original_condition": "(`t1`.`id` = 'z')",
9300 "steps": [
9301 {
9302 "transformation": "equality_propagation",
9303 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9304 },
9305 {
9306 "transformation": "constant_propagation",
9307 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9308 },
9309 {
9310 "transformation": "trivial_condition_removal",
9311 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9312 }
9313 ] /* steps */
9314 } /* condition_processing */
9315 },
9316 {
9317 "table": "`t1`",
9318 "range_analysis": {
9319 "table_scan": {
9320 "rows": 3,
9321 "cost": 2.91263
9322 } /* table_scan */
9323 } /* range_analysis */
9324 }
9325 ] /* steps */
9326 } 0 0
9327 select sum(data) into ret from t1 {
9328 "steps": [
9329 {
9330 "join_optimization": {
9331 "select#": 1,
9332 "steps": [
9333 {
9334 "table_dependencies": [
9335 {
9336 "table": "`t1`",
9337 "row_may_be_null": false,
9338 "map_bit": 0,
9339 "depends_on_map_bits": [
9340 ] /* depends_on_map_bits */
9341 }
9342 ] /* table_dependencies */
9343 },
9344 {
9345 "rows_estimation": [
9346 {
9347 "table": "`t1`",
9348 "table_scan": {
9349 "rows": 2,
9350 "cost": 0.512634
9351 } /* table_scan */
9352 }
9353 ] /* rows_estimation */
9354 },
9355 {
9356 "considered_execution_plans": [
9357 {
9358 "plan_prefix": [
9359 ] /* plan_prefix */,
9360 "table": "`t1`",
9361 "best_access_path": {
9362 "considered_access_paths": [
9363 {
9364 "rows_to_scan": 2,
9365 "access_type": "scan",
9366 "resulting_rows": 2,
9367 "cost": 0.712634,
9368 "chosen": true
9369 }
9370 ] /* considered_access_paths */
9371 } /* best_access_path */,
9372 "condition_filtering_pct": 100,
9373 "rows_for_plan": 2,
9374 "cost_for_plan": 0.712634,
9375 "chosen": true
9376 }
9377 ] /* considered_execution_plans */
9378 },
9379 {
9380 "attaching_conditions_to_tables": {
9381 "original_condition": null,
9382 "attached_conditions_computation": [
9383 ] /* attached_conditions_computation */,
9384 "attached_conditions_summary": [
9385 {
9386 "table": "`t1`",
9387 "attached": null
9388 }
9389 ] /* attached_conditions_summary */
9390 } /* attaching_conditions_to_tables */
9391 },
9392 {
9393 "optimizing_distinct_group_by_order_by": {
9394 } /* optimizing_distinct_group_by_order_by */
9395 },
9396 {
9397 "finalizing_table_conditions": [
9398 ] /* finalizing_table_conditions */
9399 },
9400 {
9401 "refine_plan": [
9402 {
9403 "table": "`t1`"
9404 }
9405 ] /* refine_plan */
9406 },
9407 {
9408 "considering_tmp_tables": [
9409 ] /* considering_tmp_tables */
9410 }
9411 ] /* steps */
9412 } /* join_optimization */
9413 },
9414 {
9415 "join_execution": {
9416 "select#": 1,
9417 "steps": [
9418 ] /* steps */
9419 } /* join_execution */
9420 }
9421 ] /* steps */
9422 } 0 0
9423 freturn 3 ret@0 {
9424 "steps": [
9425 ] /* steps */
9426 } 0 0
9427 set ret@0 NULL {
9428 "steps": [
9429 ] /* steps */
9430 } 0 0
9431 insert into t1 values("z",0) {
9432 "steps": [
9433 ] /* steps */
9434 } 0 0
9435 delete from t1 where id="z" {
9436 "steps": [
9437 {
9438 "substitute_generated_columns": {
9439 } /* substitute_generated_columns */
9440 },
9441 {
9442 "condition_processing": {
9443 "condition": "WHERE",
9444 "original_condition": "(`t1`.`id` = 'z')",
9445 "steps": [
9446 {
9447 "transformation": "equality_propagation",
9448 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9449 },
9450 {
9451 "transformation": "constant_propagation",
9452 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9453 },
9454 {
9455 "transformation": "trivial_condition_removal",
9456 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9457 }
9458 ] /* steps */
9459 } /* condition_processing */
9460 },
9461 {
9462 "table": "`t1`",
9463 "range_analysis": {
9464 "table_scan": {
9465 "rows": 3,
9466 "cost": 2.91263
9467 } /* table_scan */
9468 } /* range_analysis */
9469 }
9470 ] /* steps */
9471 } 0 0
9472 select sum(data) into ret from t1 {
9473 "steps": [
9474 {
9475 "join_optimization": {
9476 "select#": 1,
9477 "steps": [
9478 {
9479 "table_dependencies": [
9480 {
9481 "table": "`t1`",
9482 "row_may_be_null": false,
9483 "map_bit": 0,
9484 "depends_on_map_bits": [
9485 ] /* depends_on_map_bits */
9486 }
9487 ] /* table_dependencies */
9488 },
9489 {
9490 "rows_estimation": [
9491 {
9492 "table": "`t1`",
9493 "table_scan": {
9494 "rows": 2,
9495 "cost": 0.512634
9496 } /* table_scan */
9497 }
9498 ] /* rows_estimation */
9499 },
9500 {
9501 "considered_execution_plans": [
9502 {
9503 "plan_prefix": [
9504 ] /* plan_prefix */,
9505 "table": "`t1`",
9506 "best_access_path": {
9507 "considered_access_paths": [
9508 {
9509 "rows_to_scan": 2,
9510 "access_type": "scan",
9511 "resulting_rows": 2,
9512 "cost": 0.712634,
9513 "chosen": true
9514 }
9515 ] /* considered_access_paths */
9516 } /* best_access_path */,
9517 "condition_filtering_pct": 100,
9518 "rows_for_plan": 2,
9519 "cost_for_plan": 0.712634,
9520 "chosen": true
9521 }
9522 ] /* considered_execution_plans */
9523 },
9524 {
9525 "attaching_conditions_to_tables": {
9526 "original_condition": null,
9527 "attached_conditions_computation": [
9528 ] /* attached_conditions_computation */,
9529 "attached_conditions_summary": [
9530 {
9531 "table": "`t1`",
9532 "attached": null
9533 }
9534 ] /* attached_conditions_summary */
9535 } /* attaching_conditions_to_tables */
9536 },
9537 {
9538 "optimizing_distinct_group_by_order_by": {
9539 } /* optimizing_distinct_group_by_order_by */
9540 },
9541 {
9542 "finalizing_table_conditions": [
9543 ] /* finalizing_table_conditions */
9544 },
9545 {
9546 "refine_plan": [
9547 {
9548 "table": "`t1`"
9549 }
9550 ] /* refine_plan */
9551 },
9552 {
9553 "considering_tmp_tables": [
9554 ] /* considering_tmp_tables */
9555 }
9556 ] /* steps */
9557 } /* join_optimization */
9558 },
9559 {
9560 "join_execution": {
9561 "select#": 1,
9562 "steps": [
9563 ] /* steps */
9564 } /* join_execution */
9565 }
9566 ] /* steps */
9567 } 0 0
9568 freturn 3 ret@0 {
9569 "steps": [
9570 ] /* steps */
9571 } 0 0
9572 set ret@0 NULL {
9573 "steps": [
9574 ] /* steps */
9575 } 0 0
9576 insert into t1 values("z",0) {
9577 "steps": [
9578 ] /* steps */
9579 } 0 0
9580 delete from t1 where id="z" {
9581 "steps": [
9582 {
9583 "substitute_generated_columns": {
9584 } /* substitute_generated_columns */
9585 },
9586 {
9587 "condition_processing": {
9588 "condition": "WHERE",
9589 "original_condition": "(`t1`.`id` = 'z')",
9590 "steps": [
9591 {
9592 "transformation": "equality_propagation",
9593 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9594 },
9595 {
9596 "transformation": "constant_propagation",
9597 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9598 },
9599 {
9600 "transformation": "trivial_condition_removal",
9601 "resulting_condition": "multiple equal('z', `t1`.`id`)"
9602 }
9603 ] /* steps */
9604 } /* condition_processing */
9605 },
9606 {
9607 "table": "`t1`",
9608 "range_analysis": {
9609 "table_scan": {
9610 "rows": 3,
9611 "cost": 2.91263
9612 } /* table_scan */
9613 } /* range_analysis */
9614 }
9615 ] /* steps */
9616 } 0 0
9617 select sum(data) into ret from t1 {
9618 "steps": [
9619 {
9620 "join_optimization": {
9621 "select#": 1,
9622 "steps": [
9623 {
9624 "table_dependencies": [
9625 {
9626 "table": "`t1`",
9627 "row_may_be_null": false,
9628 "map_bit": 0,
9629 "depends_on_map_bits": [
9630 ] /* depends_on_map_bits */
9631 }
9632 ] /* table_dependencies */
9633 },
9634 {
9635 "rows_estimation": [
9636 {
9637 "table": "`t1`",
9638 "table_scan": {
9639 "rows": 2,
9640 "cost": 0.512634
9641 } /* table_scan */
9642 }
9643 ] /* rows_estimation */
9644 },
9645 {
9646 "considered_execution_plans": [
9647 {
9648 "plan_prefix": [
9649 ] /* plan_prefix */,
9650 "table": "`t1`",
9651 "best_access_path": {
9652 "considered_access_paths": [
9653 {
9654 "rows_to_scan": 2,
9655 "access_type": "scan",
9656 "resulting_rows": 2,
9657 "cost": 0.712634,
9658 "chosen": true
9659 }
9660 ] /* considered_access_paths */
9661 } /* best_access_path */,
9662 "condition_filtering_pct": 100,
9663 "rows_for_plan": 2,
9664 "cost_for_plan": 0.712634,
9665 "chosen": true
9666 }
9667 ] /* considered_execution_plans */
9668 },
9669 {
9670 "attaching_conditions_to_tables": {
9671 "original_condition": null,
9672 "attached_conditions_computation": [
9673 ] /* attached_conditions_computation */,
9674 "attached_conditions_summary": [
9675 {
9676 "table": "`t1`",
9677 "attached": null
9678 }
9679 ] /* attached_conditions_summary */
9680 } /* attaching_conditions_to_tables */
9681 },
9682 {
9683 "optimizing_distinct_group_by_order_by": {
9684 } /* optimizing_distinct_group_by_order_by */
9685 },
9686 {
9687 "finalizing_table_conditions": [
9688 ] /* finalizing_table_conditions */
9689 },
9690 {
9691 "refine_plan": [
9692 {
9693 "table": "`t1`"
9694 }
9695 ] /* refine_plan */
9696 },
9697 {
9698 "considering_tmp_tables": [
9699 ] /* considering_tmp_tables */
9700 }
9701 ] /* steps */
9702 } /* join_optimization */
9703 },
9704 {
9705 "join_execution": {
9706 "select#": 1,
9707 "steps": [
9708 ] /* steps */
9709 } /* join_execution */
9710 }
9711 ] /* steps */
9712 } 0 0
9713 freturn 3 ret@0 {
9714 "steps": [
9715 ] /* steps */
9716 } 0 0
9717 select d+1 into res from t6 where d=res+1 {
9718 "steps": [
9719 {
9720 "join_preparation": {
9721 "select#": 1,
9722 "steps": [
9723 {
9724 "expanded_query": "/* select#1 */ select (`t6`.`d` + 1) AS `d+1` from `t6` where (`t6`.`d` = (res@1 + 1))"
9725 }
9726 ] /* steps */
9727 } /* join_preparation */
9728 },
9729 {
9730 "join_optimization": {
9731 "select#": 1,
9732 "steps": [
9733 {
9734 "condition_processing": {
9735 "condition": "WHERE",
9736 "original_condition": "(`t6`.`d` = (res@1 + 1))",
9737 "steps": [
9738 {
9739 "transformation": "equality_propagation",
9740 "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
9741 },
9742 {
9743 "transformation": "constant_propagation",
9744 "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
9745 },
9746 {
9747 "transformation": "trivial_condition_removal",
9748 "resulting_condition": "multiple equal((res@1 + 1), `t6`.`d`)"
9749 }
9750 ] /* steps */
9751 } /* condition_processing */
9752 },
9753 {
9754 "substitute_generated_columns": {
9755 } /* substitute_generated_columns */
9756 },
9757 {
9758 "table_dependencies": [
9759 {
9760 "table": "`t6`",
9761 "row_may_be_null": false,
9762 "map_bit": 0,
9763 "depends_on_map_bits": [
9764 ] /* depends_on_map_bits */
9765 }
9766 ] /* table_dependencies */
9767 },
9768 {
9769 "ref_optimizer_key_uses": [
9770 {
9771 "table": "`t6`",
9772 "field": "d",
9773 "equals": "(res@1 + 1)",
9774 "null_rejecting": true
9775 }
9776 ] /* ref_optimizer_key_uses */
9777 },
9778 {
9779 "rows_estimation": [
9780 {
9781 "table": "`t6`",
9782 "range_analysis": {
9783 "table_scan": {
9784 "rows": 4,
9785 "cost": 3.00171
9786 } /* table_scan */,
9787 "potential_range_indexes": [
9788 {
9789 "index": "d",
9790 "usable": true,
9791 "key_parts": [
9792 "d"
9793 ] /* key_parts */
9794 }
9795 ] /* potential_range_indexes */,
9796 "best_covering_index_scan": {
9797 "index": "d",
9798 "cost": 0.667442,
9799 "chosen": true
9800 } /* best_covering_index_scan */,
9801 "setup_range_conditions": [
9802 {
9803 "impossible_condition": {
9804 "cause": "comparison_with_null_always_false"
9805 } /* impossible_condition */
9806 }
9807 ] /* setup_range_conditions */,
9808 "impossible_range": true
9809 } /* range_analysis */,
9810 "rows": 0,
9811 "cause": "impossible_where_condition"
9812 }
9813 ] /* rows_estimation */
9814 }
9815 ] /* steps */,
9816 "empty_result": {
9817 "cause": "no matching row in const table"
9818 } /* empty_result */
9819 } /* join_optimization */
9820 },
9821 {
9822 "join_execution": {
9823 "select#": 1,
9824 "steps": [
9825 ] /* steps */
9826 } /* join_execution */
9827 }
9828 ] /* steps */
9829 } 0 0
9830 set @@optimizer_switch=@old_opt_switch;
9831 # Triggers
9832 create trigger trg1 before insert on t2 for each row
9833 begin
9834 set new.s=f1();
9835 end|
9836 set optimizer_trace_offset=0, optimizer_trace_limit=100|
9837 insert into t2 select d,100,200 from t6 where d is not null|
9838 select * from information_schema.OPTIMIZER_TRACE|
9839 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
9840 insert into t2 select d,100,200 from t6 where d is not null {
9841 "steps": [
9842 {
9843 "join_preparation": {
9844 "select#": 1,
9845 "steps": [
9846 {
9847 "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)"
9848 }
9849 ] /* steps */
9850 } /* join_preparation */
9851 }
9852 ] /* steps */
9853 } 0 0
9854 insert into t2 select d,100,200 from t6 where d is not null {
9855 "steps": [
9856 {
9857 "join_optimization": {
9858 "select#": 1,
9859 "steps": [
9860 {
9861 "condition_processing": {
9862 "condition": "WHERE",
9863 "original_condition": "(`t6`.`d` is not null)",
9864 "steps": [
9865 {
9866 "transformation": "equality_propagation",
9867 "resulting_condition": "(`t6`.`d` is not null)"
9868 },
9869 {
9870 "transformation": "constant_propagation",
9871 "resulting_condition": "(`t6`.`d` is not null)"
9872 },
9873 {
9874 "transformation": "trivial_condition_removal",
9875 "resulting_condition": "(`t6`.`d` is not null)"
9876 }
9877 ] /* steps */
9878 } /* condition_processing */
9879 },
9880 {
9881 "substitute_generated_columns": {
9882 } /* substitute_generated_columns */
9883 },
9884 {
9885 "table_dependencies": [
9886 {
9887 "table": "`t6`",
9888 "row_may_be_null": false,
9889 "map_bit": 0,
9890 "depends_on_map_bits": [
9891 ] /* depends_on_map_bits */
9892 }
9893 ] /* table_dependencies */
9894 },
9895 {
9896 "ref_optimizer_key_uses": [
9897 ] /* ref_optimizer_key_uses */
9898 },
9899 {
9900 "rows_estimation": [
9901 {
9902 "table": "`t6`",
9903 "range_analysis": {
9904 "table_scan": {
9905 "rows": 4,
9906 "cost": 3.00171
9907 } /* table_scan */,
9908 "potential_range_indexes": [
9909 {
9910 "index": "d",
9911 "usable": true,
9912 "key_parts": [
9913 "d"
9914 ] /* key_parts */
9915 }
9916 ] /* potential_range_indexes */,
9917 "best_covering_index_scan": {
9918 "index": "d",
9919 "cost": 0.667442,
9920 "chosen": true
9921 } /* best_covering_index_scan */,
9922 "setup_range_conditions": [
9923 ] /* setup_range_conditions */,
9924 "group_index_range": {
9925 "chosen": false,
9926 "cause": "not_group_by_or_distinct"
9927 } /* group_index_range */,
9928 "skip_scan_range": {
9929 "potential_skip_scan_indexes": [
9930 {
9931 "index": "d",
9932 "usable": false,
9933 "cause": "prefix_not_const_equality"
9934 }
9935 ] /* potential_skip_scan_indexes */
9936 } /* skip_scan_range */,
9937 "analyzing_range_alternatives": {
9938 "range_scan_alternatives": [
9939 {
9940 "index": "d",
9941 "ranges": [
9942 "NULL < d"
9943 ] /* ranges */,
9944 "index_dives_for_eq_ranges": true,
9945 "rowid_ordered": false,
9946 "using_mrr": false,
9947 "index_only": true,
9948 "in_memory": -1,
9949 "rows": 4,
9950 "cost": 0.677442,
9951 "chosen": false,
9952 "cause": "cost"
9953 }
9954 ] /* range_scan_alternatives */,
9955 "analyzing_roworder_intersect": {
9956 "usable": false,
9957 "cause": "too_few_roworder_scans"
9958 } /* analyzing_roworder_intersect */
9959 } /* analyzing_range_alternatives */
9960 } /* range_analysis */
9961 }
9962 ] /* rows_estimation */
9963 },
9964 {
9965 "considered_execution_plans": [
9966 {
9967 "plan_prefix": [
9968 ] /* plan_prefix */,
9969 "table": "`t6`",
9970 "best_access_path": {
9971 "considered_access_paths": [
9972 {
9973 "rows_to_scan": 4,
9974 "access_type": "scan",
9975 "resulting_rows": 4,
9976 "cost": 0.901709,
9977 "chosen": true
9978 }
9979 ] /* considered_access_paths */
9980 } /* best_access_path */,
9981 "condition_filtering_pct": 100,
9982 "rows_for_plan": 4,
9983 "cost_for_plan": 0.901709,
9984 "chosen": true
9985 }
9986 ] /* considered_execution_plans */
9987 },
9988 {
9989 "attaching_conditions_to_tables": {
9990 "original_condition": "(`t6`.`d` is not null)",
9991 "attached_conditions_computation": [
9992 ] /* attached_conditions_computation */,
9993 "attached_conditions_summary": [
9994 {
9995 "table": "`t6`",
9996 "attached": "(`t6`.`d` is not null)"
9997 }
9998 ] /* attached_conditions_summary */
9999 } /* attaching_conditions_to_tables */
10000 },
10001 {
10002 "finalizing_table_conditions": [
10003 {
10004 "table": "`t6`",
10005 "original_table_condition": "(`t6`.`d` is not null)",
10006 "final_table_condition ": "(`t6`.`d` is not null)"
10007 }
10008 ] /* finalizing_table_conditions */
10009 },
10010 {
10011 "refine_plan": [
10012 {
10013 "table": "`t6`"
10014 }
10015 ] /* refine_plan */
10016 }
10017 ] /* steps */
10018 } /* join_optimization */
10019 },
10020 {
10021 "join_execution": {
10022 "select#": 1,
10023 "steps": [
10024 ] /* steps */
10025 } /* join_execution */
10026 }
10027 ] /* steps */
10028 } 0 0
10029 set_trigger_field NEW.s:=`f1`() {
10030 "steps": [
10031 ] /* steps */
10032 } 0 0
10033 set ret@0 NULL {
10034 "steps": [
10035 ] /* steps */
10036 } 0 0
10037 insert into t1 values("z",0) {
10038 "steps": [
10039 ] /* steps */
10040 } 0 0
10041 delete from t1 where id="z" {
10042 "steps": [
10043 {
10044 "delete_preparation": {
10045 "select#": 1,
10046 "steps": [
10047 "delete from `t1` where (`t1`.`id` = 'z')"
10048 ] /* steps */
10049 } /* delete_preparation */
10050 },
10051 {
10052 "substitute_generated_columns": {
10053 } /* substitute_generated_columns */
10054 },
10055 {
10056 "condition_processing": {
10057 "condition": "WHERE",
10058 "original_condition": "(`t1`.`id` = 'z')",
10059 "steps": [
10060 {
10061 "transformation": "equality_propagation",
10062 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10063 },
10064 {
10065 "transformation": "constant_propagation",
10066 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10067 },
10068 {
10069 "transformation": "trivial_condition_removal",
10070 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10071 }
10072 ] /* steps */
10073 } /* condition_processing */
10074 },
10075 {
10076 "table": "`t1`",
10077 "range_analysis": {
10078 "table_scan": {
10079 "rows": 3,
10080 "cost": 2.91263
10081 } /* table_scan */
10082 } /* range_analysis */
10083 }
10084 ] /* steps */
10085 } 0 0
10086 select sum(data) into ret from t1 {
10087 "steps": [
10088 {
10089 "join_preparation": {
10090 "select#": 1,
10091 "steps": [
10092 {
10093 "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
10094 }
10095 ] /* steps */
10096 } /* join_preparation */
10097 },
10098 {
10099 "join_optimization": {
10100 "select#": 1,
10101 "steps": [
10102 {
10103 "table_dependencies": [
10104 {
10105 "table": "`t1`",
10106 "row_may_be_null": false,
10107 "map_bit": 0,
10108 "depends_on_map_bits": [
10109 ] /* depends_on_map_bits */
10110 }
10111 ] /* table_dependencies */
10112 },
10113 {
10114 "rows_estimation": [
10115 {
10116 "table": "`t1`",
10117 "table_scan": {
10118 "rows": 2,
10119 "cost": 0.512634
10120 } /* table_scan */
10121 }
10122 ] /* rows_estimation */
10123 },
10124 {
10125 "considered_execution_plans": [
10126 {
10127 "plan_prefix": [
10128 ] /* plan_prefix */,
10129 "table": "`t1`",
10130 "best_access_path": {
10131 "considered_access_paths": [
10132 {
10133 "rows_to_scan": 2,
10134 "access_type": "scan",
10135 "resulting_rows": 2,
10136 "cost": 0.712634,
10137 "chosen": true
10138 }
10139 ] /* considered_access_paths */
10140 } /* best_access_path */,
10141 "condition_filtering_pct": 100,
10142 "rows_for_plan": 2,
10143 "cost_for_plan": 0.712634,
10144 "chosen": true
10145 }
10146 ] /* considered_execution_plans */
10147 },
10148 {
10149 "attaching_conditions_to_tables": {
10150 "original_condition": null,
10151 "attached_conditions_computation": [
10152 ] /* attached_conditions_computation */,
10153 "attached_conditions_summary": [
10154 {
10155 "table": "`t1`",
10156 "attached": null
10157 }
10158 ] /* attached_conditions_summary */
10159 } /* attaching_conditions_to_tables */
10160 },
10161 {
10162 "optimizing_distinct_group_by_order_by": {
10163 } /* optimizing_distinct_group_by_order_by */
10164 },
10165 {
10166 "finalizing_table_conditions": [
10167 ] /* finalizing_table_conditions */
10168 },
10169 {
10170 "refine_plan": [
10171 {
10172 "table": "`t1`"
10173 }
10174 ] /* refine_plan */
10175 },
10176 {
10177 "considering_tmp_tables": [
10178 ] /* considering_tmp_tables */
10179 }
10180 ] /* steps */
10181 } /* join_optimization */
10182 },
10183 {
10184 "join_execution": {
10185 "select#": 1,
10186 "steps": [
10187 ] /* steps */
10188 } /* join_execution */
10189 }
10190 ] /* steps */
10191 } 0 0
10192 freturn 3 ret@0 {
10193 "steps": [
10194 ] /* steps */
10195 } 0 0
10196 set_trigger_field NEW.s:=`f1`() {
10197 "steps": [
10198 ] /* steps */
10199 } 0 0
10200 set ret@0 NULL {
10201 "steps": [
10202 ] /* steps */
10203 } 0 0
10204 insert into t1 values("z",0) {
10205 "steps": [
10206 ] /* steps */
10207 } 0 0
10208 delete from t1 where id="z" {
10209 "steps": [
10210 {
10211 "substitute_generated_columns": {
10212 } /* substitute_generated_columns */
10213 },
10214 {
10215 "condition_processing": {
10216 "condition": "WHERE",
10217 "original_condition": "(`t1`.`id` = 'z')",
10218 "steps": [
10219 {
10220 "transformation": "equality_propagation",
10221 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10222 },
10223 {
10224 "transformation": "constant_propagation",
10225 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10226 },
10227 {
10228 "transformation": "trivial_condition_removal",
10229 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10230 }
10231 ] /* steps */
10232 } /* condition_processing */
10233 },
10234 {
10235 "table": "`t1`",
10236 "range_analysis": {
10237 "table_scan": {
10238 "rows": 3,
10239 "cost": 2.91263
10240 } /* table_scan */
10241 } /* range_analysis */
10242 }
10243 ] /* steps */
10244 } 0 0
10245 select sum(data) into ret from t1 {
10246 "steps": [
10247 {
10248 "join_optimization": {
10249 "select#": 1,
10250 "steps": [
10251 {
10252 "table_dependencies": [
10253 {
10254 "table": "`t1`",
10255 "row_may_be_null": false,
10256 "map_bit": 0,
10257 "depends_on_map_bits": [
10258 ] /* depends_on_map_bits */
10259 }
10260 ] /* table_dependencies */
10261 },
10262 {
10263 "rows_estimation": [
10264 {
10265 "table": "`t1`",
10266 "table_scan": {
10267 "rows": 2,
10268 "cost": 0.512634
10269 } /* table_scan */
10270 }
10271 ] /* rows_estimation */
10272 },
10273 {
10274 "considered_execution_plans": [
10275 {
10276 "plan_prefix": [
10277 ] /* plan_prefix */,
10278 "table": "`t1`",
10279 "best_access_path": {
10280 "considered_access_paths": [
10281 {
10282 "rows_to_scan": 2,
10283 "access_type": "scan",
10284 "resulting_rows": 2,
10285 "cost": 0.712634,
10286 "chosen": true
10287 }
10288 ] /* considered_access_paths */
10289 } /* best_access_path */,
10290 "condition_filtering_pct": 100,
10291 "rows_for_plan": 2,
10292 "cost_for_plan": 0.712634,
10293 "chosen": true
10294 }
10295 ] /* considered_execution_plans */
10296 },
10297 {
10298 "attaching_conditions_to_tables": {
10299 "original_condition": null,
10300 "attached_conditions_computation": [
10301 ] /* attached_conditions_computation */,
10302 "attached_conditions_summary": [
10303 {
10304 "table": "`t1`",
10305 "attached": null
10306 }
10307 ] /* attached_conditions_summary */
10308 } /* attaching_conditions_to_tables */
10309 },
10310 {
10311 "optimizing_distinct_group_by_order_by": {
10312 } /* optimizing_distinct_group_by_order_by */
10313 },
10314 {
10315 "finalizing_table_conditions": [
10316 ] /* finalizing_table_conditions */
10317 },
10318 {
10319 "refine_plan": [
10320 {
10321 "table": "`t1`"
10322 }
10323 ] /* refine_plan */
10324 },
10325 {
10326 "considering_tmp_tables": [
10327 ] /* considering_tmp_tables */
10328 }
10329 ] /* steps */
10330 } /* join_optimization */
10331 },
10332 {
10333 "join_execution": {
10334 "select#": 1,
10335 "steps": [
10336 ] /* steps */
10337 } /* join_execution */
10338 }
10339 ] /* steps */
10340 } 0 0
10341 freturn 3 ret@0 {
10342 "steps": [
10343 ] /* steps */
10344 } 0 0
10345 set_trigger_field NEW.s:=`f1`() {
10346 "steps": [
10347 ] /* steps */
10348 } 0 0
10349 set ret@0 NULL {
10350 "steps": [
10351 ] /* steps */
10352 } 0 0
10353 insert into t1 values("z",0) {
10354 "steps": [
10355 ] /* steps */
10356 } 0 0
10357 delete from t1 where id="z" {
10358 "steps": [
10359 {
10360 "substitute_generated_columns": {
10361 } /* substitute_generated_columns */
10362 },
10363 {
10364 "condition_processing": {
10365 "condition": "WHERE",
10366 "original_condition": "(`t1`.`id` = 'z')",
10367 "steps": [
10368 {
10369 "transformation": "equality_propagation",
10370 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10371 },
10372 {
10373 "transformation": "constant_propagation",
10374 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10375 },
10376 {
10377 "transformation": "trivial_condition_removal",
10378 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10379 }
10380 ] /* steps */
10381 } /* condition_processing */
10382 },
10383 {
10384 "table": "`t1`",
10385 "range_analysis": {
10386 "table_scan": {
10387 "rows": 3,
10388 "cost": 2.91263
10389 } /* table_scan */
10390 } /* range_analysis */
10391 }
10392 ] /* steps */
10393 } 0 0
10394 select sum(data) into ret from t1 {
10395 "steps": [
10396 {
10397 "join_optimization": {
10398 "select#": 1,
10399 "steps": [
10400 {
10401 "table_dependencies": [
10402 {
10403 "table": "`t1`",
10404 "row_may_be_null": false,
10405 "map_bit": 0,
10406 "depends_on_map_bits": [
10407 ] /* depends_on_map_bits */
10408 }
10409 ] /* table_dependencies */
10410 },
10411 {
10412 "rows_estimation": [
10413 {
10414 "table": "`t1`",
10415 "table_scan": {
10416 "rows": 2,
10417 "cost": 0.512634
10418 } /* table_scan */
10419 }
10420 ] /* rows_estimation */
10421 },
10422 {
10423 "considered_execution_plans": [
10424 {
10425 "plan_prefix": [
10426 ] /* plan_prefix */,
10427 "table": "`t1`",
10428 "best_access_path": {
10429 "considered_access_paths": [
10430 {
10431 "rows_to_scan": 2,
10432 "access_type": "scan",
10433 "resulting_rows": 2,
10434 "cost": 0.712634,
10435 "chosen": true
10436 }
10437 ] /* considered_access_paths */
10438 } /* best_access_path */,
10439 "condition_filtering_pct": 100,
10440 "rows_for_plan": 2,
10441 "cost_for_plan": 0.712634,
10442 "chosen": true
10443 }
10444 ] /* considered_execution_plans */
10445 },
10446 {
10447 "attaching_conditions_to_tables": {
10448 "original_condition": null,
10449 "attached_conditions_computation": [
10450 ] /* attached_conditions_computation */,
10451 "attached_conditions_summary": [
10452 {
10453 "table": "`t1`",
10454 "attached": null
10455 }
10456 ] /* attached_conditions_summary */
10457 } /* attaching_conditions_to_tables */
10458 },
10459 {
10460 "optimizing_distinct_group_by_order_by": {
10461 } /* optimizing_distinct_group_by_order_by */
10462 },
10463 {
10464 "finalizing_table_conditions": [
10465 ] /* finalizing_table_conditions */
10466 },
10467 {
10468 "refine_plan": [
10469 {
10470 "table": "`t1`"
10471 }
10472 ] /* refine_plan */
10473 },
10474 {
10475 "considering_tmp_tables": [
10476 ] /* considering_tmp_tables */
10477 }
10478 ] /* steps */
10479 } /* join_optimization */
10480 },
10481 {
10482 "join_execution": {
10483 "select#": 1,
10484 "steps": [
10485 ] /* steps */
10486 } /* join_execution */
10487 }
10488 ] /* steps */
10489 } 0 0
10490 freturn 3 ret@0 {
10491 "steps": [
10492 ] /* steps */
10493 } 0 0
10494 set_trigger_field NEW.s:=`f1`() {
10495 "steps": [
10496 ] /* steps */
10497 } 0 0
10498 set ret@0 NULL {
10499 "steps": [
10500 ] /* steps */
10501 } 0 0
10502 insert into t1 values("z",0) {
10503 "steps": [
10504 ] /* steps */
10505 } 0 0
10506 delete from t1 where id="z" {
10507 "steps": [
10508 {
10509 "substitute_generated_columns": {
10510 } /* substitute_generated_columns */
10511 },
10512 {
10513 "condition_processing": {
10514 "condition": "WHERE",
10515 "original_condition": "(`t1`.`id` = 'z')",
10516 "steps": [
10517 {
10518 "transformation": "equality_propagation",
10519 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10520 },
10521 {
10522 "transformation": "constant_propagation",
10523 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10524 },
10525 {
10526 "transformation": "trivial_condition_removal",
10527 "resulting_condition": "multiple equal('z', `t1`.`id`)"
10528 }
10529 ] /* steps */
10530 } /* condition_processing */
10531 },
10532 {
10533 "table": "`t1`",
10534 "range_analysis": {
10535 "table_scan": {
10536 "rows": 3,
10537 "cost": 2.91263
10538 } /* table_scan */
10539 } /* range_analysis */
10540 }
10541 ] /* steps */
10542 } 0 0
10543 select sum(data) into ret from t1 {
10544 "steps": [
10545 {
10546 "join_optimization": {
10547 "select#": 1,
10548 "steps": [
10549 {
10550 "table_dependencies": [
10551 {
10552 "table": "`t1`",
10553 "row_may_be_null": false,
10554 "map_bit": 0,
10555 "depends_on_map_bits": [
10556 ] /* depends_on_map_bits */
10557 }
10558 ] /* table_dependencies */
10559 },
10560 {
10561 "rows_estimation": [
10562 {
10563 "table": "`t1`",
10564 "table_scan": {
10565 "rows": 2,
10566 "cost": 0.512634
10567 } /* table_scan */
10568 }
10569 ] /* rows_estimation */
10570 },
10571 {
10572 "considered_execution_plans": [
10573 {
10574 "plan_prefix": [
10575 ] /* plan_prefix */,
10576 "table": "`t1`",
10577 "best_access_path": {
10578 "considered_access_paths": [
10579 {
10580 "rows_to_scan": 2,
10581 "access_type": "scan",
10582 "resulting_rows": 2,
10583 "cost": 0.712634,
10584 "chosen": true
10585 }
10586 ] /* considered_access_paths */
10587 } /* best_access_path */,
10588 "condition_filtering_pct": 100,
10589 "rows_for_plan": 2,
10590 "cost_for_plan": 0.712634,
10591 "chosen": true
10592 }
10593 ] /* considered_execution_plans */
10594 },
10595 {
10596 "attaching_conditions_to_tables": {
10597 "original_condition": null,
10598 "attached_conditions_computation": [
10599 ] /* attached_conditions_computation */,
10600 "attached_conditions_summary": [
10601 {
10602 "table": "`t1`",
10603 "attached": null
10604 }
10605 ] /* attached_conditions_summary */
10606 } /* attaching_conditions_to_tables */
10607 },
10608 {
10609 "optimizing_distinct_group_by_order_by": {
10610 } /* optimizing_distinct_group_by_order_by */
10611 },
10612 {
10613 "finalizing_table_conditions": [
10614 ] /* finalizing_table_conditions */
10615 },
10616 {
10617 "refine_plan": [
10618 {
10619 "table": "`t1`"
10620 }
10621 ] /* refine_plan */
10622 },
10623 {
10624 "considering_tmp_tables": [
10625 ] /* considering_tmp_tables */
10626 }
10627 ] /* steps */
10628 } /* join_optimization */
10629 },
10630 {
10631 "join_execution": {
10632 "select#": 1,
10633 "steps": [
10634 ] /* steps */
10635 } /* join_execution */
10636 }
10637 ] /* steps */
10638 } 0 0
10639 freturn 3 ret@0 {
10640 "steps": [
10641 ] /* steps */
10642 } 0 0
10643 select * from t2|
10644 s i d
10645 a 1 1
10646 b 2 2
10647 c 3 3
10648 d 4 4
10649 3 100 200
10650 3 100 200
10651 3 100 200
10652 3 100 200
10653 prepare stmt from 'select count(*) from t1 where t1.data=?';
10654 set @param="c";
10655 set optimizer_trace_offset=0, optimizer_trace_limit=100;
10656 execute stmt using @param;
10657 count(*)
10658 0
10659 Warnings:
10660 Warning 1292 Truncated incorrect INTEGER value: 'c'
10661 Warning 1292 Truncated incorrect INTEGER value: 'c'
10662 Warning 1292 Truncated incorrect INTEGER value: 'c'
10663 Warning 1292 Truncated incorrect INTEGER value: 'c'
10664 select count(*) from information_schema.OPTIMIZER_TRACE;
10665 count(*)
10666 1
10667 select TRACE into @trace from information_schema.OPTIMIZER_TRACE;
10668 select @trace;
10669 @trace
10670 {
10671 "steps": [
10672 {
10673 "statement_parameters": [
10674 "LONGLONG"
10675 ] /* statement_parameters */
10676 },
10677 {
10678 "join_optimization": {
10679 "select#": 1,
10680 "steps": [
10681 {
10682 "condition_processing": {
10683 "condition": "WHERE",
10684 "original_condition": "(`t1`.`data` = 'c')",
10685 "steps": [
10686 {
10687 "transformation": "equality_propagation",
10688 "resulting_condition": "multiple equal('c', `t1`.`data`)"
10689 },
10690 {
10691 "transformation": "constant_propagation",
10692 "resulting_condition": "multiple equal('c', `t1`.`data`)"
10693 },
10694 {
10695 "transformation": "trivial_condition_removal",
10696 "resulting_condition": "multiple equal('c', `t1`.`data`)"
10697 }
10698 ] /* steps */
10699 } /* condition_processing */
10700 },
10701 {
10702 "substitute_generated_columns": {
10703 } /* substitute_generated_columns */
10704 },
10705 {
10706 "table_dependencies": [
10707 {
10708 "table": "`t1`",
10709 "row_may_be_null": false,
10710 "map_bit": 0,
10711 "depends_on_map_bits": [
10712 ] /* depends_on_map_bits */
10713 }
10714 ] /* table_dependencies */
10715 },
10716 {
10717 "ref_optimizer_key_uses": [
10718 ] /* ref_optimizer_key_uses */
10719 },
10720 {
10721 "rows_estimation": [
10722 {
10723 "table": "`t1`",
10724 "table_scan": {
10725 "rows": 2,
10726 "cost": 0.512634
10727 } /* table_scan */
10728 }
10729 ] /* rows_estimation */
10730 },
10731 {
10732 "considered_execution_plans": [
10733 {
10734 "plan_prefix": [
10735 ] /* plan_prefix */,
10736 "table": "`t1`",
10737 "best_access_path": {
10738 "considered_access_paths": [
10739 {
10740 "rows_to_scan": 2,
10741 "access_type": "scan",
10742 "resulting_rows": 2,
10743 "cost": 0.712634,
10744 "chosen": true
10745 }
10746 ] /* considered_access_paths */
10747 } /* best_access_path */,
10748 "condition_filtering_pct": 100,
10749 "rows_for_plan": 2,
10750 "cost_for_plan": 0.712634,
10751 "chosen": true
10752 }
10753 ] /* considered_execution_plans */
10754 },
10755 {
10756 "attaching_conditions_to_tables": {
10757 "original_condition": "(`t1`.`data` = 'c')",
10758 "attached_conditions_computation": [
10759 ] /* attached_conditions_computation */,
10760 "attached_conditions_summary": [
10761 {
10762 "table": "`t1`",
10763 "attached": "(`t1`.`data` = 'c')"
10764 }
10765 ] /* attached_conditions_summary */
10766 } /* attaching_conditions_to_tables */
10767 },
10768 {
10769 "optimizing_distinct_group_by_order_by": {
10770 } /* optimizing_distinct_group_by_order_by */
10771 },
10772 {
10773 "finalizing_table_conditions": [
10774 {
10775 "table": "`t1`",
10776 "original_table_condition": "(`t1`.`data` = 'c')",
10777 "final_table_condition ": "(`t1`.`data` = 'c')"
10778 }
10779 ] /* finalizing_table_conditions */
10780 },
10781 {
10782 "refine_plan": [
10783 {
10784 "table": "`t1`"
10785 }
10786 ] /* refine_plan */
10787 },
10788 {
10789 "considering_tmp_tables": [
10790 ] /* considering_tmp_tables */
10791 }
10792 ] /* steps */
10793 } /* join_optimization */
10794 },
10795 {
10796 "join_execution": {
10797 "select#": 1,
10798 "steps": [
10799 ] /* steps */
10800 } /* join_execution */
10801 }
10802 ] /* steps */
10803 }
10804 set optimizer_trace_offset=0, optimizer_trace_limit=100;
10805 execute stmt using @param;
10806 count(*)
10807 0
10808 Warnings:
10809 Warning 1292 Truncated incorrect INTEGER value: 'c'
10810 Warning 1292 Truncated incorrect INTEGER value: 'c'
10811 Warning 1292 Truncated incorrect INTEGER value: 'c'
10812 Warning 1292 Truncated incorrect INTEGER value: 'c'
10813 select count(*) from information_schema.OPTIMIZER_TRACE;
10814 count(*)
10815 1
10816 select TRACE into @trace2 from information_schema.OPTIMIZER_TRACE;
10817 select @trace=@trace2;
10818 @trace=@trace2
10819 1
10820 drop procedure p1;
10821 create temporary table optt like information_schema.OPTIMIZER_TRACE;
10822 create procedure p1(arg char(1) charset utf8mb4)
10823 begin
10824 declare res int;
10825 set optimizer_trace="enabled=off";
10826 # want to see all of SELECT below
10827 set optimizer_trace_offset=0, optimizer_trace_limit=100;
10828 set optimizer_trace="enabled=on";
10829 select d into res from t6 where d in (select f1() from t2 where s=arg);
10830 set optimizer_trace="enabled=off"; # and not more
10831 insert into optt select * from information_schema.OPTIMIZER_TRACE;
10832 set optimizer_trace_offset=default, optimizer_trace_limit=default;
10833 select d+1 into res from t6 where d=res+1;
10834 end|
10835 call p1("c")|
10836 Warnings:
10837 Warning 1329 No data - zero rows fetched, selected, or processed
10838 select * from optt|
10839 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
10840 select d into res from t6 where d in (select f1() from t2 where s=arg) {
10841 "steps": [
10842 {
10843 "join_preparation": {
10844 "select#": 1,
10845 "steps": [
10846 {
10847 "join_preparation": {
10848 "select#": 2,
10849 "steps": [
10850 {
10851 "expanded_query": "/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0)"
10852 }
10853 ] /* steps */
10854 } /* join_preparation */
10855 },
10856 {
10857 "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))"
10858 },
10859 {
10860 "transformation": {
10861 "select#": 2,
10862 "from": "IN (SELECT)",
10863 "to": "semijoin",
10864 "chosen": true,
10865 "transformation_to_semi_join": {
10866 "subquery_predicate": "`t6`.`d` in (/* select#2 */ select `f1`() from `t2` where (`t2`.`s` = arg@0))",
10867 "embedded in": "WHERE",
10868 "evaluating_constant_semijoin_conditions": [
10869 ] /* evaluating_constant_semijoin_conditions */,
10870 "semi-join condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
10871 "decorrelated_predicates": [
10872 {
10873 "outer": "`t6`.`d`",
10874 "inner": "`f1`()"
10875 }
10876 ] /* decorrelated_predicates */
10877 } /* transformation_to_semi_join */
10878 } /* transformation */
10879 },
10880 {
10881 "transformations_to_nested_joins": {
10882 "transformations": [
10883 "semijoin"
10884 ] /* transformations */,
10885 "expanded_query": "/* select#1 */ select `t6`.`d` AS `d` from `t6` semi join (`t2`) where ((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
10886 } /* transformations_to_nested_joins */
10887 }
10888 ] /* steps */
10889 } /* join_preparation */
10890 },
10891 {
10892 "join_optimization": {
10893 "select#": 1,
10894 "steps": [
10895 {
10896 "condition_processing": {
10897 "condition": "WHERE",
10898 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
10899 "steps": [
10900 {
10901 "transformation": "equality_propagation",
10902 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
10903 },
10904 {
10905 "transformation": "constant_propagation",
10906 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
10907 },
10908 {
10909 "transformation": "trivial_condition_removal",
10910 "resulting_condition": "((`t6`.`d` = `f1`()) and multiple equal(arg@0, `t2`.`s`))"
10911 }
10912 ] /* steps */
10913 } /* condition_processing */
10914 },
10915 {
10916 "substitute_generated_columns": {
10917 } /* substitute_generated_columns */
10918 },
10919 {
10920 "table_dependencies": [
10921 {
10922 "table": "`t6`",
10923 "row_may_be_null": false,
10924 "map_bit": 0,
10925 "depends_on_map_bits": [
10926 ] /* depends_on_map_bits */
10927 },
10928 {
10929 "table": "`t2`",
10930 "row_may_be_null": false,
10931 "map_bit": 1,
10932 "depends_on_map_bits": [
10933 ] /* depends_on_map_bits */
10934 }
10935 ] /* table_dependencies */
10936 },
10937 {
10938 "ref_optimizer_key_uses": [
10939 ] /* ref_optimizer_key_uses */
10940 },
10941 {
10942 "pulled_out_semijoin_tables": [
10943 ] /* pulled_out_semijoin_tables */
10944 },
10945 {
10946 "rows_estimation": [
10947 {
10948 "table": "`t6`",
10949 "table_scan": {
10950 "rows": 4,
10951 "cost": 0.501709
10952 } /* table_scan */
10953 },
10954 {
10955 "table": "`t2`",
10956 "table_scan": {
10957 "rows": 8,
10958 "cost": 0.537598
10959 } /* table_scan */
10960 }
10961 ] /* rows_estimation */
10962 },
10963 {
10964 "execution_plan_for_potential_materialization": {
10965 "steps": [
10966 {
10967 "considered_execution_plans": [
10968 {
10969 "plan_prefix": [
10970 ] /* plan_prefix */,
10971 "table": "`t2`",
10972 "best_access_path": {
10973 "considered_access_paths": [
10974 {
10975 "rows_to_scan": 8,
10976 "filtering_effect": [
10977 ] /* filtering_effect */,
10978 "final_filtering_effect": 0.125,
10979 "access_type": "scan",
10980 "resulting_rows": 1,
10981 "cost": 1.3376,
10982 "chosen": true
10983 }
10984 ] /* considered_access_paths */
10985 } /* best_access_path */,
10986 "condition_filtering_pct": 100,
10987 "rows_for_plan": 1,
10988 "cost_for_plan": 1.3376,
10989 "chosen": true
10990 }
10991 ] /* considered_execution_plans */
10992 }
10993 ] /* steps */
10994 } /* execution_plan_for_potential_materialization */
10995 },
10996 {
10997 "considered_execution_plans": [
10998 {
10999 "plan_prefix": [
11000 ] /* plan_prefix */,
11001 "table": "`t6`",
11002 "best_access_path": {
11003 "considered_access_paths": [
11004 {
11005 "rows_to_scan": 4,
11006 "filtering_effect": [
11007 ] /* filtering_effect */,
11008 "final_filtering_effect": 1,
11009 "access_type": "scan",
11010 "resulting_rows": 4,
11011 "cost": 0.901709,
11012 "chosen": true
11013 }
11014 ] /* considered_access_paths */
11015 } /* best_access_path */,
11016 "condition_filtering_pct": 25,
11017 "rows_for_plan": 1,
11018 "cost_for_plan": 0.901709,
11019 "semijoin_strategy_choice": [
11020 ] /* semijoin_strategy_choice */,
11021 "rest_of_plan": [
11022 {
11023 "plan_prefix": [
11024 "`t6`"
11025 ] /* plan_prefix */,
11026 "table": "`t2`",
11027 "best_access_path": {
11028 "considered_access_paths": [
11029 {
11030 "rows_to_scan": 8,
11031 "filtering_effect": [
11032 ] /* filtering_effect */,
11033 "final_filtering_effect": 0.125,
11034 "access_type": "scan",
11035 "using_join_cache": true,
11036 "buffers_needed": 1,
11037 "resulting_rows": 1,
11038 "cost": 1.33762,
11039 "chosen": true
11040 }
11041 ] /* considered_access_paths */
11042 } /* best_access_path */,
11043 "condition_filtering_pct": 100,
11044 "rows_for_plan": 1,
11045 "cost_for_plan": 2.23933,
11046 "semijoin_strategy_choice": [
11047 {
11048 "strategy": "FirstMatch",
11049 "recalculate_access_paths_and_cost": {
11050 "tables": [
11051 {
11052 "table": "`t2`",
11053 "best_access_path": {
11054 "considered_access_paths": [
11055 {
11056 "rows_to_scan": 8,
11057 "filtering_effect": [
11058 ] /* filtering_effect */,
11059 "final_filtering_effect": 0.125,
11060 "access_type": "scan",
11061 "using_join_cache": true,
11062 "buffers_needed": 1,
11063 "resulting_rows": 1,
11064 "cost": 1.33762,
11065 "chosen": true
11066 }
11067 ] /* considered_access_paths */
11068 } /* best_access_path */
11069 }
11070 ] /* tables */
11071 } /* recalculate_access_paths_and_cost */,
11072 "cost": 2.23933,
11073 "rows": 1,
11074 "chosen": true
11075 },
11076 {
11077 "strategy": "MaterializeLookup",
11078 "cost": 3.43931,
11079 "rows": 1,
11080 "duplicate_tables_left": false,
11081 "chosen": false
11082 },
11083 {
11084 "strategy": "DuplicatesWeedout",
11085 "cost": 3.43933,
11086 "rows": 1,
11087 "duplicate_tables_left": false,
11088 "chosen": false
11089 }
11090 ] /* semijoin_strategy_choice */,
11091 "chosen": true
11092 }
11093 ] /* rest_of_plan */
11094 },
11095 {
11096 "plan_prefix": [
11097 ] /* plan_prefix */,
11098 "table": "`t2`",
11099 "best_access_path": {
11100 "considered_access_paths": [
11101 {
11102 "rows_to_scan": 8,
11103 "filtering_effect": [
11104 ] /* filtering_effect */,
11105 "final_filtering_effect": 0.125,
11106 "access_type": "scan",
11107 "resulting_rows": 1,
11108 "cost": 1.3376,
11109 "chosen": true
11110 }
11111 ] /* considered_access_paths */
11112 } /* best_access_path */,
11113 "condition_filtering_pct": 100,
11114 "rows_for_plan": 1,
11115 "cost_for_plan": 1.3376,
11116 "semijoin_strategy_choice": [
11117 {
11118 "strategy": "MaterializeScan",
11119 "choice": "deferred"
11120 }
11121 ] /* semijoin_strategy_choice */,
11122 "pruned_by_heuristic": true
11123 },
11124 {
11125 "final_semijoin_strategy": "FirstMatch",
11126 "recalculate_access_paths_and_cost": {
11127 "tables": [
11128 {
11129 "table": "`t2`",
11130 "best_access_path": {
11131 "considered_access_paths": [
11132 {
11133 "rows_to_scan": 8,
11134 "filtering_effect": [
11135 ] /* filtering_effect */,
11136 "final_filtering_effect": 0.125,
11137 "access_type": "scan",
11138 "using_join_cache": true,
11139 "buffers_needed": 1,
11140 "resulting_rows": 1,
11141 "cost": 1.33762,
11142 "chosen": true
11143 }
11144 ] /* considered_access_paths */
11145 } /* best_access_path */
11146 }
11147 ] /* tables */
11148 } /* recalculate_access_paths_and_cost */
11149 }
11150 ] /* considered_execution_plans */
11151 },
11152 {
11153 "attaching_conditions_to_tables": {
11154 "original_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
11155 "attached_conditions_computation": [
11156 ] /* attached_conditions_computation */,
11157 "attached_conditions_summary": [
11158 {
11159 "table": "`t6`",
11160 "attached": null
11161 },
11162 {
11163 "table": "`t2`",
11164 "attached": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))"
11165 }
11166 ] /* attached_conditions_summary */
11167 } /* attaching_conditions_to_tables */
11168 },
11169 {
11170 "finalizing_table_conditions": [
11171 {
11172 "table": "`t2`",
11173 "original_table_condition": "((`t2`.`s` = arg@0) and (`t6`.`d` = `f1`()))",
11174 "final_table_condition ": "((`t2`.`s` = <cache>(arg@0)) and (`t6`.`d` = `f1`()))"
11175 }
11176 ] /* finalizing_table_conditions */
11177 },
11178 {
11179 "refine_plan": [
11180 {
11181 "table": "`t6`"
11182 },
11183 {
11184 "table": "`t2`"
11185 }
11186 ] /* refine_plan */
11187 }
11188 ] /* steps */
11189 } /* join_optimization */
11190 },
11191 {
11192 "join_execution": {
11193 "select#": 1,
11194 "steps": [
11195 ] /* steps */
11196 } /* join_execution */
11197 }
11198 ] /* steps */
11199 } 0 0
11200 set ret@0 NULL {
11201 "steps": [
11202 ] /* steps */
11203 } 0 0
11204 insert into t1 values("z",0) {
11205 "steps": [
11206 ] /* steps */
11207 } 0 0
11208 delete from t1 where id="z" {
11209 "steps": [
11210 {
11211 "delete_preparation": {
11212 "select#": 1,
11213 "steps": [
11214 "delete from `t1` where (`t1`.`id` = 'z')"
11215 ] /* steps */
11216 } /* delete_preparation */
11217 },
11218 {
11219 "substitute_generated_columns": {
11220 } /* substitute_generated_columns */
11221 },
11222 {
11223 "condition_processing": {
11224 "condition": "WHERE",
11225 "original_condition": "(`t1`.`id` = 'z')",
11226 "steps": [
11227 {
11228 "transformation": "equality_propagation",
11229 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11230 },
11231 {
11232 "transformation": "constant_propagation",
11233 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11234 },
11235 {
11236 "transformation": "trivial_condition_removal",
11237 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11238 }
11239 ] /* steps */
11240 } /* condition_processing */
11241 },
11242 {
11243 "table": "`t1`",
11244 "range_analysis": {
11245 "table_scan": {
11246 "rows": 3,
11247 "cost": 2.91263
11248 } /* table_scan */
11249 } /* range_analysis */
11250 }
11251 ] /* steps */
11252 } 0 0
11253 select sum(data) into ret from t1 {
11254 "steps": [
11255 {
11256 "join_preparation": {
11257 "select#": 1,
11258 "steps": [
11259 {
11260 "expanded_query": "/* select#1 */ select sum(`t1`.`data`) AS `sum(data)` from `t1`"
11261 }
11262 ] /* steps */
11263 } /* join_preparation */
11264 },
11265 {
11266 "join_optimization": {
11267 "select#": 1,
11268 "steps": [
11269 {
11270 "table_dependencies": [
11271 {
11272 "table": "`t1`",
11273 "row_may_be_null": false,
11274 "map_bit": 0,
11275 "depends_on_map_bits": [
11276 ] /* depends_on_map_bits */
11277 }
11278 ] /* table_dependencies */
11279 },
11280 {
11281 "rows_estimation": [
11282 {
11283 "table": "`t1`",
11284 "table_scan": {
11285 "rows": 2,
11286 "cost": 0.512634
11287 } /* table_scan */
11288 }
11289 ] /* rows_estimation */
11290 },
11291 {
11292 "considered_execution_plans": [
11293 {
11294 "plan_prefix": [
11295 ] /* plan_prefix */,
11296 "table": "`t1`",
11297 "best_access_path": {
11298 "considered_access_paths": [
11299 {
11300 "rows_to_scan": 2,
11301 "access_type": "scan",
11302 "resulting_rows": 2,
11303 "cost": 0.712634,
11304 "chosen": true
11305 }
11306 ] /* considered_access_paths */
11307 } /* best_access_path */,
11308 "condition_filtering_pct": 100,
11309 "rows_for_plan": 2,
11310 "cost_for_plan": 0.712634,
11311 "chosen": true
11312 }
11313 ] /* considered_execution_plans */
11314 },
11315 {
11316 "attaching_conditions_to_tables": {
11317 "original_condition": null,
11318 "attached_conditions_computation": [
11319 ] /* attached_conditions_computation */,
11320 "attached_conditions_summary": [
11321 {
11322 "table": "`t1`",
11323 "attached": null
11324 }
11325 ] /* attached_conditions_summary */
11326 } /* attaching_conditions_to_tables */
11327 },
11328 {
11329 "optimizing_distinct_group_by_order_by": {
11330 } /* optimizing_distinct_group_by_order_by */
11331 },
11332 {
11333 "finalizing_table_conditions": [
11334 ] /* finalizing_table_conditions */
11335 },
11336 {
11337 "refine_plan": [
11338 {
11339 "table": "`t1`"
11340 }
11341 ] /* refine_plan */
11342 },
11343 {
11344 "considering_tmp_tables": [
11345 ] /* considering_tmp_tables */
11346 }
11347 ] /* steps */
11348 } /* join_optimization */
11349 },
11350 {
11351 "join_execution": {
11352 "select#": 1,
11353 "steps": [
11354 ] /* steps */
11355 } /* join_execution */
11356 }
11357 ] /* steps */
11358 } 0 0
11359 freturn 3 ret@0 {
11360 "steps": [
11361 ] /* steps */
11362 } 0 0
11363 set ret@0 NULL {
11364 "steps": [
11365 ] /* steps */
11366 } 0 0
11367 insert into t1 values("z",0) {
11368 "steps": [
11369 ] /* steps */
11370 } 0 0
11371 delete from t1 where id="z" {
11372 "steps": [
11373 {
11374 "substitute_generated_columns": {
11375 } /* substitute_generated_columns */
11376 },
11377 {
11378 "condition_processing": {
11379 "condition": "WHERE",
11380 "original_condition": "(`t1`.`id` = 'z')",
11381 "steps": [
11382 {
11383 "transformation": "equality_propagation",
11384 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11385 },
11386 {
11387 "transformation": "constant_propagation",
11388 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11389 },
11390 {
11391 "transformation": "trivial_condition_removal",
11392 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11393 }
11394 ] /* steps */
11395 } /* condition_processing */
11396 },
11397 {
11398 "table": "`t1`",
11399 "range_analysis": {
11400 "table_scan": {
11401 "rows": 3,
11402 "cost": 2.91263
11403 } /* table_scan */
11404 } /* range_analysis */
11405 }
11406 ] /* steps */
11407 } 0 0
11408 select sum(data) into ret from t1 {
11409 "steps": [
11410 {
11411 "join_optimization": {
11412 "select#": 1,
11413 "steps": [
11414 {
11415 "table_dependencies": [
11416 {
11417 "table": "`t1`",
11418 "row_may_be_null": false,
11419 "map_bit": 0,
11420 "depends_on_map_bits": [
11421 ] /* depends_on_map_bits */
11422 }
11423 ] /* table_dependencies */
11424 },
11425 {
11426 "rows_estimation": [
11427 {
11428 "table": "`t1`",
11429 "table_scan": {
11430 "rows": 2,
11431 "cost": 0.512634
11432 } /* table_scan */
11433 }
11434 ] /* rows_estimation */
11435 },
11436 {
11437 "considered_execution_plans": [
11438 {
11439 "plan_prefix": [
11440 ] /* plan_prefix */,
11441 "table": "`t1`",
11442 "best_access_path": {
11443 "considered_access_paths": [
11444 {
11445 "rows_to_scan": 2,
11446 "access_type": "scan",
11447 "resulting_rows": 2,
11448 "cost": 0.712634,
11449 "chosen": true
11450 }
11451 ] /* considered_access_paths */
11452 } /* best_access_path */,
11453 "condition_filtering_pct": 100,
11454 "rows_for_plan": 2,
11455 "cost_for_plan": 0.712634,
11456 "chosen": true
11457 }
11458 ] /* considered_execution_plans */
11459 },
11460 {
11461 "attaching_conditions_to_tables": {
11462 "original_condition": null,
11463 "attached_conditions_computation": [
11464 ] /* attached_conditions_computation */,
11465 "attached_conditions_summary": [
11466 {
11467 "table": "`t1`",
11468 "attached": null
11469 }
11470 ] /* attached_conditions_summary */
11471 } /* attaching_conditions_to_tables */
11472 },
11473 {
11474 "optimizing_distinct_group_by_order_by": {
11475 } /* optimizing_distinct_group_by_order_by */
11476 },
11477 {
11478 "finalizing_table_conditions": [
11479 ] /* finalizing_table_conditions */
11480 },
11481 {
11482 "refine_plan": [
11483 {
11484 "table": "`t1`"
11485 }
11486 ] /* refine_plan */
11487 },
11488 {
11489 "considering_tmp_tables": [
11490 ] /* considering_tmp_tables */
11491 }
11492 ] /* steps */
11493 } /* join_optimization */
11494 },
11495 {
11496 "join_execution": {
11497 "select#": 1,
11498 "steps": [
11499 ] /* steps */
11500 } /* join_execution */
11501 }
11502 ] /* steps */
11503 } 0 0
11504 freturn 3 ret@0 {
11505 "steps": [
11506 ] /* steps */
11507 } 0 0
11508 set ret@0 NULL {
11509 "steps": [
11510 ] /* steps */
11511 } 0 0
11512 insert into t1 values("z",0) {
11513 "steps": [
11514 ] /* steps */
11515 } 0 0
11516 delete from t1 where id="z" {
11517 "steps": [
11518 {
11519 "substitute_generated_columns": {
11520 } /* substitute_generated_columns */
11521 },
11522 {
11523 "condition_processing": {
11524 "condition": "WHERE",
11525 "original_condition": "(`t1`.`id` = 'z')",
11526 "steps": [
11527 {
11528 "transformation": "equality_propagation",
11529 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11530 },
11531 {
11532 "transformation": "constant_propagation",
11533 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11534 },
11535 {
11536 "transformation": "trivial_condition_removal",
11537 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11538 }
11539 ] /* steps */
11540 } /* condition_processing */
11541 },
11542 {
11543 "table": "`t1`",
11544 "range_analysis": {
11545 "table_scan": {
11546 "rows": 3,
11547 "cost": 2.91263
11548 } /* table_scan */
11549 } /* range_analysis */
11550 }
11551 ] /* steps */
11552 } 0 0
11553 select sum(data) into ret from t1 {
11554 "steps": [
11555 {
11556 "join_optimization": {
11557 "select#": 1,
11558 "steps": [
11559 {
11560 "table_dependencies": [
11561 {
11562 "table": "`t1`",
11563 "row_may_be_null": false,
11564 "map_bit": 0,
11565 "depends_on_map_bits": [
11566 ] /* depends_on_map_bits */
11567 }
11568 ] /* table_dependencies */
11569 },
11570 {
11571 "rows_estimation": [
11572 {
11573 "table": "`t1`",
11574 "table_scan": {
11575 "rows": 2,
11576 "cost": 0.512634
11577 } /* table_scan */
11578 }
11579 ] /* rows_estimation */
11580 },
11581 {
11582 "considered_execution_plans": [
11583 {
11584 "plan_prefix": [
11585 ] /* plan_prefix */,
11586 "table": "`t1`",
11587 "best_access_path": {
11588 "considered_access_paths": [
11589 {
11590 "rows_to_scan": 2,
11591 "access_type": "scan",
11592 "resulting_rows": 2,
11593 "cost": 0.712634,
11594 "chosen": true
11595 }
11596 ] /* considered_access_paths */
11597 } /* best_access_path */,
11598 "condition_filtering_pct": 100,
11599 "rows_for_plan": 2,
11600 "cost_for_plan": 0.712634,
11601 "chosen": true
11602 }
11603 ] /* considered_execution_plans */
11604 },
11605 {
11606 "attaching_conditions_to_tables": {
11607 "original_condition": null,
11608 "attached_conditions_computation": [
11609 ] /* attached_conditions_computation */,
11610 "attached_conditions_summary": [
11611 {
11612 "table": "`t1`",
11613 "attached": null
11614 }
11615 ] /* attached_conditions_summary */
11616 } /* attaching_conditions_to_tables */
11617 },
11618 {
11619 "optimizing_distinct_group_by_order_by": {
11620 } /* optimizing_distinct_group_by_order_by */
11621 },
11622 {
11623 "finalizing_table_conditions": [
11624 ] /* finalizing_table_conditions */
11625 },
11626 {
11627 "refine_plan": [
11628 {
11629 "table": "`t1`"
11630 }
11631 ] /* refine_plan */
11632 },
11633 {
11634 "considering_tmp_tables": [
11635 ] /* considering_tmp_tables */
11636 }
11637 ] /* steps */
11638 } /* join_optimization */
11639 },
11640 {
11641 "join_execution": {
11642 "select#": 1,
11643 "steps": [
11644 ] /* steps */
11645 } /* join_execution */
11646 }
11647 ] /* steps */
11648 } 0 0
11649 freturn 3 ret@0 {
11650 "steps": [
11651 ] /* steps */
11652 } 0 0
11653 set ret@0 NULL {
11654 "steps": [
11655 ] /* steps */
11656 } 0 0
11657 insert into t1 values("z",0) {
11658 "steps": [
11659 ] /* steps */
11660 } 0 0
11661 delete from t1 where id="z" {
11662 "steps": [
11663 {
11664 "substitute_generated_columns": {
11665 } /* substitute_generated_columns */
11666 },
11667 {
11668 "condition_processing": {
11669 "condition": "WHERE",
11670 "original_condition": "(`t1`.`id` = 'z')",
11671 "steps": [
11672 {
11673 "transformation": "equality_propagation",
11674 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11675 },
11676 {
11677 "transformation": "constant_propagation",
11678 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11679 },
11680 {
11681 "transformation": "trivial_condition_removal",
11682 "resulting_condition": "multiple equal('z', `t1`.`id`)"
11683 }
11684 ] /* steps */
11685 } /* condition_processing */
11686 },
11687 {
11688 "table": "`t1`",
11689 "range_analysis": {
11690 "table_scan": {
11691 "rows": 3,
11692 "cost": 2.91263
11693 } /* table_scan */
11694 } /* range_analysis */
11695 }
11696 ] /* steps */
11697 } 0 0
11698 select sum(data) into ret from t1 {
11699 "steps": [
11700 {
11701 "join_optimization": {
11702 "select#": 1,
11703 "steps": [
11704 {
11705 "table_dependencies": [
11706 {
11707 "table": "`t1`",
11708 "row_may_be_null": false,
11709 "map_bit": 0,
11710 "depends_on_map_bits": [
11711 ] /* depends_on_map_bits */
11712 }
11713 ] /* table_dependencies */
11714 },
11715 {
11716 "rows_estimation": [
11717 {
11718 "table": "`t1`",
11719 "table_scan": {
11720 "rows": 2,
11721 "cost": 0.512634
11722 } /* table_scan */
11723 }
11724 ] /* rows_estimation */
11725 },
11726 {
11727 "considered_execution_plans": [
11728 {
11729 "plan_prefix": [
11730 ] /* plan_prefix */,
11731 "table": "`t1`",
11732 "best_access_path": {
11733 "considered_access_paths": [
11734 {
11735 "rows_to_scan": 2,
11736 "access_type": "scan",
11737 "resulting_rows": 2,
11738 "cost": 0.712634,
11739 "chosen": true
11740 }
11741 ] /* considered_access_paths */
11742 } /* best_access_path */,
11743 "condition_filtering_pct": 100,
11744 "rows_for_plan": 2,
11745 "cost_for_plan": 0.712634,
11746 "chosen": true
11747 }
11748 ] /* considered_execution_plans */
11749 },
11750 {
11751 "attaching_conditions_to_tables": {
11752 "original_condition": null,
11753 "attached_conditions_computation": [
11754 ] /* attached_conditions_computation */,
11755 "attached_conditions_summary": [
11756 {
11757 "table": "`t1`",
11758 "attached": null
11759 }
11760 ] /* attached_conditions_summary */
11761 } /* attaching_conditions_to_tables */
11762 },
11763 {
11764 "optimizing_distinct_group_by_order_by": {
11765 } /* optimizing_distinct_group_by_order_by */
11766 },
11767 {
11768 "finalizing_table_conditions": [
11769 ] /* finalizing_table_conditions */
11770 },
11771 {
11772 "refine_plan": [
11773 {
11774 "table": "`t1`"
11775 }
11776 ] /* refine_plan */
11777 },
11778 {
11779 "considering_tmp_tables": [
11780 ] /* considering_tmp_tables */
11781 }
11782 ] /* steps */
11783 } /* join_optimization */
11784 },
11785 {
11786 "join_execution": {
11787 "select#": 1,
11788 "steps": [
11789 ] /* steps */
11790 } /* join_execution */
11791 }
11792 ] /* steps */
11793 } 0 0
11794 freturn 3 ret@0 {
11795 "steps": [
11796 ] /* steps */
11797 } 0 0
11798 select @@optimizer_trace|
11799 @@optimizer_trace
11800 enabled=off,one_line=off
11801 set optimizer_trace="enabled=on";
11802 drop temporary table optt;
11803 drop function f1;
11804 drop procedure p1;
11805 drop trigger trg1;
11806 create view v1 as select * from t1 where id < "c";
11807 explain select * from v1 where id="b";
11808 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
11809 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 2 50.00 Using where
11810 Warnings:
11811 Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`data` AS `data` from `test`.`t1` where (`test`.`t1`.`id` = 'b')
11812 select * from information_schema.OPTIMIZER_TRACE;
11813 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
11814 explain select * from v1 where id="b" {
11815 "steps": [
11816 {
11817 "join_preparation": {
11818 "select#": 1,
11819 "steps": [
11820 {
11821 "join_preparation": {
11822 "select#": 2,
11823 "steps": [
11824 {
11825 "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c')"
11826 }
11827 ] /* steps */
11828 } /* join_preparation */
11829 },
11830 {
11831 "view": {
11832 "table": "`v1`",
11833 "select#": 2,
11834 "merged": true
11835 } /* view */
11836 },
11837 {
11838 "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')"
11839 },
11840 {
11841 "transformations_to_nested_joins": {
11842 "transformations": [
11843 "JOIN_condition_to_WHERE",
11844 "parenthesis_removal"
11845 ] /* transformations */,
11846 "expanded_query": "/* select#1 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where ((`t1`.`id` = 'b') and (`t1`.`id` < 'c'))"
11847 } /* transformations_to_nested_joins */
11848 }
11849 ] /* steps */
11850 } /* join_preparation */
11851 },
11852 {
11853 "join_optimization": {
11854 "select#": 1,
11855 "steps": [
11856 {
11857 "condition_processing": {
11858 "condition": "WHERE",
11859 "original_condition": "((`t1`.`id` = 'b') and (`t1`.`id` < 'c'))",
11860 "steps": [
11861 {
11862 "transformation": "equality_propagation",
11863 "resulting_condition": "(('b' < 'c') and multiple equal('b', `t1`.`id`))"
11864 },
11865 {
11866 "transformation": "constant_propagation",
11867 "resulting_condition": "(('b' < 'c') and multiple equal('b', `t1`.`id`))"
11868 },
11869 {
11870 "transformation": "trivial_condition_removal",
11871 "resulting_condition": "multiple equal('b', `t1`.`id`)"
11872 }
11873 ] /* steps */
11874 } /* condition_processing */
11875 },
11876 {
11877 "substitute_generated_columns": {
11878 } /* substitute_generated_columns */
11879 },
11880 {
11881 "table_dependencies": [
11882 {
11883 "table": "`t1`",
11884 "row_may_be_null": false,
11885 "map_bit": 0,
11886 "depends_on_map_bits": [
11887 ] /* depends_on_map_bits */
11888 }
11889 ] /* table_dependencies */
11890 },
11891 {
11892 "ref_optimizer_key_uses": [
11893 ] /* ref_optimizer_key_uses */
11894 },
11895 {
11896 "rows_estimation": [
11897 {
11898 "table": "`t1`",
11899 "table_scan": {
11900 "rows": 2,
11901 "cost": 0.512634
11902 } /* table_scan */
11903 }
11904 ] /* rows_estimation */
11905 },
11906 {
11907 "considered_execution_plans": [
11908 {
11909 "plan_prefix": [
11910 ] /* plan_prefix */,
11911 "table": "`t1`",
11912 "best_access_path": {
11913 "considered_access_paths": [
11914 {
11915 "rows_to_scan": 2,
11916 "filtering_effect": [
11917 ] /* filtering_effect */,
11918 "final_filtering_effect": 0.5,
11919 "access_type": "scan",
11920 "resulting_rows": 1,
11921 "cost": 0.712634,
11922 "chosen": true
11923 }
11924 ] /* considered_access_paths */
11925 } /* best_access_path */,
11926 "condition_filtering_pct": 100,
11927 "rows_for_plan": 1,
11928 "cost_for_plan": 0.712634,
11929 "chosen": true
11930 }
11931 ] /* considered_execution_plans */
11932 },
11933 {
11934 "attaching_conditions_to_tables": {
11935 "original_condition": "(`t1`.`id` = 'b')",
11936 "attached_conditions_computation": [
11937 ] /* attached_conditions_computation */,
11938 "attached_conditions_summary": [
11939 {
11940 "table": "`t1`",
11941 "attached": "(`t1`.`id` = 'b')"
11942 }
11943 ] /* attached_conditions_summary */
11944 } /* attaching_conditions_to_tables */
11945 },
11946 {
11947 "finalizing_table_conditions": [
11948 {
11949 "table": "`t1`",
11950 "original_table_condition": "(`t1`.`id` = 'b')",
11951 "final_table_condition ": "(`t1`.`id` = 'b')"
11952 }
11953 ] /* finalizing_table_conditions */
11954 },
11955 {
11956 "refine_plan": [
11957 {
11958 "table": "`t1`"
11959 }
11960 ] /* refine_plan */
11961 }
11962 ] /* steps */
11963 } /* join_optimization */
11964 },
11965 {
11966 "join_explain": {
11967 "select#": 1,
11968 "steps": [
11969 ] /* steps */
11970 } /* join_explain */
11971 }
11972 ] /* steps */
11973 } 0 0
11974 insert into v1 values("z", 100);
11975 select * from information_schema.OPTIMIZER_TRACE;
11976 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
11977 insert into v1 values("z", 100) {
11978 "steps": [
11979 ] /* steps */
11980 } 0 0
11981 delete from v1 where data=100;
11982 select * from information_schema.OPTIMIZER_TRACE;
11983 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
11984 delete from v1 where data=100 {
11985 "steps": [
11986 {
11987 "substitute_generated_columns": {
11988 } /* substitute_generated_columns */
11989 },
11990 {
11991 "condition_processing": {
11992 "condition": "WHERE",
11993 "original_condition": "((`t1`.`data` = 100) and (`t1`.`id` < 'c'))",
11994 "steps": [
11995 {
11996 "transformation": "equality_propagation",
11997 "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
11998 },
11999 {
12000 "transformation": "constant_propagation",
12001 "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
12002 },
12003 {
12004 "transformation": "trivial_condition_removal",
12005 "resulting_condition": "((`t1`.`id` < 'c') and multiple equal(100, `t1`.`data`))"
12006 }
12007 ] /* steps */
12008 } /* condition_processing */
12009 },
12010 {
12011 "table": "`t1`",
12012 "range_analysis": {
12013 "table_scan": {
12014 "rows": 3,
12015 "cost": 2.91263
12016 } /* table_scan */
12017 } /* range_analysis */
12018 }
12019 ] /* steps */
12020 } 0 0
12021 drop view v1;
12022 create view v1 as select * from t1 where id < "c" limit 2;
12023 explain select * from v1 where id="b";
12024 id select_type table partitions type possible_keys key key_len ref rows filtered Extra
12025 1 PRIMARY <derived2> NULL ref <auto_key0> <auto_key0> 64 const 1 100.00 Using where
12026 2 DERIVED t1 NULL ALL NULL NULL NULL NULL 3 33.33 Using where
12027 Warnings:
12028 Note 1003 /* select#1 */ select `test`.`v1`.`id` AS `id`,`test`.`v1`.`data` AS `data` from `test`.`v1` where (`test`.`v1`.`id` = 'b')
12029 select * from information_schema.OPTIMIZER_TRACE;
12030 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12031 explain select * from v1 where id="b" {
12032 "steps": [
12033 {
12034 "join_preparation": {
12035 "select#": 1,
12036 "steps": [
12037 {
12038 "join_preparation": {
12039 "select#": 2,
12040 "steps": [
12041 {
12042 "expanded_query": "/* select#2 */ select `t1`.`id` AS `id`,`t1`.`data` AS `data` from `t1` where (`t1`.`id` < 'c') limit 2"
12043 }
12044 ] /* steps */
12045 } /* join_preparation */
12046 },
12047 {
12048 "view": {
12049 "table": "`v1`",
12050 "select#": 2,
12051 "materialized": true
12052 } /* view */
12053 },
12054 {
12055 "expanded_query": "/* select#1 */ select `v1`.`id` AS `id`,`v1`.`data` AS `data` from `v1` where (`v1`.`id` = 'b')"
12056 }
12057 ] /* steps */
12058 } /* join_preparation */
12059 },
12060 {
12061 "join_optimization": {
12062 "select#": 1,
12063 "steps": [
12064 {
12065 "join_optimization": {
12066 "select#": 2,
12067 "steps": [
12068 {
12069 "condition_processing": {
12070 "condition": "WHERE",
12071 "original_condition": "(`t1`.`id` < 'c')",
12072 "steps": [
12073 {
12074 "transformation": "equality_propagation",
12075 "resulting_condition": "(`t1`.`id` < 'c')"
12076 },
12077 {
12078 "transformation": "constant_propagation",
12079 "resulting_condition": "(`t1`.`id` < 'c')"
12080 },
12081 {
12082 "transformation": "trivial_condition_removal",
12083 "resulting_condition": "(`t1`.`id` < 'c')"
12084 }
12085 ] /* steps */
12086 } /* condition_processing */
12087 },
12088 {
12089 "substitute_generated_columns": {
12090 } /* substitute_generated_columns */
12091 },
12092 {
12093 "table_dependencies": [
12094 {
12095 "table": "`t1`",
12096 "row_may_be_null": false,
12097 "map_bit": 0,
12098 "depends_on_map_bits": [
12099 ] /* depends_on_map_bits */
12100 }
12101 ] /* table_dependencies */
12102 },
12103 {
12104 "ref_optimizer_key_uses": [
12105 ] /* ref_optimizer_key_uses */
12106 },
12107 {
12108 "rows_estimation": [
12109 {
12110 "table": "`t1`",
12111 "table_scan": {
12112 "rows": 3,
12113 "cost": 0.512634
12114 } /* table_scan */
12115 }
12116 ] /* rows_estimation */
12117 },
12118 {
12119 "considered_execution_plans": [
12120 {
12121 "plan_prefix": [
12122 ] /* plan_prefix */,
12123 "table": "`t1`",
12124 "best_access_path": {
12125 "considered_access_paths": [
12126 {
12127 "rows_to_scan": 3,
12128 "filtering_effect": [
12129 ] /* filtering_effect */,
12130 "final_filtering_effect": 0.333333,
12131 "access_type": "scan",
12132 "resulting_rows": 1,
12133 "cost": 0.812634,
12134 "chosen": true
12135 }
12136 ] /* considered_access_paths */
12137 } /* best_access_path */,
12138 "condition_filtering_pct": 100,
12139 "rows_for_plan": 1,
12140 "cost_for_plan": 0.812634,
12141 "chosen": true
12142 }
12143 ] /* considered_execution_plans */
12144 },
12145 {
12146 "attaching_conditions_to_tables": {
12147 "original_condition": "(`t1`.`id` < 'c')",
12148 "attached_conditions_computation": [
12149 ] /* attached_conditions_computation */,
12150 "attached_conditions_summary": [
12151 {
12152 "table": "`t1`",
12153 "attached": "(`t1`.`id` < 'c')"
12154 }
12155 ] /* attached_conditions_summary */
12156 } /* attaching_conditions_to_tables */
12157 },
12158 {
12159 "finalizing_table_conditions": [
12160 {
12161 "table": "`t1`",
12162 "original_table_condition": "(`t1`.`id` < 'c')",
12163 "final_table_condition ": "(`t1`.`id` < 'c')"
12164 }
12165 ] /* finalizing_table_conditions */
12166 },
12167 {
12168 "refine_plan": [
12169 {
12170 "table": "`t1`"
12171 }
12172 ] /* refine_plan */
12173 }
12174 ] /* steps */
12175 } /* join_optimization */
12176 },
12177 {
12178 "condition_processing": {
12179 "condition": "WHERE",
12180 "original_condition": "(`v1`.`id` = 'b')",
12181 "steps": [
12182 {
12183 "transformation": "equality_propagation",
12184 "resulting_condition": "multiple equal('b', `v1`.`id`)"
12185 },
12186 {
12187 "transformation": "constant_propagation",
12188 "resulting_condition": "multiple equal('b', `v1`.`id`)"
12189 },
12190 {
12191 "transformation": "trivial_condition_removal",
12192 "resulting_condition": "multiple equal('b', `v1`.`id`)"
12193 }
12194 ] /* steps */
12195 } /* condition_processing */
12196 },
12197 {
12198 "substitute_generated_columns": {
12199 } /* substitute_generated_columns */
12200 },
12201 {
12202 "table_dependencies": [
12203 {
12204 "table": "`v1`",
12205 "row_may_be_null": false,
12206 "map_bit": 0,
12207 "depends_on_map_bits": [
12208 ] /* depends_on_map_bits */
12209 }
12210 ] /* table_dependencies */
12211 },
12212 {
12213 "ref_optimizer_key_uses": [
12214 {
12215 "table": "`v1`",
12216 "field": "id",
12217 "equals": "'b'",
12218 "null_rejecting": true
12219 }
12220 ] /* ref_optimizer_key_uses */
12221 },
12222 {
12223 "rows_estimation": [
12224 {
12225 "table": "`v1`"
12226 }
12227 ] /* rows_estimation */
12228 },
12229 {
12230 "considered_execution_plans": [
12231 {
12232 "plan_prefix": [
12233 ] /* plan_prefix */,
12234 "table": "`v1`",
12235 "best_access_path": {
12236 "considered_access_paths": [
12237 {
12238 "access_type": "ref",
12239 "index": "<auto_key0>",
12240 "rows": 1,
12241 "cost": 0.35,
12242 "chosen": true
12243 },
12244 {
12245 "access_type": "scan",
12246 "cost": 2.725,
12247 "rows": 2,
12248 "chosen": false,
12249 "cause": "cost"
12250 }
12251 ] /* considered_access_paths */
12252 } /* best_access_path */,
12253 "condition_filtering_pct": 100,
12254 "rows_for_plan": 1,
12255 "cost_for_plan": 0.35,
12256 "chosen": true
12257 }
12258 ] /* considered_execution_plans */
12259 },
12260 {
12261 "attaching_conditions_to_tables": {
12262 "original_condition": "(`v1`.`id` = 'b')",
12263 "attached_conditions_computation": [
12264 ] /* attached_conditions_computation */,
12265 "attached_conditions_summary": [
12266 {
12267 "table": "`v1`",
12268 "attached": "(`v1`.`id` = 'b')"
12269 }
12270 ] /* attached_conditions_summary */
12271 } /* attaching_conditions_to_tables */
12272 },
12273 {
12274 "finalizing_table_conditions": [
12275 {
12276 "table": "`v1`",
12277 "original_table_condition": "(`v1`.`id` = 'b')",
12278 "final_table_condition ": "(`v1`.`id` = 'b')"
12279 }
12280 ] /* finalizing_table_conditions */
12281 },
12282 {
12283 "refine_plan": [
12284 {
12285 "table": "`v1`"
12286 }
12287 ] /* refine_plan */
12288 }
12289 ] /* steps */
12290 } /* join_optimization */
12291 },
12292 {
12293 "join_explain": {
12294 "select#": 1,
12295 "steps": [
12296 {
12297 "join_explain": {
12298 "select#": 2,
12299 "steps": [
12300 ] /* steps */
12301 } /* join_explain */
12302 }
12303 ] /* steps */
12304 } /* join_explain */
12305 }
12306 ] /* steps */
12307 } 0 0
12308 drop view v1;
12309 set end_markers_in_json=off;
12310 select 1 union select 2;
12311 1
12312 1
12313 2
12314 select TRACE into dumpfile 'MYSQLTEST_VARDIR/tmp/optimizer_trace.txt' from information_schema.OPTIMIZER_TRACE;;
12315 {
12316 "steps": [
12317 {
12318 "join_optimization": {
12319 "select#": 1,
12320 "steps": [
12321 ]
12322 }
12323 },
12324 {
12325 "join_optimization": {
12326 "select#": 2,
12327 "steps": [
12328 ]
12329 }
12330 },
12331 {
12332 "creating_tmp_table": {
12333 "tmp_table_info": {
12334 "table": "<union temporary>",
12335 "columns": 1,
12336 "row_length": 9,
12337 "key_length": 8,
12338 "unique_constraint": false,
12339 "makes_grouped_rows": false,
12340 "cannot_insert_duplicates": true,
12341 "location": "TempTable"
12342 }
12343 }
12344 },
12345 {
12346 "join_optimization": {
12347 "select#": 3,
12348 "steps": [
12349 {
12350 "table_dependencies": [
12351 {
12352 "table": "``",
12353 "row_may_be_null": false,
12354 "map_bit": 0,
12355 "depends_on_map_bits": [
12356 ]
12357 }
12358 ]
12359 },
12360 {
12361 "rows_estimation": [
12362 {
12363 "table": "``",
12364 "table_scan": {
12365 "rows": 0,
12366 "cost": 2.5
12367 }
12368 }
12369 ]
12370 },
12371 {
12372 "considered_execution_plans": [
12373 {
12374 "plan_prefix": [
12375 ],
12376 "table": "``",
12377 "best_access_path": {
12378 "considered_access_paths": [
12379 {
12380 "rows_to_scan": 0,
12381 "access_type": "scan",
12382 "resulting_rows": 0,
12383 "cost": 2.5,
12384 "chosen": true
12385 }
12386 ]
12387 },
12388 "condition_filtering_pct": 100,
12389 "rows_for_plan": 0,
12390 "cost_for_plan": 2.5,
12391 "chosen": true
12392 }
12393 ]
12394 },
12395 {
12396 "attaching_conditions_to_tables": {
12397 "original_condition": null,
12398 "attached_conditions_computation": [
12399 ],
12400 "attached_conditions_summary": [
12401 {
12402 "table": "``",
12403 "attached": null
12404 }
12405 ]
12406 }
12407 },
12408 {
12409 "finalizing_table_conditions": [
12410 ]
12411 },
12412 {
12413 "refine_plan": [
12414 {
12415 "table": "``"
12416 }
12417 ]
12418 }
12419 ]
12420 }
12421 },
12422 {
12423 "join_execution": {
12424 "steps": [
12425 {
12426 "materialize": {
12427 "select#": 1,
12428 "steps": [
12429 ]
12430 }
12431 },
12432 {
12433 "materialize": {
12434 "select#": 2,
12435 "steps": [
12436 ]
12437 }
12438 }
12439 ]
12440 }
12441 }
12442 ]
12443 }set optimizer_switch='default,index_merge=on,index_merge=off,default';
12444 ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'index_merge=off,default'
12445 select @@optimizer_switch=@old_opt_switch;
12446 @@optimizer_switch=@old_opt_switch
12447 1
12448 select * from information_schema.OPTIMIZER_TRACE;
12449 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12450 select "abc1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111def" as col {
12451 "steps": [
12452 {
12453 "join_optimization": {
12454 "select#": 1,
12455 "steps": [
12456 ]
12457 }
12458 },
12459 {
12460 "join_execution": {
12461 "select#": 1,
12462 "steps": [
12463 ]
12464 }
12465 }
12466 ]
12467 } 0 0
12468 drop table t1,t2;
12469 DROP TABLE t5,t6;
12470 # Trace for transformation scalar subquery to derived table
12471 CREATE TABLE t1(a INT);
12472 CREATE TABLE t2(a INT);
12473 INSERT INTO t1 VALUES (1),(2),(3),(4);
12474 INSERT INTO t2 VALUES (1),(2);
12475 ANALYZE TABLE t1, t2;
12476 Table Op Msg_type Msg_text
12477 test.t1 analyze status OK
12478 test.t2 analyze status OK
12479 SET optimizer_switch='subquery_to_derived=on';
12480 SELECT a + (SELECT SUM(a) + (SELECT COUNT(a) FROM t1) FROM t1) AS cnt FROM t2;
12481 cnt
12482 15
12483 16
12484 SELECT * FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
12485 QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
12486 SELECT a + (SELECT SUM(a) + (SELECT COUNT(a) FROM t1) FROM t1) AS cnt FROM t2 {
12487 "steps": [
12488 {
12489 "join_optimization": {
12490 "select#": 1,
12491 "steps": [
12492 {
12493 "join_optimization": {
12494 "select#": 2,
12495 "steps": [
12496 {
12497 "join_optimization": {
12498 "select#": 4,
12499 "steps": [
12500 {
12501 "table_dependencies": [
12502 {
12503 "table": "`t1`",
12504 "row_may_be_null": false,
12505 "map_bit": 0,
12506 "depends_on_map_bits": [
12507 ]
12508 }
12509 ]
12510 },
12511 {
12512 "rows_estimation": [
12513 {
12514 "table": "`t1`",
12515 "table_scan": {
12516 "rows": 4,
12517 "cost": 0.501709
12518 }
12519 }
12520 ]
12521 },
12522 {
12523 "considered_execution_plans": [
12524 {
12525 "plan_prefix": [
12526 ],
12527 "table": "`t1`",
12528 "best_access_path": {
12529 "considered_access_paths": [
12530 {
12531 "rows_to_scan": 4,
12532 "access_type": "scan",
12533 "resulting_rows": 4,
12534 "cost": 0.901709,
12535 "chosen": true
12536 }
12537 ]
12538 },
12539 "condition_filtering_pct": 100,
12540 "rows_for_plan": 4,
12541 "cost_for_plan": 0.901709,
12542 "chosen": true
12543 }
12544 ]
12545 },
12546 {
12547 "attaching_conditions_to_tables": {
12548 "original_condition": null,
12549 "attached_conditions_computation": [
12550 ],
12551 "attached_conditions_summary": [
12552 {
12553 "table": "`t1`",
12554 "attached": null
12555 }
12556 ]
12557 }
12558 },
12559 {
12560 "optimizing_distinct_group_by_order_by": {
12561 }
12562 },
12563 {
12564 "finalizing_table_conditions": [
12565 ]
12566 },
12567 {
12568 "refine_plan": [
12569 {
12570 "table": "`t1`"
12571 }
12572 ]
12573 },
12574 {
12575 "considering_tmp_tables": [
12576 ]
12577 }
12578 ]
12579 }
12580 },
12581 {
12582 "creating_tmp_table": {
12583 "tmp_table_info": {
12584 "table": "derived_2_4",
12585 "columns": 1,
12586 "row_length": 16,
12587 "key_length": 0,
12588 "unique_constraint": false,
12589 "makes_grouped_rows": false,
12590 "cannot_insert_duplicates": false,
12591 "location": "TempTable"
12592 }
12593 }
12594 },
12595 {
12596 "join_execution": {
12597 "select#": 4,
12598 "steps": [
12599 ]
12600 }
12601 },
12602 {
12603 "join_optimization": {
12604 "select#": 5,
12605 "steps": [
12606 {
12607 "table_dependencies": [
12608 {
12609 "table": "`t1`",
12610 "row_may_be_null": false,
12611 "map_bit": 0,
12612 "depends_on_map_bits": [
12613 ]
12614 }
12615 ]
12616 },
12617 {
12618 "rows_estimation": [
12619 {
12620 "table": "`t1`",
12621 "table_scan": {
12622 "rows": 4,
12623 "cost": 0.501709
12624 }
12625 }
12626 ]
12627 },
12628 {
12629 "considered_execution_plans": [
12630 {
12631 "plan_prefix": [
12632 ],
12633 "table": "`t1`",
12634 "best_access_path": {
12635 "considered_access_paths": [
12636 {
12637 "rows_to_scan": 4,
12638 "access_type": "scan",
12639 "resulting_rows": 4,
12640 "cost": 0.901709,
12641 "chosen": true
12642 }
12643 ]
12644 },
12645 "condition_filtering_pct": 100,
12646 "rows_for_plan": 4,
12647 "cost_for_plan": 0.901709,
12648 "chosen": true
12649 }
12650 ]
12651 },
12652 {
12653 "attaching_conditions_to_tables": {
12654 "original_condition": null,
12655 "attached_conditions_computation": [
12656 ],
12657 "attached_conditions_summary": [
12658 {
12659 "table": "`t1`",
12660 "attached": null
12661 }
12662 ]
12663 }
12664 },
12665 {
12666 "optimizing_distinct_group_by_order_by": {
12667 }
12668 },
12669 {
12670 "finalizing_table_conditions": [
12671 ]
12672 },
12673 {
12674 "refine_plan": [
12675 {
12676 "table": "`t1`"
12677 }
12678 ]
12679 },
12680 {
12681 "considering_tmp_tables": [
12682 ]
12683 }
12684 ]
12685 }
12686 },
12687 {
12688 "creating_tmp_table": {
12689 "tmp_table_info": {
12690 "table": "derived_2_5",
12691 "columns": 1,
12692 "row_length": 9,
12693 "key_length": 0,
12694 "unique_constraint": false,
12695 "makes_grouped_rows": false,
12696 "cannot_insert_duplicates": false,
12697 "location": "TempTable"
12698 }
12699 }
12700 },
12701 {
12702 "join_execution": {
12703 "select#": 5,
12704 "steps": [
12705 ]
12706 }
12707 },
12708 {
12709 "condition_processing": {
12710 "condition": "WHERE",
12711 "original_condition": null,
12712 "steps": [
12713 {
12714 "transformation": "equality_propagation",
12715 "resulting_condition": null
12716 }
12717 ]
12718 }
12719 },
12720 {
12721 "table_dependencies": [
12722 {
12723 "table": " `derived_2_4`",
12724 "row_may_be_null": false,
12725 "map_bit": 0,
12726 "depends_on_map_bits": [
12727 ]
12728 },
12729 {
12730 "table": " `derived_2_5`",
12731 "row_may_be_null": true,
12732 "map_bit": 1,
12733 "depends_on_map_bits": [
12734 0
12735 ]
12736 }
12737 ]
12738 },
12739 {
12740 "ref_optimizer_key_uses": [
12741 ]
12742 },
12743 {
12744 "rows_estimation": [
12745 {
12746 "table": " `derived_2_4`",
12747 "rows": 1,
12748 "cost": 1,
12749 "table_type": "system",
12750 "empty": false
12751 },
12752 {
12753 "table": " `derived_2_5`",
12754 "rows": 1,
12755 "cost": 1,
12756 "table_type": "system",
12757 "empty": false
12758 }
12759 ]
12760 },
12761 {
12762 "condition_on_constant_tables": "true",
12763 "condition_value": true
12764 },
12765 {
12766 "attaching_conditions_to_tables": {
12767 "original_condition": "true",
12768 "attached_conditions_computation": [
12769 ],
12770 "attached_conditions_summary": [
12771 ]
12772 }
12773 },
12774 {
12775 "refine_plan": [
12776 ]
12777 }
12778 ]
12779 }
12780 },
12781 {
12782 "creating_tmp_table": {
12783 "tmp_table_info": {
12784 "table": "derived_1_2",
12785 "columns": 1,
12786 "row_length": 16,
12787 "key_length": 0,
12788 "unique_constraint": false,
12789 "makes_grouped_rows": false,
12790 "cannot_insert_duplicates": false,
12791 "location": "TempTable"
12792 }
12793 }
12794 },
12795 {
12796 "join_execution": {
12797 "select#": 2,
12798 "steps": [
12799 ]
12800 }
12801 },
12802 {
12803 "condition_processing": {
12804 "condition": "WHERE",
12805 "original_condition": null,
12806 "steps": [
12807 {
12808 "transformation": "equality_propagation",
12809 "resulting_condition": null
12810 }
12811 ]
12812 }
12813 },
12814 {
12815 "table_dependencies": [
12816 {
12817 "table": "`t2`",
12818 "row_may_be_null": false,
12819 "map_bit": 0,
12820 "depends_on_map_bits": [
12821 ]
12822 },
12823 {
12824 "table": " `derived_1_2`",
12825 "row_may_be_null": true,
12826 "map_bit": 1,
12827 "depends_on_map_bits": [
12828 0
12829 ]
12830 }
12831 ]
12832 },
12833 {
12834 "ref_optimizer_key_uses": [
12835 ]
12836 },
12837 {
12838 "rows_estimation": [
12839 {
12840 "table": "`t2`",
12841 "table_scan": {
12842 "rows": 2,
12843 "cost": 0.500854
12844 }
12845 },
12846 {
12847 "table": " `derived_1_2`",
12848 "table_scan": {
12849 "rows": 1,
12850 "cost": 2.5125
12851 }
12852 }
12853 ]
12854 },
12855 {
12856 "considered_execution_plans": [
12857 {
12858 "plan_prefix": [
12859 ],
12860 "table": "`t2`",
12861 "best_access_path": {
12862 "considered_access_paths": [
12863 {
12864 "rows_to_scan": 2,
12865 "access_type": "scan",
12866 "resulting_rows": 2,
12867 "cost": 0.700854,
12868 "chosen": true
12869 }
12870 ]
12871 },
12872 "condition_filtering_pct": 100,
12873 "rows_for_plan": 2,
12874 "cost_for_plan": 0.700854,
12875 "rest_of_plan": [
12876 {
12877 "plan_prefix": [
12878 "`t2`"
12879 ],
12880 "table": " `derived_1_2`",
12881 "best_access_path": {
12882 "considered_access_paths": [
12883 {
12884 "rows_to_scan": 1,
12885 "access_type": "scan",
12886 "using_join_cache": true,
12887 "buffers_needed": 1,
12888 "resulting_rows": 1,
12889 "cost": 2.7126,
12890 "chosen": true
12891 }
12892 ]
12893 },
12894 "condition_filtering_pct": 100,
12895 "rows_for_plan": 2,
12896 "cost_for_plan": 3.41345,
12897 "chosen": true
12898 }
12899 ]
12900 }
12901 ]
12902 },
12903 {
12904 "condition_on_constant_tables": "true",
12905 "condition_value": true
12906 },
12907 {
12908 "attaching_conditions_to_tables": {
12909 "original_condition": "true",
12910 "attached_conditions_computation": [
12911 ],
12912 "attached_conditions_summary": [
12913 {
12914 "table": "`t2`",
12915 "attached": null
12916 },
12917 {
12918 "table": " `derived_1_2`",
12919 "attached": "<if>(is_not_null_compl(derived_1_2), true, true)"
12920 }
12921 ]
12922 }
12923 },
12924 {
12925 "finalizing_table_conditions": [
12926 {
12927 "table": " `derived_1_2`",
12928 "original_table_condition": "<if>(is_not_null_compl(derived_1_2), true, true)",
12929 "final_table_condition ": "<if>(is_not_null_compl(derived_1_2), true, true)"
12930 }
12931 ]
12932 },
12933 {
12934 "refine_plan": [
12935 {
12936 "table": "`t2`"
12937 },
12938 {
12939 "table": " `derived_1_2`"
12940 }
12941 ]
12942 }
12943 ]
12944 }
12945 },
12946 {
12947 "join_execution": {
12948 "select#": 1,
12949 "steps": [
12950 ]
12951 }
12952 }
12953 ]
12954 } 0 0
12955 SET optimizer_switch='subquery_to_derived=default';
12956 DROP TABLE t1, t2;
12957 SET optimizer_trace=default;