diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2014-11-19 17:14:49 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2014-11-19 17:14:49 +0300 |
commit | 00475d40d10ed53a16faec417575652c54493635 (patch) | |
tree | d2bf099ddd345ede070ddbff0eb96b121cd47daa /sql/opt_range.cc | |
parent | 416f267a7acc42fd0949b30a54344822b74ed380 (diff) | |
download | mariadb-git-00475d40d10ed53a16faec417575652c54493635.tar.gz |
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).
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index dec104c3903..a5c27fa66e2 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -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; /* @@ -12944,6 +12944,16 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time) } /* + 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. */ |