mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-36125 Cleanup ahead of [NO_]INDEX_MERGE
Introduces code cleanup and small refactorings, such as:
- Flip keys_to_use.is_clear_all() and de-dent
- Rename best_trp to best_read_plan
- Fix key_parts assignment spacing
- find_shortest_key now keeps happy path to the left
- Cleanup in the get_best_ror_intersect, remove_nonrange_trees,
and restore_nonrange_trees functions
- Reorganization of locals within test_quick_select
- De-dent some large code blocks by changing
if (key)
{
LOTS-OF-CODE;
}
into
if (!key)
continue;
LOTS-OF-CODE;
This commit is contained in:
committed by
Dave Gosselin
parent
8d08350dd3
commit
428c1d0511
@@ -934,8 +934,9 @@ hint_state hint_table_state(const THD *thd,
|
||||
}
|
||||
|
||||
|
||||
bool hint_key_state(const THD *thd, const TABLE *table, uint keyno,
|
||||
opt_hints_enum type_arg, bool fallback_value)
|
||||
bool hint_key_state(const THD *thd, const TABLE *table,
|
||||
uint keyno, opt_hints_enum type_arg,
|
||||
bool fallback_value)
|
||||
{
|
||||
Opt_hints_table *table_hints= table->pos_in_table_list->opt_hints_table;
|
||||
|
||||
|
||||
1103
sql/opt_range.cc
1103
sql/opt_range.cc
File diff suppressed because it is too large
Load Diff
@@ -27046,24 +27046,25 @@ uint find_shortest_key(TABLE *table, const key_map *usable_keys)
|
||||
uint best= MAX_KEY;
|
||||
uint possible_keys= usable_keys->bits_set();
|
||||
|
||||
if (possible_keys)
|
||||
{
|
||||
if (possible_keys == 1)
|
||||
return usable_keys->find_first_bit();
|
||||
if (!possible_keys)
|
||||
return best;
|
||||
|
||||
for (uint nr=0; nr < table->s->keys ; nr++)
|
||||
if (possible_keys == 1)
|
||||
return usable_keys->find_first_bit();
|
||||
|
||||
for (uint nr=0; nr < table->s->keys ; nr++)
|
||||
{
|
||||
if (!usable_keys->is_set(nr))
|
||||
continue;
|
||||
|
||||
const size_t length= table->key_storage_length(nr);
|
||||
if (length < min_length)
|
||||
{
|
||||
if (usable_keys->is_set(nr))
|
||||
{
|
||||
size_t length= table->key_storage_length(nr);
|
||||
if (length < min_length)
|
||||
{
|
||||
min_length= length;
|
||||
best= nr;
|
||||
}
|
||||
}
|
||||
min_length= length;
|
||||
best= nr;
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
@@ -33166,24 +33167,24 @@ test_if_cheaper_ordering(bool in_join_optimizer,
|
||||
/*
|
||||
Don't use an index scan with ORDER BY without limit.
|
||||
For GROUP BY without limit always use index scan
|
||||
if there is a suitable index.
|
||||
if there is a suitable index.
|
||||
Why we hold to this asymmetry hardly can be explained
|
||||
rationally. It's easy to demonstrate that using
|
||||
temporary table + filesort could be cheaper for grouping
|
||||
queries too.
|
||||
*/
|
||||
*/
|
||||
if (is_covering || has_limit ||
|
||||
(ref_key < 0 && (group || table->force_index)))
|
||||
{
|
||||
{
|
||||
double rec_per_key;
|
||||
if (group)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
Used_key_parts can be larger than keyinfo->user_defined_key_parts
|
||||
when using a secondary index clustered with a primary
|
||||
key (e.g. as in Innodb).
|
||||
when using a secondary index clustered with a primary
|
||||
key (e.g. as in Innodb).
|
||||
See Bug #28591 for details.
|
||||
*/
|
||||
*/
|
||||
KEY *keyinfo= table->key_info+nr;
|
||||
uint used_index_parts= keyinfo->user_defined_key_parts;
|
||||
uint used_pk_parts= 0;
|
||||
|
||||
Reference in New Issue
Block a user