summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2018-09-14 08:47:22 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2018-09-14 08:47:22 +0200
commit28f08d3753eb10a1393a63e6c581d43aad9f93b9 (patch)
tree86c9df8c3fb6d4ebd99d431697c84f06ef242989 /sql/opt_range.cc
parent38665893087e20c3ad65d5b0e227a75185a4865e (diff)
parentf1bcfbb4373e40dda2c18c137f76fc6ff32e1a45 (diff)
downloadmariadb-git-28f08d3753eb10a1393a63e6c581d43aad9f93b9.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 2c015c1a5da..b67661e1c8a 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2727,13 +2727,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;
@@ -2745,6 +2751,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;
@@ -2902,7 +2911,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)
@@ -3019,7 +3039,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;