Debian Codegraph @

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