diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2018-08-28 21:59:11 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2018-08-29 02:17:37 +0530 |
commit | a9c09c95bdd33ee0cbd3fb3254753ab2fc56f2a5 (patch) | |
tree | 1ec0fdad572a4759896e3cebd047f503bff4ba3d /sql/opt_range.cc | |
parent | 5fb251642e19c59306c32333dbba669ce160457c (diff) | |
download | mariadb-git-a9c09c95bdd33ee0cbd3fb3254753ab2fc56f2a5.tar.gz |
MDEV-15306: Wrong/Unexpected result with the value optimizer_use_condition_selectivity set to 4
Currently for selectivity calculation we perform range analysis for a column even when we don't have any statistics(EITS).
This makes less sense but is used to catch contradiction for WHERE condition.
So the solution is to not perform range analysis for selectivity calculation for columns that do not have statistics.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 734adfbc9d1..ceabac2b744 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3326,13 +3326,18 @@ 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()) 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; @@ -3628,7 +3633,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; |