mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-4120: UNIQUE indexes should not be considered for loose index scan
Currently the loose scan code in opt_range.cc considers all indexes as possible for the access method. Due to inexact statistics it may happen that a loose scan is selected over a unique index. This is clearly wrong since a "loose scan" over a unique index will read the same keys as a direct index scan, but the loose scan has more overhead. This task adds a rule to skip unique indexes for loose scan.
This commit is contained in:
@ -12411,8 +12411,12 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
|
||||
uchar cur_key_infix[MAX_KEY_LENGTH];
|
||||
uint cur_used_key_parts;
|
||||
|
||||
/* Check (B1) - if current index is covering. */
|
||||
if (!table->covering_keys.is_set(cur_index))
|
||||
/*
|
||||
Check (B1) - if current index is covering. Exclude UNIQUE indexes, because
|
||||
loose scan may still be chosen for them due to imperfect cost calculations.
|
||||
*/
|
||||
if (!table->covering_keys.is_set(cur_index) ||
|
||||
cur_index_info->flags & HA_NOSAME)
|
||||
goto next_index;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user