1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge 10.1 into 10.2

This commit is contained in:
Marko Mäkelä
2019-09-18 16:24:48 +03:00
42 changed files with 513 additions and 515 deletions

View File

@ -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;
}