24#ifndef SQL_JOIN_OPTIMIZER_RELATIONAL_EXPRESSION_H
25#define SQL_JOIN_OPTIMIZER_RELATIONAL_EXPRESSION_H
256 [&](
const Item *other) { return ItemsAreEqual(cond, other); })) {
289 requires std::is_invocable_v<Func, RelationalExpression *>
bool IsSubset(uint64_t x, uint64_t y)
Definition: bit_utils.h:221
bool Overlaps(uint64_t x, uint64_t y)
Definition: bit_utils.h:229
The collection of CompanionSet objects for a given JoinHypergraph.
Definition: relational_expression.h:309
CompanionSet * Find(table_map tables)
Definition: relational_expression.h:319
CompanionSet * FindInternal(table_map tables) const
For a given set of tables, find the CompanionSet they are part of Returns nullptr if the tables are i...
Definition: relational_expression.cc:199
CompanionSetCollection(const CompanionSetCollection &)=delete
No copying.
void Compute(THD *thd, RelationalExpression *expr, CompanionSet *current_set)
Compute the CompanionSet of 'expr' and all of its descendants.
Definition: relational_expression.cc:149
std::array< CompanionSet *, MAX_TABLES > m_table_num_to_companion_set
A mapping from table number to CompanionSet.
Definition: relational_expression.h:330
CompanionSetCollection & operator=(const CompanionSetCollection &)=delete
CompanionSetCollection(THD *thd, struct RelationalExpression *root)
Definition: relational_expression.h:311
std::string ToString() const
For trace and debugging.
Definition: relational_expression.cc:181
const CompanionSet * Find(table_map tables) const
Definition: relational_expression.h:321
RelationalExpression objects in the same companion set are those that are inner-joined against each o...
Definition: relational_expression.h:80
CompanionSet & operator=(const CompanionSet &)=delete
Mem_root_array< EqualTerm > m_equal_terms
The set of sets of fields in equijoin predicates in this companion set.
Definition: relational_expression.h:129
table_map GetEqualityMap(const Field &field) const
If 'field' is part of an equijoin predicate in this CompanionSet, return a table_map of the tables in...
Definition: relational_expression.cc:121
CompanionSet(const CompanionSet &)=delete
No copying.
CompanionSet(THD *thd)
Definition: relational_expression.h:84
std::string ToString() const
For tracing and debugging.
Definition: relational_expression.cc:132
void AddEquijoinCondition(THD *thd, const Item_func_eq &eq)
Add the set of equal fields specified by 'func_eq'.
Definition: relational_expression.cc:66
Base class for the equality comparison operators = and <=>.
Definition: item_cmpfunc.h:995
Implements the comparison operator equals (=)
Definition: item_cmpfunc.h:1060
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
virtual table_map used_tables() const
Definition: item.h:2364
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Definition: overflow_bitset.h:78
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
table_map map() const
Return table map derived from table number.
Definition: table.h:4036
NESTED_JOIN * nested_join
Is non-NULL if this table reference is a nested join, ie it represents the inner tables of an outer j...
Definition: table.h:3914
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
@ ANTI
Left antijoin, i.e.
@ SEMI
Left semijoin, i.e.
uint64_t table_map
Definition: my_table_map.h:30
uint64_t NodeMap
Since our graphs can never have more than 61 tables, node sets and edge lists are implemented using 6...
Definition: node_map.h:40
OverflowBitset is a fixed-size (once allocated) bitmap that is optimized for the common case of few e...
void ForEachJoinOperator(RelationalExpression *expr, Func &&func)
Definition: relational_expression.h:290
void ForEachOperator(RelationalExpression *expr, Func &&func)
Definition: relational_expression.h:300
bool PassesConflictRules(hypergraph::NodeMap joined_tables, const RelationalExpression *expr)
Definition: relational_expression.h:268
bool OperatorIsCommutative(const RelationalExpression &expr)
Definition: relational_expression.h:281
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:227
Definition: relational_expression.h:47
double selectivity
Definition: relational_expression.h:49
Mem_root_array< ContainedSubquery > contained_subqueries
Definition: relational_expression.h:48
OverflowBitset redundant_against_sargable_predicates
Definition: relational_expression.h:57
This represents equality between a set of fields, i.e.
Definition: relational_expression.h:110
FieldArray * fields
The fields that are equal to each other.
Definition: relational_expression.h:112
table_map tables
A map of all tables in 'fields'.
Definition: relational_expression.h:115
Definition: relational_expression.h:65
hypergraph::NodeMap required_nodes
Definition: relational_expression.h:67
hypergraph::NodeMap needed_to_activate_rule
Definition: relational_expression.h:66
uint sj_enabled_strategies
Bitmap of which strategies are enabled for this semi-join nest.
Definition: nested_join.h:136
Represents an expression tree in the relational algebra of joins.
Definition: relational_expression.h:147
int join_predicate_last
Definition: relational_expression.h:233
Mem_root_array< CachedPropertiesForPredicate > properties_for_equijoin_conditions
Definition: relational_expression.h:221
const Mem_root_array< Item * > & pushable_conditions() const
Definition: relational_expression.h:245
Mem_root_array< Item_eq_base * > equijoin_conditions
Definition: relational_expression.h:208
int join_predicate_first
Definition: relational_expression.h:233
Mem_root_array< ConflictRule > conflict_rules
Definition: relational_expression.h:238
void enable_semijoin_strategies(const Table_ref *tl)
Definition: relational_expression.h:241
enum RelationalExpression::Type type
CompanionSet * companion_set
Definition: relational_expression.h:199
RelationalExpression(THD *thd)
Definition: relational_expression.h:180
void AddPushable(Item *cond)
Add a condition that can be pushed down to the acces path for 'table'.
Definition: relational_expression.h:250
table_map tables_in_subtree
Definition: relational_expression.h:188
const Table_ref * table
Definition: relational_expression.h:196
hypergraph::NodeMap nodes_in_subtree
Definition: relational_expression.h:193
Mem_root_array< RelationalExpression * > multi_children
Definition: relational_expression.h:206
uint sj_enabled_strategies
Definition: relational_expression.h:239
table_map conditions_used_tables
Definition: relational_expression.h:226
Mem_root_array< Item * > join_conditions
Definition: relational_expression.h:207
Type
Definition: relational_expression.h:148
@ SEMIJOIN
Left semijoin.
Definition: relational_expression.h:153
@ MULTI_INNER_JOIN
Definition: relational_expression.h:175
@ STRAIGHT_INNER_JOIN
Definition: relational_expression.h:161
@ ANTIJOIN
Left antijoin.
Definition: relational_expression.h:156
@ INNER_JOIN
Definition: relational_expression.h:149
@ FULL_OUTER_JOIN
Definition: relational_expression.h:168
@ TABLE
Definition: relational_expression.h:177
@ LEFT_JOIN
Definition: relational_expression.h:150
Mem_root_array< Item * > m_pushable_conditions
Conditions that can be pushed down to the acces path for 'table'.
Definition: relational_expression.h:263
bool join_conditions_reject_all_rows
Definition: relational_expression.h:225
Mem_root_array< CachedPropertiesForPredicate > properties_for_join_conditions
Definition: relational_expression.h:219
RelationalExpression * left
Definition: relational_expression.h:204
RelationalExpression * right
Definition: relational_expression.h:204