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