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