mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-7118: Anemometer stop working after upgrade to from...
When the optimizer considers an option to use Loose Scan, it should still consider UNIQUE keys (Previously, MDEV-4120 disabled loose scan for all kinds of unique indexes. That was wrong) However, we should not use Loose Scan when trying to satisfy "SELECT DISTINCT col1, col2, .. colN" when using an index defined as UNIQU(col1, col2, ... colN).
This commit is contained in:
@@ -12801,11 +12801,11 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
|
||||
uint cur_used_key_parts;
|
||||
|
||||
/*
|
||||
Check (B1) - if current index is covering. Exclude UNIQUE indexes, because
|
||||
loose scan may still be chosen for them due to imperfect cost calculations.
|
||||
Check (B1) - if current index is covering.
|
||||
(was also: "Exclude UNIQUE indexes ..." but this was removed because
|
||||
there are cases Loose Scan over a multi-part index is useful).
|
||||
*/
|
||||
if (!table->covering_keys.is_set(cur_index) ||
|
||||
cur_index_info->flags & HA_NOSAME)
|
||||
if (!table->covering_keys.is_set(cur_index))
|
||||
goto next_index;
|
||||
|
||||
/*
|
||||
@@ -12943,6 +12943,16 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
|
||||
min_max_arg_part= cur_index_info->key_part + key_part_nr - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
Aplly a heuristic: there is no point to use loose index scan when we're
|
||||
using the whole unique index.
|
||||
*/
|
||||
if (cur_index_info->flags & HA_NOSAME &&
|
||||
cur_group_key_parts == cur_index_info->user_defined_key_parts)
|
||||
{
|
||||
goto next_index;
|
||||
}
|
||||
|
||||
/*
|
||||
Check (NGA1, NGA2) and extract a sequence of constants to be used as part
|
||||
of all search keys.
|
||||
|
Reference in New Issue
Block a user