mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge 10.5 into 10.6
This commit is contained in:
@@ -3531,9 +3531,35 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
|
||||
*/
|
||||
selectivity_mult= ((double)(i+1)) / i;
|
||||
}
|
||||
table->cond_selectivity*= selectivity_mult;
|
||||
selectivity_for_index.add("selectivity_multiplier",
|
||||
selectivity_mult);
|
||||
|
||||
/*
|
||||
Ok, now we assume that selectivity that range condition on
|
||||
this index adds over selectivities on indexes that we've already
|
||||
examined is
|
||||
|
||||
$SEL= (quick_cond_selectivity * selectivity_mult)
|
||||
|
||||
The heuristic that we used to obtain selectivity_mult may not be
|
||||
correct (actually is known to be incorrect in simple cases), so
|
||||
we make sure here that $SEL <= 1.0.
|
||||
|
||||
We adjust selectivity_mult (table->cond_selectivity was already
|
||||
multiplied by quick_cond_selectivity above, so we will only
|
||||
multiply it with selectivity_mult).
|
||||
*/
|
||||
if ((thd->variables.optimizer_adjust_secondary_key_costs &
|
||||
OPTIMIZER_ADJ_FIX_CARD_MULT) &&
|
||||
selectivity_mult > 1.0 / quick_cond_selectivity)
|
||||
{
|
||||
selectivity_for_index.add("note", "multiplier too high, clipping");
|
||||
selectivity_mult= 1.0/quick_cond_selectivity;
|
||||
selectivity_for_index.add("clipped_multiplier", selectivity_mult);
|
||||
DBUG_ASSERT(quick_cond_selectivity * selectivity_mult <= 1.0);
|
||||
}
|
||||
|
||||
table->cond_selectivity*= selectivity_mult;
|
||||
}
|
||||
/*
|
||||
We need to set selectivity for fields supported by indexes.
|
||||
|
Reference in New Issue
Block a user