![]() |
MySQL
8.0.23
Source Code Documentation
|
A position of table within a join order. More...
#include <sql_select.h>
Public Member Functions | |
void | no_semijoin () |
Even if the query has no semijoin, two sj-related members are read and must thus have been set, by this function. More... | |
void | set_prefix_cost (double cost, double rowcount) |
Set complete estimated cost and produced rowcount for the prefix of tables up to and including this table, in the join plan. More... | |
void | set_prefix_join_cost (uint idx, const Cost_model_server *cm) |
Set complete estimated cost and produced rowcount for the prefix of tables up to and including this table, calculated from the cost of the previous stage, the fanout of the current stage and the cost to process a row at the current stage. More... | |
Public Attributes | |
double | rows_fetched |
The number of rows that will be fetched by the chosen access method per each row combination of previous tables. More... | |
double | read_cost |
Cost of accessing the table in course of the entire complete join execution, i.e. More... | |
float | filter_effect |
The fraction of the 'rows_fetched' rows that will pass the table conditions that were NOT used by the access method. More... | |
double | prefix_rowcount |
prefix_rowcount and prefix_cost form a stack of partial join order costs and output sizes More... | |
double | prefix_cost |
JOIN_TAB * | table |
Key_use * | key |
NULL - 'index' or 'range' or 'index_merge' or 'ALL' access is used. More... | |
table_map | ref_depend_map |
If ref-based access is used: bitmap of tables this table depends on More... | |
bool | use_join_buffer |
uint | sj_strategy |
Current optimization state: Semi-join strategy to be used for this and preceding join tables. More... | |
uint | n_sj_tables |
Valid only after fix_semijoin_strategies_for_picked_join_order() call: if sj_strategy!=SJ_OPT_NONE, this is the number of subsequent tables that are covered by the specified semi-join strategy. More... | |
table_map | dups_producing_tables |
Bitmap of semi-join inner tables that are in the join prefix and for which there's no provision yet for how to eliminate semi-join duplicates which they produce. More... | |
uint | first_loosescan_table |
table_map | loosescan_need_tables |
uint | loosescan_key |
uint | loosescan_parts |
uint | first_firstmatch_table |
nested_join_map | cur_embedding_map |
Value of Optimize_table_order::cur_embedding_map after this table has been added to the plan. More... | |
table_map | first_firstmatch_rtbl |
table_map | firstmatch_need_tables |
uint | first_dupsweedout_table |
table_map | dupsweedout_tables |
uint | sjm_scan_last_inner |
table_map | sjm_scan_need_tables |
A position of table within a join order.
This structure is primarily used as a part of join->positions
and join->best_positions
arrays.
One POSITION element contains information about:
This class has to stay a POD, because it is memcpy'd in many places.
|
inline |
Even if the query has no semijoin, two sj-related members are read and must thus have been set, by this function.
|
inline |
Set complete estimated cost and produced rowcount for the prefix of tables up to and including this table, in the join plan.
cost | Estimated cost |
rowcount | Estimated row count |
|
inline |
Set complete estimated cost and produced rowcount for the prefix of tables up to and including this table, calculated from the cost of the previous stage, the fanout of the current stage and the cost to process a row at the current stage.
idx | Index of position object within array, if zero there is no "previous" stage that can be added. |
cm | Cost model that provides the actual calculation |
nested_join_map POSITION::cur_embedding_map |
Value of Optimize_table_order::cur_embedding_map after this table has been added to the plan.
Used to constrain FirstMatch table orders.
table_map POSITION::dups_producing_tables |
Bitmap of semi-join inner tables that are in the join prefix and for which there's no provision yet for how to eliminate semi-join duplicates which they produce.
table_map POSITION::dupsweedout_tables |
float POSITION::filter_effect |
The fraction of the 'rows_fetched' rows that will pass the table conditions that were NOT used by the access method.
If, e.g.,
"SELECT ... WHERE t1.colx = 4 and t1.coly @> 5"
is resolved by ref access on t1.colx, filter_effect will be the fraction of rows that will pass the "t1.coly @> 5" predicate. The valid range is 0..1, where 0.0 means that no rows will pass the table conditions and 1.0 means that all rows will pass.
It is used to calculate how many row combinations will be joined with the next table,
"SELECT ... WHERE t1.col1=t2.colx and t2.coly OP @<something@>"
where t1 is a prefix table and the optimizer currently calculates the cost of adding t2 to the join. Assume that the chosen access method on t2 is a 'ref' access on 'colx' that is estimated to produce 2 rows per row from t1 (i.e., rows_fetched = 2). It will in this case be perfectly fine to calculate a filtering effect <0.5 (resulting in "rows_fetched * filter_effect @< 1.0") from the predicate "t2.coly OP @<something@>". If so, the number of row combinations from (t1,t2) is lower than the prefix_rowcount of t1.
The above is just an example of how the fanout of a table can become less than one. It can happen for any access method.
uint POSITION::first_dupsweedout_table |
table_map POSITION::first_firstmatch_rtbl |
uint POSITION::first_firstmatch_table |
uint POSITION::first_loosescan_table |
table_map POSITION::firstmatch_need_tables |
Key_use* POSITION::key |
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}
uint POSITION::loosescan_key |
table_map POSITION::loosescan_need_tables |
uint POSITION::loosescan_parts |
uint POSITION::n_sj_tables |
Valid only after fix_semijoin_strategies_for_picked_join_order() call: if sj_strategy!=SJ_OPT_NONE, this is the number of subsequent tables that are covered by the specified semi-join strategy.
double POSITION::prefix_cost |
double POSITION::prefix_rowcount |
prefix_rowcount and prefix_cost form a stack of partial join order costs and output sizes
prefix_rowcount: The number of row combinations that will be joined to the next table in the join sequence.
For a joined table it is calculated as prefix_rowcount = last_table.prefix_rowcount * rows_fetched * filter_effect
For a semijoined table it may be less than this formula due to duplicate elimination.
double POSITION::read_cost |
Cost of accessing the table in course of the entire complete join execution, i.e.
cost of one access method use (e.g. 'range' or 'ref' scan ) multiplied by estimated number of rows from tables earlier in the join sequence.
read_cost does NOT include cost of processing rows within the executor (row_evaluate_cost).
table_map POSITION::ref_depend_map |
If ref-based access is used: bitmap of tables this table depends on
double POSITION::rows_fetched |
The number of rows that will be fetched by the chosen access method per each row combination of previous tables.
That is:
rows_fetched = selectivity(access_condition) * cardinality(table)
where 'access_condition' is whatever condition was chosen for index access, depending on the access method ('ref', 'range', etc.)
uint POSITION::sj_strategy |
Current optimization state: Semi-join strategy to be used for this and preceding join tables.
Join optimizer sets this for the last join_tab in the duplicate-generating range. That is, in order to interpret this field, one needs to traverse join->[best_]positions array from right to left. When you see a join table with sj_strategy!= SJ_OPT_NONE, some other field (depending on the strategy) tells how many preceding positions this applies to. The values of covered_preceding_positions->sj_strategy must be ignored.
uint POSITION::sjm_scan_last_inner |
table_map POSITION::sjm_scan_need_tables |
JOIN_TAB* POSITION::table |
bool POSITION::use_join_buffer |