1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge branch '10.4' into 10.4-mdev16188

This commit is contained in:
Igor Babaev
2018-11-10 14:52:57 -08:00
1883 changed files with 72584 additions and 264686 deletions

View File

@ -2845,13 +2845,19 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
if (bitmap_is_set(used_fields, (*field_ptr)->field_index))
Column_statistics* col_stats= (*field_ptr)->read_stats;
if (bitmap_is_set(used_fields, (*field_ptr)->field_index)
&& col_stats && !col_stats->no_stat_values_provided()
&& !((*field_ptr)->type() == MYSQL_TYPE_GEOMETRY))
parts++;
}
KEY_PART *key_part;
uint keys= 0;
if (!parts)
return TRUE;
if (!(key_part= (KEY_PART *) alloc_root(param->mem_root,
sizeof(KEY_PART) * parts)))
return TRUE;
@ -2863,6 +2869,9 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
if (bitmap_is_set(used_fields, (*field_ptr)->field_index))
{
Field *field= *field_ptr;
if (field->type() == MYSQL_TYPE_GEOMETRY)
continue;
uint16 store_length;
uint16 max_key_part_length= (uint16) table->file->max_key_part_length();
key_part->key= keys;
@ -3020,7 +3029,18 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
table->cond_selectivity= 1.0;
if (!*cond || table_records == 0)
if (table_records == 0)
DBUG_RETURN(FALSE);
QUICK_SELECT_I *quick;
if ((quick=table->reginfo.join_tab->quick) &&
quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
{
table->cond_selectivity*= (quick->records/table_records);
DBUG_RETURN(FALSE);
}
if (!*cond)
DBUG_RETURN(FALSE);
if (table->pos_in_table_list->schema_table)
@ -3137,7 +3157,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
*/
if (thd->variables.optimizer_use_condition_selectivity > 2 &&
!bitmap_is_clear_all(used_fields))
!bitmap_is_clear_all(used_fields) &&
thd->variables.use_stat_tables > 0)
{
PARAM param;
MEM_ROOT alloc;
@ -3226,6 +3247,12 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
}
if (quick && (quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION ||
quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE))
{
table->cond_selectivity*= (quick->records/table_records);
}
bitmap_union(used_fields, &handled_columns);
/* Check if we can improve selectivity estimates by using sampling */
@ -7628,9 +7655,8 @@ SEL_TREE *Item_bool_func::get_full_func_mm_tree(RANGE_OPT_PARAM *param,
param->current_table);
#ifdef HAVE_SPATIAL
Field::geometry_type sav_geom_type;
LINT_INIT_STRUCT(sav_geom_type);
if (field_item->field->type() == MYSQL_TYPE_GEOMETRY)
const bool geometry= field_item->field->type() == MYSQL_TYPE_GEOMETRY;
if (geometry)
{
sav_geom_type= ((Field_geom*) field_item->field)->geom_type;
/* We have to be able to store all sorts of spatial features here */
@ -7665,7 +7691,7 @@ SEL_TREE *Item_bool_func::get_full_func_mm_tree(RANGE_OPT_PARAM *param,
}
#ifdef HAVE_SPATIAL
if (field_item->field->type() == MYSQL_TYPE_GEOMETRY)
if (geometry)
{
((Field_geom*) field_item->field)->geom_type= sav_geom_type;
}
@ -14833,6 +14859,32 @@ void QUICK_GROUP_MIN_MAX_SELECT::add_keys_and_lengths(String *key_names,
}
/* Check whether the number for equality ranges exceeds the set threshold */
bool eq_ranges_exceeds_limit(RANGE_SEQ_IF *seq, void *seq_init_param,
uint limit)
{
KEY_MULTI_RANGE range;
range_seq_t seq_it;
uint count = 0;
if (limit == 0)
{
/* 'Statistics instead of index dives' feature is turned off */
return false;
}
seq_it= seq->init(seq_init_param, 0, 0);
while (!seq->next(seq_it, &range))
{
if ((range.range_flag & EQ_RANGE) && !(range.range_flag & NULL_RANGE))
{
if (++count >= limit)
return true;
}
}
return false;
}
#ifndef DBUG_OFF
static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map,