mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Reduced size of POSITION
Replaced Cost_estimate prefix_cost with a double as prefix_cost was only used to store and retrive total prefix cost. This also speeds up things (a bit) as don't have to call Cost_estimate::total_cost() for every access to the prefix_cost. Sizeof POSITION decreased from 304 to 256.
This commit is contained in:
@@ -2895,7 +2895,7 @@ void optimize_semi_joins(JOIN *join, table_map remaining_tables, uint idx,
|
|||||||
pos[-1].inner_tables_handled_with_other_sjs;
|
pos[-1].inner_tables_handled_with_other_sjs;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos->prefix_cost.convert_from_cost(*current_read_time);
|
pos->prefix_cost= *current_read_time;
|
||||||
pos->prefix_record_count= *current_record_count;
|
pos->prefix_record_count= *current_record_count;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -3017,7 +3017,7 @@ void optimize_semi_joins(JOIN *join, table_map remaining_tables, uint idx,
|
|||||||
|
|
||||||
update_sj_state(join, new_join_tab, idx, remaining_tables);
|
update_sj_state(join, new_join_tab, idx, remaining_tables);
|
||||||
|
|
||||||
pos->prefix_cost.convert_from_cost(*current_read_time);
|
pos->prefix_cost= *current_read_time;
|
||||||
pos->prefix_record_count= *current_record_count;
|
pos->prefix_record_count= *current_record_count;
|
||||||
pos->dups_producing_tables= dups_producing_tables;
|
pos->dups_producing_tables= dups_producing_tables;
|
||||||
}
|
}
|
||||||
@@ -3107,15 +3107,15 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* This is SJ-Materialization with lookups */
|
/* This is SJ-Materialization with lookups */
|
||||||
Cost_estimate prefix_cost;
|
double prefix_cost;
|
||||||
signed int first_tab= (int)idx - mat_info->tables;
|
signed int first_tab= (int)idx - mat_info->tables;
|
||||||
double prefix_rec_count;
|
double prefix_rec_count, mat_read_time;
|
||||||
Json_writer_object trace(join->thd);
|
Json_writer_object trace(join->thd);
|
||||||
trace.add("strategy", "SJ-Materialization");
|
trace.add("strategy", "SJ-Materialization");
|
||||||
|
|
||||||
if (first_tab < (int)join->const_tables)
|
if (first_tab < (int)join->const_tables)
|
||||||
{
|
{
|
||||||
prefix_cost.reset();
|
prefix_cost= 0;
|
||||||
prefix_rec_count= 1.0;
|
prefix_rec_count= 1.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3124,9 +3124,8 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
|
|||||||
prefix_rec_count= join->positions[first_tab].prefix_record_count;
|
prefix_rec_count= join->positions[first_tab].prefix_record_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
double mat_read_time= prefix_cost.total_cost();
|
|
||||||
mat_read_time=
|
mat_read_time=
|
||||||
COST_ADD(mat_read_time,
|
COST_ADD(prefix_cost,
|
||||||
COST_ADD(mat_info->materialization_cost.total_cost(),
|
COST_ADD(mat_info->materialization_cost.total_cost(),
|
||||||
COST_MULT(prefix_rec_count,
|
COST_MULT(prefix_rec_count,
|
||||||
mat_info->lookup_cost.total_cost())));
|
mat_info->lookup_cost.total_cost())));
|
||||||
@@ -3171,7 +3170,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prefix_cost= join->positions[first_tab - 1].prefix_cost.total_cost();
|
prefix_cost= join->positions[first_tab - 1].prefix_cost;
|
||||||
prefix_rec_count= join->positions[first_tab - 1].prefix_record_count;
|
prefix_rec_count= join->positions[first_tab - 1].prefix_record_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3535,7 +3534,7 @@ bool Duplicate_weedout_picker::check_qep(JOIN *join,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dups_cost= join->positions[first_tab - 1].prefix_cost.total_cost();
|
dups_cost= join->positions[first_tab - 1].prefix_cost;
|
||||||
prefix_rec_count= join->positions[first_tab - 1].prefix_record_count;
|
prefix_rec_count= join->positions[first_tab - 1].prefix_record_count;
|
||||||
temptable_rec_size= 8; /* This is not true but we'll make it so */
|
temptable_rec_size= 8; /* This is not true but we'll make it so */
|
||||||
}
|
}
|
||||||
|
@@ -17945,7 +17945,7 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
|
|||||||
|
|
||||||
if (first_tab > join->const_tables)
|
if (first_tab > join->const_tables)
|
||||||
{
|
{
|
||||||
cost= join->positions[first_tab - 1].prefix_cost.total_cost();
|
cost= join->positions[first_tab - 1].prefix_cost;
|
||||||
rec_count= join->positions[first_tab - 1].prefix_record_count;
|
rec_count= join->positions[first_tab - 1].prefix_record_count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -952,6 +952,9 @@ public:
|
|||||||
|
|
||||||
double prefix_record_count;
|
double prefix_record_count;
|
||||||
|
|
||||||
|
/* Cost for the join prefix */
|
||||||
|
double prefix_cost;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NULL - 'index' or 'range' or 'index_merge' or 'ALL' access is used.
|
NULL - 'index' or 'range' or 'index_merge' or 'ALL' access is used.
|
||||||
Other - [eq_]ref[_or_null] access is used. Pointer to {t.keypart1 = expr}
|
Other - [eq_]ref[_or_null] access is used. Pointer to {t.keypart1 = expr}
|
||||||
@@ -983,9 +986,6 @@ public:
|
|||||||
LooseScan_picker loosescan_picker;
|
LooseScan_picker loosescan_picker;
|
||||||
Sj_materialization_picker sjmat_picker;
|
Sj_materialization_picker sjmat_picker;
|
||||||
|
|
||||||
/* Cumulative cost and record count for the join prefix */
|
|
||||||
Cost_estimate prefix_cost;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Current optimization state: Semi-join strategy to be used for this
|
Current optimization state: Semi-join strategy to be used for this
|
||||||
and preceding join tables.
|
and preceding join tables.
|
||||||
|
Reference in New Issue
Block a user