My Project
Classes | Public Types | Public Member Functions | Public Attributes
JOIN Class Reference
Inheritance diagram for JOIN:
Sql_alloc

List of all members.

Classes

class  ORDER_with_src
class  Prepare_error_tracker
 RAII class to ease the call of LEX::mark_broken() if error.

Public Types

enum  { ordered_index_void, ordered_index_group_by, ordered_index_order_by }

Public Member Functions

 JOIN (THD *thd_arg, List< Item > &fields_arg, ulonglong select_options_arg, select_result *result_arg)
void init (THD *thd_arg, List< Item > &fields_arg, ulonglong select_options_arg, select_result *result_arg)
bool plan_is_const () const
 True if plan is const, ie it will return zero or one rows.
bool plan_is_single_table ()
int prepare (TABLE_LIST *tables, uint wind_num, Item *conds, uint og_num, ORDER *order, ORDER *group, Item *having, SELECT_LEX *select, SELECT_LEX_UNIT *unit)
int optimize ()
void reset ()
void exec ()
bool prepare_result (List< Item > **columns_list)
bool explain ()
bool destroy ()
void restore_tmp ()
bool alloc_func_list ()
bool flatten_subqueries ()
bool make_sum_func_list (List< Item > &all_fields, List< Item > &send_fields, bool before_group_by, bool recompute=FALSE)
Ref_ptr_array ref_ptr_array_slice (size_t slice_num)
 Initialzes a slice, see comments for ref_ptrs above.
void copy_ref_ptr_array (Ref_ptr_array dst_arr, Ref_ptr_array src_arr)
void set_items_ref_array (Ref_ptr_array src_arr)
 Overwrites 'ref_ptrs' and remembers the the source as 'current'.
void init_items_ref_array ()
 Initializes 'items0' and remembers that it is 'current'.
bool rollup_init ()
bool rollup_process_const_fields ()
bool rollup_make_fields (List< Item > &all_fields, List< Item > &fields, Item_sum ***func)
int rollup_send_data (uint idx)
int rollup_write_data (uint idx, TABLE *table)
void remove_subq_pushed_predicates (Item **where)
void join_free ()
void cleanup (bool full)
void clear ()
bool save_join_tab ()
void restore_join_tab ()
bool init_save_join_tab ()
bool send_row_on_empty_set () const
bool change_result (select_result *result)
bool is_top_level_join () const
bool cache_const_exprs ()
bool generate_derived_keys ()
 Add keys to derived tables'/views' result tables in a list.
void drop_unused_derived_keys ()
 Drop unused keys for each materialized derived table/view.
bool get_best_combination ()
bool update_equalities_for_sjm ()
bool add_sorting_to_table (JOIN_TAB *tab, ORDER_with_src *order)
 Add Filesort object to the given table to sort if with filesort.
bool decide_subquery_strategy ()
void refine_best_rowcount ()
void set_semijoin_embedding ()

Public Attributes

JOIN_TABjoin_tab
JOIN_TAB ** best_ref
JOIN_TAB ** map2table
 mapping between table indexes and JOIN_TABs
TABLE ** table
TABLEsort_by_table
uint tables
 Total number of tables in query block.
uint primary_tables
 Number of primary input tables in query block.
uint const_tables
 Number of primary tables deemed constant.
uint tmp_tables
 Number of temporary tables used by query.
uint send_group_parts
bool sort_and_group
bool first_record
bool full_join
bool no_field_update
bool group
 If query contains GROUP BY clause.
bool do_send_rows
table_map all_table_map
 Set of tables contained in query.
table_map const_table_map
 Set of tables found to be const.
table_map found_const_table_map
table_map outer_join
 Bitmap of all inner tables from outer joins.
ha_rows send_records
ha_rows found_records
ha_rows examined_rows
ha_rows row_limit
ha_rows m_select_limit
ha_rows fetch_limit
ha_rows min_ft_matches
POSITIONbest_positions
POSITIONpositions
Next_select_func first_select
double best_read
ha_rows best_rowcount
List< Item > * fields
List< Cached_itemgroup_fields
List< Cached_itemgroup_fields_cache
THD * thd
Item_sum ** sum_funcs
Item_sum *** sum_funcs_end
Item_sum ** sum_funcs2
Item_sum *** sum_funcs_end2
ulonglong select_options
select_result * result
TMP_TABLE_PARAM tmp_table_param
MYSQL_LOCKlock
SELECT_LEX_UNIT * unit
 unit structure (with global parameters) for this select
SELECT_LEX * select_lex
 select that processed
bool no_const_tables
ROLLUP rollup
 Used with rollup.
bool select_distinct
 Set if SELECT DISTINCT.
bool group_optimized_away
bool simple_order
bool simple_group
enum JOIN:: { ... }  ordered_index_usage
bool no_order
bool skip_sort_order
bool need_tmp
int hidden_group_field_count
Key_use_array keyuse
List< Itemall_fields
 to store all expressions used in query Above list changed to use temporary table
List< Itemtmp_all_fields1
List< Itemtmp_all_fields2
List< Itemtmp_all_fields3
List< Itemtmp_fields_list1
 Part, shared with list above, emulate following list.
List< Itemtmp_fields_list2
List< Itemtmp_fields_list3
List< Item > & fields_list
 hold field list passed to mysql_select
List< Itemprocedure_fields_list
int error
 set in optimize(), exec(), prepare_result()
ORDER_with_src order
ORDER_with_src group_list
Explain_format_flags explain_flags
Itemconds
 The where clause item tree.
Itemhaving
 The having clause item tree.
Itemhaving_for_explain
 Saved optimized HAVING for EXPLAIN.
TABLE_LISTtables_list
 hold 'tables' parameter of mysql_select
List< TABLE_LIST > * join_list
 list of joined tables in reverse order
COND_EQUALcond_equal
JOIN_TABreturn_tab
Ref_ptr_array ref_ptrs
Ref_ptr_array items0
Ref_ptr_array items1
Ref_ptr_array items2
Ref_ptr_array items3
Ref_ptr_array current_ref_ptrs
const char * zero_result_cause
 not 0 if exec must return zero result
bool union_part
 this subselect is part of union
bool optimized
 flag to avoid double optimization in EXPLAIN
bool child_subquery_can_materialize
bool allow_outer_refs
Mem_root_array
< Item_exists_subselect
*, true > 
sj_subselects
List< TABLEsj_tmp_tables
List< Semijoin_mat_execsjm_exec_list
bool set_group_rpa
bool group_sent

Member Function Documentation

void JOIN::copy_ref_ptr_array ( Ref_ptr_array  dst_arr,
Ref_ptr_array  src_arr 
) [inline]

Overwrites one slice with the contents of another slice. In the normal case, dst and src have the same size(). However: the rollup slices may have smaller size than slice_sz.

bool JOIN::plan_is_single_table ( ) [inline]

True if plan contains one non-const primary table (ie not including tables taking part in semi-join materialization).

bool JOIN::send_row_on_empty_set ( ) const [inline]

Return whether the caller should send a row even if the join produced no rows if:

  • there is an aggregate function (sum_func_count!=0), and
  • the query is not grouped, and
  • a possible HAVING clause evaluates to TRUE.
Note:
: if there is a having clause, it must be evaluated before returning the row.

Member Data Documentation

True if plan search is allowed to use references to expressions outer to this JOIN (for example may set up a 'ref' access looking up an outer expression in the index, etc).

The cost of best complete join plan found so far during optimization, after optimization phase - cost of picked join order (not taking into account the changes made by test_if_skip_sort_order()).

The estimated row count of the plan with best read time (see above).

True if, at this stage of processing, subquery materialization is allowed for children subqueries of this JOIN (those in the SELECT list, in WHERE, etc). If false, and we have to evaluate a subquery at this stage, then we must choose EXISTS.

The where clause item tree.

JOIN::having is initially equal to select_lex->having, but may later be changed by optimizations performed by JOIN. The relationship between the JOIN::having condition and the associated variable select_lex->having_value is so that having_value can be:

  • COND_UNDEF if a having clause was not specified in the query or if it has not been optimized yet
  • COND_TRUE if the having clause is always true, in which case JOIN::having is set to NULL.
  • COND_FALSE if the having clause is impossible, in which case JOIN::having is set to NULL
  • COND_OK otherwise, meaning that the having clause needs to be further evaluated All of the above also applies to the conds/select_lex->cond_value pair.

Buffer to gather GROUP BY, ORDER BY and DISTINCT QEP details for EXPLAIN

Used to fetch no more than given amount of rows per one fetch operation of server side cursor. The value is checked in end_send and end_send_group in fashion, similar to offset_limit_cnt:

  • fetch_limit= HA_POS_ERROR if there is no cursor.
  • when we open a cursor, we set fetch_limit to 0,
  • on each fetch iteration we add num_rows to fetch to fetch_limit

Const tables which are either:

  • not empty
  • empty but inner to a LEFT JOIN, thus "considered" not empty for the rest of execution (a NULL-complemented row will be used).

If we have the GROUP BY statement in the query, but the group_list was emptied by optimizer, this flag is TRUE. It happens when fields in the GROUP BY are from constant table

Exec time only: TRUE <=> current group has been sent

Minimum number of matches that is needed to use JT_FT access.

See also:
optimize_fts_limit_query

TRUE <=> optimizer must not mark any table as a constant table. This is needed for subqueries in form "a IN (SELECT .. UNION SELECT ..): when we optimize the select that reads the results of the union from a temporary table, we must not mark the temp. table as constant because the number of rows in it may vary from one subquery execution to another.

Is set only in case if we have a GROUP BY clause and no ORDER BY after constant elimination of 'order'.

ORDER BY and GROUP BY lists, to transform with prepare,optimize and exec

TRUE <=> ref_pointer_array is set to items3.

Is set if we have a GROUP BY and we have ORDER BY on a constant.

Indicates that grouping will be performed on the result set during query execution. This field belongs to query execution.

See also:
make_group_fields, alloc_group_fields, JOIN::exec

second copy of sumfuncs (for queries with 2 temporary tables

Total number of tables in query block.

Before plan has been created, "tables" denote number of input tables in the query block and "primary_tables" is equal to "tables". After plan has been created (after JOIN::get_best_combination()), the JOIN_TAB objects are enumerated as follows:

  • "tables" gives the total number of allocated JOIN_TAB objects
  • "primary_tables" gives the number of input tables, including materialized temporary tables from semi-join operation.
  • "const_tables" are those tables among primary_tables that are detected to be constant.
  • "tmp_tables" is 0, 1 or 2 and counts the maximum possible number of intermediate tables in post-processing (ie sorting and duplicate removal). Later, tmp_tables will be adjusted to the correct number of intermediate tables,
    See also:
    JOIN::make_tmp_tables_info.
  • The remaining tables (ie. tables - primary_tables - tmp_tables) are input tables to materialized semi-join operations. The tables are ordered as follows in the join_tab array: 1. const primary table 2. non-const primary tables 3. intermediate sort/group tables 4. possible holes in array 5. semi-joined tables used with materialization strategy

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines