mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge.
This commit is contained in:
@ -5556,9 +5556,23 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key)
|
||||
/* Estimate of the number matching candidates in the joined table */
|
||||
|
||||
inline
|
||||
ha_rows matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint)
|
||||
double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint,
|
||||
uint use_cond_selectivity)
|
||||
{
|
||||
ha_rows records= s->found_records;
|
||||
ha_rows records;
|
||||
double dbl_records;
|
||||
|
||||
if (use_cond_selectivity > 1)
|
||||
{
|
||||
TABLE *table= s->table;
|
||||
double sel= table->cond_selectivity;
|
||||
double table_records= table->stat_records();
|
||||
dbl_records= table_records * sel;
|
||||
return dbl_records;
|
||||
}
|
||||
|
||||
records = s->found_records;
|
||||
|
||||
/*
|
||||
If there is a filtering condition on the table (i.e. ref analyzer found
|
||||
at least one "table.keyXpartY= exprZ", where exprZ refers only to tables
|
||||
@ -5578,7 +5592,8 @@ ha_rows matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint)
|
||||
if (s->table->quick_condition_rows != s->found_records)
|
||||
records= s->table->quick_condition_rows;
|
||||
|
||||
return records;
|
||||
dbl_records= records;
|
||||
return dbl_records;
|
||||
}
|
||||
|
||||
|
||||
@ -5621,6 +5636,7 @@ best_access_path(JOIN *join,
|
||||
POSITION *loose_scan_pos)
|
||||
{
|
||||
THD *thd= join->thd;
|
||||
uint use_cond_selectivity= thd->variables.optimizer_use_condition_selectivity;
|
||||
KEYUSE *best_key= 0;
|
||||
uint best_max_key_part= 0;
|
||||
my_bool found_constraint= 0;
|
||||
@ -6052,7 +6068,8 @@ best_access_path(JOIN *join,
|
||||
{
|
||||
double join_sel= 0.1;
|
||||
/* Estimate the cost of the hash join access to the table */
|
||||
ha_rows rnd_records= matching_candidates_in_table(s, found_constraint);
|
||||
double rnd_records= matching_candidates_in_table(s, found_constraint,
|
||||
use_cond_selectivity);
|
||||
|
||||
tmp= s->quick ? s->quick->read_time : s->scan_time();
|
||||
tmp+= (s->records - rnd_records)/(double) TIME_FOR_COMPARE;
|
||||
@ -6064,7 +6081,7 @@ best_access_path(JOIN *join,
|
||||
best_time= tmp +
|
||||
(record_count*join_sel) / TIME_FOR_COMPARE * rnd_records;
|
||||
best= tmp;
|
||||
records= rows2double(rnd_records);
|
||||
records= rnd_records;
|
||||
best_key= hj_start_key;
|
||||
best_ref_depends_map= 0;
|
||||
best_uses_jbuf= TRUE;
|
||||
@ -6111,7 +6128,8 @@ best_access_path(JOIN *join,
|
||||
!(s->table->force_index && best_key && !s->quick) && // (4)
|
||||
!(best_key && s->table->pos_in_table_list->jtbm_subselect)) // (5)
|
||||
{ // Check full join
|
||||
ha_rows rnd_records= matching_candidates_in_table(s, found_constraint);
|
||||
double rnd_records= matching_candidates_in_table(s, found_constraint,
|
||||
use_cond_selectivity);
|
||||
|
||||
/*
|
||||
Range optimizer never proposes a RANGE if it isn't better
|
||||
@ -6184,7 +6202,7 @@ best_access_path(JOIN *join,
|
||||
will ensure that this will be used
|
||||
*/
|
||||
best= tmp;
|
||||
records= rows2double(rnd_records);
|
||||
records= rnd_records;
|
||||
best_key= 0;
|
||||
/* range/index_merge/ALL/index access method are "independent", so: */
|
||||
best_ref_depends_map= 0;
|
||||
@ -7289,6 +7307,10 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
|
||||
keyuse++;
|
||||
} while (keyuse->table == table && keyuse->key == key);
|
||||
}
|
||||
else
|
||||
{
|
||||
sel= 1;
|
||||
}
|
||||
|
||||
/*
|
||||
If the field f from the table is equal to a field from one the
|
||||
@ -8313,7 +8335,7 @@ get_best_combination(JOIN *join)
|
||||
Save records_read in JOIN_TAB so that select_describe()/etc don't have
|
||||
to access join->best_positions[].
|
||||
*/
|
||||
j->records_read= (ha_rows)join->best_positions[tablenr].records_read;
|
||||
j->records_read= join->best_positions[tablenr].records_read;
|
||||
j->cond_selectivity= join->best_positions[tablenr].cond_selectivity;
|
||||
join->map2table[j->table->tablenr]= j;
|
||||
|
||||
|
Reference in New Issue
Block a user