1
0
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:
Varun Gupta
2018-08-23 16:01:58 +05:30
parent bcc677bb72
commit 7d8d37c31d
3 changed files with 57 additions and 1 deletions

View File

@ -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)