diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-18 16:24:48 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-18 16:24:48 +0300 |
commit | bb4214272a8a1b0e60a785e1bf1391d5753b73b6 (patch) | |
tree | 27d4dd0eff246902f9f25c102cf5f5aa9d10a05d /sql/sql_select.cc | |
parent | 24859049c6b2d0b6f83f1f93ced15414d7266fb6 (diff) | |
parent | 8a79fa0e4d0385818da056f7a4a39fde95d62fe3 (diff) | |
download | mariadb-git-bb4214272a8a1b0e60a785e1bf1391d5753b73b6.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 24edac2dae1..f743e1f4c97 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7992,7 +7992,19 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, } keyparts++; } + /* + Here we discount selectivity of the constant range CR. To calculate + this selectivity we use elements from the quick_rows[] array. + If we have indexes i1,...,ik with the same prefix compatible + with CR any of the estimate quick_rows[i1], ... quick_rows[ik] could + be used for this calculation but here we don't know which one was + actually used. So sel could be greater than 1 and we have to cap it. + However if sel becomes greater than 2 then with high probability + something went wrong. + */ sel /= (double)table->quick_rows[key] / (double) table->stat_records(); + DBUG_ASSERT(0 < sel && sel <= 2.0); + set_if_smaller(sel, 1.0); used_range_selectivity= true; } } @@ -8040,6 +8052,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, if (table->field[fldno]->cond_selectivity > 0) { sel /= table->field[fldno]->cond_selectivity; + DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); } /* @@ -8097,6 +8110,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, if (field->cond_selectivity > 0) { sel/= field->cond_selectivity; + DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); } break; @@ -8108,6 +8122,7 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s, sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables, keyparts, ref_keyuse_steps); + DBUG_ASSERT(0.0 < sel && sel <= 1.0); return sel; } |