Commit 0fada9c2 authored by Monty's avatar Monty Committed by Sergei Petrunia

Removed worst_seek argument for cost_for_index_read()

The argument was not used.
parent 43dc831e
...@@ -5847,7 +5847,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, ...@@ -5847,7 +5847,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
s->records= s->found_records= records; s->records= s->found_records= records;
s->records_init= s->records_out= rows2double(records); s->records_init= s->records_out= rows2double(records);
s->read_time=1.0; s->read_time=1.0;
s->worst_seeks=1.0;
table_records.add_table_name(s). table_records.add_table_name(s).
add("rows", s->found_records). add("rows", s->found_records).
add("cost", s->read_time). add("cost", s->read_time).
...@@ -5865,21 +5864,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, ...@@ -5865,21 +5864,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
if (s->table->is_splittable()) if (s->table->is_splittable())
s->add_keyuses_for_splitting(); s->add_keyuses_for_splitting();
/*
Set a max range of how many seeks we can expect when using keys
This is can't be to high as otherwise we are likely to use
table scan.
*/
#ifdef OLD_CODE_LIMITED_SEEKS
s->worst_seeks= MY_MIN((double) s->found_records / 10,
(double) s->read_time*3);
s->worst_seeks= s->found_records; // Disable worst seeks
if (s->worst_seeks < 2.0) // Fix for small tables
s->worst_seeks=2.0;
#else
s->worst_seeks= DBL_MAX;
#endif
/* /*
Add to stat->const_keys those indexes for which all group fields or Add to stat->const_keys those indexes for which all group fields or
all select distinct fields participate in one index. all select distinct fields participate in one index.
...@@ -7862,9 +7846,8 @@ static double matching_candidates_in_table(JOIN_TAB *s, ...@@ -7862,9 +7846,8 @@ static double matching_candidates_in_table(JOIN_TAB *s,
WHERE_COST cost is not added to any result. WHERE_COST cost is not added to any result.
*/ */
ALL_READ_COST cost_for_index_read(const THD *thd, const TABLE *table, static ALL_READ_COST cost_for_index_read(const THD *thd, const TABLE *table,
uint key, ha_rows records, uint key, ha_rows records)
ha_rows worst_seeks)
{ {
ALL_READ_COST cost; ALL_READ_COST cost;
handler *file= table->file; handler *file= table->file;
...@@ -8327,7 +8310,7 @@ best_access_path(JOIN *join, ...@@ -8327,7 +8310,7 @@ best_access_path(JOIN *join,
} }
else else
{ {
tmp= cost_for_index_read(thd, table, key, 1, 1); tmp= cost_for_index_read(thd, table, key, 1);
} }
/* /*
Calculate an adjusted cost based on how many records are read Calculate an adjusted cost based on how many records are read
...@@ -8435,13 +8418,11 @@ best_access_path(JOIN *join, ...@@ -8435,13 +8418,11 @@ best_access_path(JOIN *join,
} }
/* Calculate the cost of the index access */ /* Calculate the cost of the index access */
tmp= cost_for_index_read(thd, table, key, tmp= cost_for_index_read(thd, table, key,
(ha_rows) records, (ha_rows) records);
(ha_rows) s->worst_seeks);
} }
} }
else else
{ {
ha_rows tmp_records;
type = ref_or_null_part ? JT_REF_OR_NULL : JT_REF; type = ref_or_null_part ? JT_REF_OR_NULL : JT_REF;
if (unlikely(trace_access_idx.trace_started())) if (unlikely(trace_access_idx.trace_started()))
trace_access_idx. trace_access_idx.
...@@ -8620,13 +8601,8 @@ best_access_path(JOIN *join, ...@@ -8620,13 +8601,8 @@ best_access_path(JOIN *join,
} }
} }
/* Limit the number of matched rows */
set_if_smaller(records, (double) s->records); set_if_smaller(records, (double) s->records);
tmp_records= records; tmp= cost_for_index_read(thd, table, key, (ha_rows)records);
set_if_smaller(tmp_records, thd->variables.max_seeks_for_key);
tmp= cost_for_index_read(thd, table, key,
tmp_records,
(ha_rows) s->worst_seeks);
tmp.copy_cost+= extra_cost; tmp.copy_cost+= extra_cost;
} }
else else
...@@ -9055,8 +9031,7 @@ best_access_path(JOIN *join, ...@@ -9055,8 +9031,7 @@ best_access_path(JOIN *join,
{ {
ALL_READ_COST cost= cost_for_index_read(thd, table, ALL_READ_COST cost= cost_for_index_read(thd, table,
forced_index, forced_index,
s->records, s->records);
s->worst_seeks);
cur_cost= file->cost(cost); cur_cost= file->cost(cost);
/* Calculate cost of checking the attached WHERE */ /* Calculate cost of checking the attached WHERE */
cur_cost= COST_ADD(cur_cost, cur_cost= COST_ADD(cur_cost,
...@@ -10184,7 +10159,7 @@ double JOIN::get_examined_rows() ...@@ -10184,7 +10159,7 @@ double JOIN::get_examined_rows()
COST_MULT((double) (tab->get_examined_rows()), prev_fanout)); COST_MULT((double) (tab->get_examined_rows()), prev_fanout));
prev_tab= tab; prev_tab= tab;
} }
examined_rows= double_to_rows(records); examined_rows= records;
return examined_rows; return examined_rows;
} }
...@@ -30341,10 +30316,7 @@ static bool get_range_limit_read_cost(const POSITION *pos, ...@@ -30341,10 +30316,7 @@ static bool get_range_limit_read_cost(const POSITION *pos,
<=> N > refkey_rows_estimate. <=> N > refkey_rows_estimate.
*/ */
ALL_READ_COST cost= cost_for_index_read(table->in_use, table, keynr, ALL_READ_COST cost= cost_for_index_read(table->in_use, table, keynr,
rows_to_scan, rows_to_scan);
pos ?
(ha_rows) pos->table->worst_seeks :
HA_ROWS_MAX);
*read_cost= (table->file->cost(&cost) + *read_cost= (table->file->cost(&cost) +
rows_to_scan * WHERE_COST_THD(table->in_use)); rows_to_scan * WHERE_COST_THD(table->in_use));
*read_rows= rows2double(rows_to_scan); *read_rows= rows2double(rows_to_scan);
...@@ -322,7 +322,6 @@ typedef struct st_join_table { ...@@ -322,7 +322,6 @@ typedef struct st_join_table {
*/ */
READ_RECORD::Setup_func save_read_first_record;/* to save read_first_record */ READ_RECORD::Setup_func save_read_first_record;/* to save read_first_record */
READ_RECORD::Read_func save_read_record;/* to save read_record.read_record */ READ_RECORD::Read_func save_read_record;/* to save read_record.read_record */
double worst_seeks;
key_map const_keys; /**< Keys with constant part */ key_map const_keys; /**< Keys with constant part */
key_map checked_keys; /**< Keys checked in find_best */ key_map checked_keys; /**< Keys checked in find_best */
key_map needed_reg; key_map needed_reg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment