mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix bug MDEV-641
Analysis: Range analysis discoveres that the query can be executed via loose index scan for GROUP BY. Later, GROUP BY analysis fails to confirm that the GROUP operation can be computed via an index because there is no logic to handle duplicate field references in the GROUP clause. As a result the optimizer produces an inconsistent plan. It constructs a temporary table, but on the other hand the group fields are not set to point there. Solution: Make loose scan analysis work in sync with order by analysis. In the case of duplicate columns loose scan will not be applicable. This limitation will be lifted in 10.0 by removing duplicate columns.
This commit is contained in:
@ -9481,6 +9481,13 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
|
||||
else
|
||||
goto next_index;
|
||||
}
|
||||
/*
|
||||
This function is called on the precondition that the index is covering.
|
||||
Therefore if the GROUP BY list contains more elements than the index,
|
||||
these are duplicates. The GROUP BY list cannot be a prefix of the index.
|
||||
*/
|
||||
if (cur_part == end_part && tmp_group)
|
||||
goto next_index;
|
||||
}
|
||||
/*
|
||||
Check (GA2) if this is a DISTINCT query.
|
||||
|
Reference in New Issue
Block a user