MySQL 9.1.0
Source Code Documentation
Opt_hints_qb Class Reference

Query block level hints. More...

#include <opt_hints.h>

Inheritance diagram for Opt_hints_qb:
[legend]

Public Member Functions

 Opt_hints_qb (Opt_hints *opt_hints_arg, MEM_ROOT *mem_root_arg, uint select_number_arg)
 
const LEX_CSTRINGget_print_name () override
 
void append_qb_hint (const THD *thd, String *str)
 Append query block hint. More...
 
void append_name (const THD *thd, String *str) override
 Append query block name. More...
 
PT_hintget_complex_hints (opt_hints_enum type) override
 Returns pointer to complex hint for a given type. More...
 
Opt_hints_tableadjust_table_hints (Table_ref *table)
 Function finds Opt_hints_table object corresponding to table alias in the query block and attaches corresponding key hint objects to appropriate KEY structures. More...
 
bool semijoin_enabled (const THD *thd) const
 Returns whether semi-join is enabled for this query block. More...
 
uint sj_enabled_strategies (uint opt_switches) const
 Returns bit mask of which semi-join strategies are enabled for this query block. More...
 
Subquery_strategy subquery_strategy () const
 Returns which subquery execution strategy has been specified by hints for this query block. More...
 
void print_irregular_hints (const THD *thd, String *str) override
 Function prints hints which are non-standard and don't fit into existing hint infrastructure. More...
 
const mem_root_deque< Table_ref * > * sort_tables_in_join_order (THD *thd, const mem_root_deque< Table_ref * > &join_list, bool toplevel=false)
 Sorts tables from the join list to create a new join list which contains the tables in an order which complies with join order hints. More...
 
bool check_join_order_hints (RelationalExpression *left, RelationalExpression *right, const mem_root_deque< Table_ref * > *join_list)
 Checks if a combination of left and right RelationalExpressions satisfy one or more join order hints. More...
 
bool hinted_join_order (PT_qb_level_hint *hint, RelationalExpression *left, RelationalExpression *right, const mem_root_deque< Table_ref * > *join_list)
 Checks if a combination of left and right RelationalExpressions satisfy a hint. More...
 
bool has_join_order_hints () const
 Checks if any join order hints have been specified in query. More...
 
void clear_join_order_hints ()
 Deletes all the join order hints. More...
 
void apply_join_order_hints (JOIN *join)
 Checks if join order hints are applicable and applies table dependencies if possible. More...
 
- Public Member Functions inherited from Opt_hints
 Opt_hints (const LEX_CSTRING *name_arg, Opt_hints *parent_arg, MEM_ROOT *mem_root_arg)
 
virtual ~Opt_hints ()=default
 
bool is_specified (opt_hints_enum type_arg) const
 
bool set_switch (bool switch_state_arg, opt_hints_enum type_arg, bool check_parent)
 Function sets switch hint state. More...
 
bool get_switch (opt_hints_enum type_arg) const
 Function returns switch hint state. More...
 
virtual const LEX_CSTRINGget_name () const
 
void set_name (const LEX_CSTRING *name_arg)
 
Opt_hintsget_parent () const
 
virtual void set_resolved ()
 
virtual bool is_resolved (opt_hints_enum type_arg)
 Returns 'resolved' flag value for depending on hint type. More...
 
virtual void set_unresolved (opt_hints_enum type_arg)
 Set hint to unresolved state. More...
 
virtual bool ignore_print (opt_hints_enum type_arg) const
 If ignore_print() returns true, hint is not printed in Opt_hints::print() function. More...
 
void incr_resolved_children ()
 
Mem_root_array< Opt_hints * > * child_array_ptr ()
 
bool is_all_resolved () const
 
void register_child (Opt_hints *hint_arg)
 
Opt_hintsfind_by_name (const LEX_CSTRING *name_arg, const CHARSET_INFO *cs) const
 Find hint among lower-level hint objects. More...
 
void print (const THD *thd, String *str, enum_query_type query_type)
 Print all hints except of QB_NAME hint. More...
 
void check_unresolved (THD *thd)
 Check if there are any unresolved hint objects and print warnings for them. More...
 

Private Member Functions

void register_join_order_hint (PT_qb_level_hint *hint_arg)
 

Private Attributes

uint select_number
 
LEX_CSTRING sys_name
 
char buff [32]
 
PT_qb_level_hintsubquery_hint
 
PT_qb_level_hintsemijoin_hint
 
Mem_root_array< PT_qb_level_hint * > join_order_hints
 Array of join order hints. More...
 
ulonglong join_order_hints_ignored
 Bit map of which hints are ignored. More...
 

Friends

class PT_qb_level_hint
 

Detailed Description

Query block level hints.

Constructor & Destructor Documentation

◆ Opt_hints_qb()

Opt_hints_qb::Opt_hints_qb ( Opt_hints opt_hints_arg,
MEM_ROOT mem_root_arg,
uint  select_number_arg 
)

Member Function Documentation

◆ adjust_table_hints()

Opt_hints_table * Opt_hints_qb::adjust_table_hints ( Table_ref table)

Function finds Opt_hints_table object corresponding to table alias in the query block and attaches corresponding key hint objects to appropriate KEY structures.

Parameters
tableTable reference
Returns
pointer Opt_hints_table object if this object is found, NULL otherwise.

◆ append_name()

void Opt_hints_qb::append_name ( const THD thd,
String str 
)
inlineoverridevirtual

Append query block name.

Parameters
thdpointer to THD object
strpointer to String object

Implements Opt_hints.

◆ append_qb_hint()

void Opt_hints_qb::append_qb_hint ( const THD thd,
String str 
)
inline

Append query block hint.

Parameters
thdpointer to THD object
strpointer to String object

◆ apply_join_order_hints()

void Opt_hints_qb::apply_join_order_hints ( JOIN join)

Checks if join order hints are applicable and applies table dependencies if possible.

Parameters
joinJOIN object

◆ check_join_order_hints()

bool Opt_hints_qb::check_join_order_hints ( RelationalExpression left,
RelationalExpression right,
const mem_root_deque< Table_ref * > *  join_list 
)

Checks if a combination of left and right RelationalExpressions satisfy one or more join order hints.

If the proposed join does not satisfy a hint, the remaining hints are ignored.

Parameters
leftLeft side of proposed join
rightRight side of proposed join
join_listDeque of tables in join
Returns
true if at least one hint matches, false otherwise

◆ clear_join_order_hints()

void Opt_hints_qb::clear_join_order_hints ( )

Deletes all the join order hints.

◆ get_complex_hints()

PT_hint * Opt_hints_qb::get_complex_hints ( opt_hints_enum  type)
overridevirtual

Returns pointer to complex hint for a given type.

A complex hint is a hint that has arguments. (It is not just an on/off switch.)

Parameters
typehint type
Returns
pointer to complex hint for a given type.

Reimplemented from Opt_hints.

◆ get_print_name()

const LEX_CSTRING * Opt_hints_qb::get_print_name ( )
inlineoverridevirtual

Reimplemented from Opt_hints.

◆ has_join_order_hints()

bool Opt_hints_qb::has_join_order_hints ( ) const

Checks if any join order hints have been specified in query.

Returns
true if join order hints present, false otherwise.

◆ hinted_join_order()

bool Opt_hints_qb::hinted_join_order ( PT_qb_level_hint hint,
RelationalExpression left,
RelationalExpression right,
const mem_root_deque< Table_ref * > *  join_list 
)

Checks if a combination of left and right RelationalExpressions satisfy a hint.

Parameters
hintHint info
leftLeft side of proposed join
rightRight side of proposed join
join_listDeque of tables in join
Returns
true if at least one hint matches, false otherwise

◆ print_irregular_hints()

void Opt_hints_qb::print_irregular_hints ( const THD thd,
String str 
)
overridevirtual

Function prints hints which are non-standard and don't fit into existing hint infrastructure.

Parameters
thdpointer to THD object
strpointer to String object

Reimplemented from Opt_hints.

◆ register_join_order_hint()

void Opt_hints_qb::register_join_order_hint ( PT_qb_level_hint hint_arg)
inlineprivate

◆ semijoin_enabled()

bool Opt_hints_qb::semijoin_enabled ( const THD thd) const

Returns whether semi-join is enabled for this query block.

A SEMIJOIN hint will force semi-join regardless of optimizer_switch settings. A NO_SEMIJOIN hint will only turn off semi-join if the variant with no strategies is used. A SUBQUERY hint will turn off semi-join. If there is no SEMIJOIN/SUBQUERY hint, optimizer_switch setting determines whether SEMIJOIN is used.

Parameters
thdPointer to THD object for session. Used to access optimizer_switch
Returns
true if semijoin is enabled

◆ sj_enabled_strategies()

uint Opt_hints_qb::sj_enabled_strategies ( uint  opt_switches) const

Returns bit mask of which semi-join strategies are enabled for this query block.

Parameters
opt_switchesBit map of strategies enabled by optimizer_switch
Returns
Bit mask of strategies that are enabled

◆ sort_tables_in_join_order()

const mem_root_deque< Table_ref * > * Opt_hints_qb::sort_tables_in_join_order ( THD thd,
const mem_root_deque< Table_ref * > &  join_list,
bool  toplevel = false 
)

Sorts tables from the join list to create a new join list which contains the tables in an order which complies with join order hints.

Parameters
thdThread handle.
join_listDeque of tables in join
toplevelFalse for subqueries, true otherwise
Returns
Deque of tables sorted in reverse hinted order.

◆ subquery_strategy()

Subquery_strategy Opt_hints_qb::subquery_strategy ( ) const

Returns which subquery execution strategy has been specified by hints for this query block.

Return values
SUBQ_MATERIALIZATIONSubquery Materialization should be used
SUBQ_EXISTSIn-to-exists execution should be used
UNSPECIFIEDNo SUBQUERY hint for this query block

Friends And Related Function Documentation

◆ PT_qb_level_hint

friend class PT_qb_level_hint
friend

Member Data Documentation

◆ buff

char Opt_hints_qb::buff[32]
private

◆ join_order_hints

Mem_root_array<PT_qb_level_hint *> Opt_hints_qb::join_order_hints
private

Array of join order hints.

◆ join_order_hints_ignored

ulonglong Opt_hints_qb::join_order_hints_ignored
private

Bit map of which hints are ignored.

◆ select_number

uint Opt_hints_qb::select_number
private

◆ semijoin_hint

PT_qb_level_hint * Opt_hints_qb::semijoin_hint
private

◆ subquery_hint

PT_qb_level_hint* Opt_hints_qb::subquery_hint
private

◆ sys_name

LEX_CSTRING Opt_hints_qb::sys_name
private

The documentation for this class was generated from the following files: