summaryrefslogtreecommitdiff
path: root/sql/opt_split.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/opt_split.cc')
-rw-r--r--sql/opt_split.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index c01f8f3cccf..48eeda0d40a 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -668,12 +668,13 @@ static
double spl_postjoin_oper_cost(THD *thd, double join_record_count, uint rec_len)
{
double cost;
- cost= get_tmp_table_write_cost(thd, join_record_count,rec_len) *
- join_record_count; // cost to fill tmp table
- cost+= get_tmp_table_lookup_cost(thd, join_record_count,rec_len) *
- join_record_count; // cost to perform post join operation used here
- cost+= get_tmp_table_lookup_cost(thd, join_record_count, rec_len) +
- (join_record_count == 0 ? 0 :
+ TMPTABLE_COSTS tmp_cost= get_tmp_table_costs(thd, join_record_count,
+ rec_len, 0);
+ // cost to fill tmp table
+ cost= tmp_cost.create + tmp_cost.write * join_record_count;
+ // cost to perform post join operation used here
+ cost+= tmp_cost.lookup * join_record_count;
+ cost+= (join_record_count == 0 ? 0 :
join_record_count * log2 (join_record_count)) *
SORT_INDEX_CMP_COST; // cost to perform sorting
return cost;
@@ -1038,12 +1039,11 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
}
/* Set the cost of the preferred materialization for this partial join */
- records= (ha_rows)spl_opt_info->unsplit_card;
spl_plan= spl_opt_info->last_plan;
if (spl_plan)
{
startup_cost= record_count * spl_plan->cost;
- records= (ha_rows) (records * spl_plan->split_sel);
+ records= (ha_rows) (spl_opt_info->unsplit_card * spl_plan->split_sel);
if (unlikely(thd->trace_started()))
{
@@ -1055,7 +1055,11 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
}
}
else
- startup_cost= spl_opt_info->unsplit_cost;
+ {
+ /* Restore original values */
+ startup_cost= spl_opt_info->unsplit_cost;
+ records= (ha_rows) spl_opt_info->unsplit_card;
+ }
return spl_plan;
}