Debian Codegraph @

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

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