mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Range optimizer fix:
If cost(full_scan_on_shortest_covering_index) < cost(best_range_scan) < cost(full_table_scan) use full_scan_on_shortest_covering_index (before this fix best_range_scan was used)
This commit is contained in:
@ -1614,6 +1614,17 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
|
||||
}
|
||||
param.key_parts_end=key_parts;
|
||||
|
||||
/* Calculate cost of full index read for the shortest covering index */
|
||||
if (!head->used_keys.is_clear_all())
|
||||
{
|
||||
int key_for_use= find_shortest_key(head, &head->used_keys);
|
||||
double key_read_time= get_index_only_read_time(¶m, records,
|
||||
key_for_use);
|
||||
DBUG_PRINT("info", ("'all'+'using index' scan will be using key %d, "
|
||||
"read time %g", key_for_use, key_read_time));
|
||||
if (key_read_time < read_time)
|
||||
read_time= key_read_time;
|
||||
}
|
||||
|
||||
if ((tree=get_mm_tree(¶m,cond)))
|
||||
{
|
||||
@ -1676,17 +1687,6 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
|
||||
TABLE_READ_PLAN *best_conj_trp= NULL, *new_conj_trp;
|
||||
LINT_INIT(new_conj_trp); /* no empty index_merge lists possible */
|
||||
|
||||
/* Calculate cost of full index read for the shortest covering index */
|
||||
if (!head->used_keys.is_clear_all())
|
||||
{
|
||||
int key_for_use= find_shortest_key(head, &head->used_keys);
|
||||
double key_read_time= get_index_only_read_time(¶m, records,
|
||||
key_for_use);
|
||||
DBUG_PRINT("info", ("'all'+'using index' scan will be using key %d, "
|
||||
"read time %g", key_for_use, key_read_time));
|
||||
if (key_read_time < read_time)
|
||||
read_time= key_read_time;
|
||||
}
|
||||
|
||||
DBUG_PRINT("info",("No range reads possible,"
|
||||
" trying to construct index_merge"));
|
||||
|
Reference in New Issue
Block a user