|
I've discovered this when investigating MDEV-23809.
There is code get_best_combination that computes the number of aggregate tables:
/*
|
Additional plan nodes for postjoin tmp tables:
|
1? + // For GROUP BY
|
1? + // For DISTINCT
|
1? + // For aggregation functions aggregated in outer query
|
// when used with distinct
|
1? + // For ORDER BY
|
1? // buffer result
|
Up to 2 tmp tables are actually used, but it's hard to tell exact number
|
at this stage.
|
*/
|
uint aggr_tables= (group_list ? 1 : 0) +
|
(select_distinct ?
|
(tmp_table_param.using_outer_summary_function ? 2 : 1) : 0) +
|
(order ? 1 : 0) +
|
(select_options & (SELECT_BIG_RESULT | OPTION_BUFFER_RESULT) ? 1 : 0) ;
|
We don't have specific examples yet, but we suspect it might be incorrect.
One thing that was discovered is that tmp_table_param.using_outer_summary_function is set after this piece of code is executed.
|