mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
and use_stat_tables= PREFERABLY Currently the code that calculates selectivity for a table does not take into account the case when we can have GROUP BY optimization (looses index scan).
This commit is contained in:
@ -3501,7 +3501,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)
|
||||
|
Reference in New Issue
Block a user