mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-36106 New-style hints: [NO_]DERIVED_CONDITION_PUSHDOWN, [NO_]MERGE
Implements and tests the optimizer hints DERIVED_CONDITION_PUSHDOWN and NO_DERIVED_CONDITION_PUSHDOWN, table-level hints to enable and disable, respectively, the condition pushdown for derived tables which is typically controlled by the condition_pushdown_for_derived optimizer switch. Implements and tests the optimizer hints MERGE and NO_MERGE, table-level hints to enable and disable, respectively, the derived_merge optimization which is typically controlled by the derived_merge optimizer switch. Sometimes hints need to be fixed before TABLE instances are available, but after TABLE_LIST instances have been created (as in the cases of MERGE and NO_MERGE). This commit introduces a new function called fix_hints_for_derived_table to allow early hint fixing for derived tables, using only a TABLE_LIST instance (so long as such hints are not index-level).
This commit is contained in:
committed by
Dave Gosselin
parent
e653666368
commit
2ee2e2d0f3
@@ -51,6 +51,11 @@
|
||||
each table, as a result TABLE_LIST::opt_hints_table points to the table's
|
||||
hints.
|
||||
|
||||
Non-index hints may be fixed before TABLE instances are available, by
|
||||
calling fix_hints_for_derived_table and using a TABLE_LIST instance; as
|
||||
the name implies, this is the case for derived tables (and such tables
|
||||
are the only use case at this point).
|
||||
|
||||
== Hint hierarchy ==
|
||||
|
||||
Hints have this hierarchy, less specific to more specific:
|
||||
@@ -178,6 +183,13 @@ protected:
|
||||
for key level.
|
||||
*/
|
||||
Lex_ident_sys name;
|
||||
|
||||
/*
|
||||
Hints by default are NOT_FIXED.
|
||||
When hints are fixed, during hint resolution, they
|
||||
transition from NOT_FIXED to FIXED.
|
||||
*/
|
||||
enum class Fixed_state { NOT_FIXED, FIXED };
|
||||
private:
|
||||
/*
|
||||
Parent object. There is no parent for global level,
|
||||
@@ -193,8 +205,8 @@ private:
|
||||
/* Array of child objects. i.e. array of the lower level objects */
|
||||
Mem_root_array<Opt_hints*, true> child_array;
|
||||
|
||||
/* true if hint is connected to the real object */
|
||||
bool fixed;
|
||||
/* FIXED if hint is connected to the real object (see above) */
|
||||
Fixed_state fixed;
|
||||
|
||||
/*
|
||||
Number of child hints that are fully fixed, that is, fixed and
|
||||
@@ -208,7 +220,7 @@ public:
|
||||
Opt_hints *parent_arg,
|
||||
MEM_ROOT *mem_root_arg)
|
||||
: name(name_arg), parent(parent_arg), child_array(mem_root_arg),
|
||||
fixed(false), n_fully_fixed_children(0)
|
||||
fixed(Fixed_state::NOT_FIXED), n_fully_fixed_children(0)
|
||||
{ }
|
||||
|
||||
bool is_specified(opt_hints_enum type_arg) const
|
||||
@@ -260,8 +272,8 @@ public:
|
||||
}
|
||||
void set_name(const Lex_ident_sys &name_arg) { name= name_arg; }
|
||||
Opt_hints *get_parent() const { return parent; }
|
||||
void set_fixed() { fixed= true; }
|
||||
bool is_fixed() const { return fixed; }
|
||||
void set_fixed() { fixed= Fixed_state::FIXED; }
|
||||
bool is_fixed() const { return fixed == Fixed_state::FIXED; }
|
||||
void incr_fully_fixed_children() { n_fully_fixed_children++; }
|
||||
Mem_root_array<Opt_hints*, true> *child_array_ptr() { return &child_array; }
|
||||
|
||||
@@ -450,6 +462,8 @@ public:
|
||||
void append_hint_arguments(THD *thd, opt_hints_enum hint,
|
||||
String *str) override;
|
||||
|
||||
void fix_hints_for_derived_table(TABLE_LIST *table_list);
|
||||
|
||||
/**
|
||||
Function finds Opt_hints_table object corresponding to
|
||||
table alias in the query block and attaches corresponding
|
||||
@@ -662,6 +676,20 @@ bool hint_key_state(const THD *thd, const TABLE *table,
|
||||
uint keyno, opt_hints_enum type_arg,
|
||||
uint optimizer_switch);
|
||||
|
||||
/**
|
||||
Returns table hint value if hint is specified, returns
|
||||
fallback value if hint is not specified.
|
||||
|
||||
@param thd Pointer to THD object
|
||||
@param table_lsit Pointer to TABLE_LIST object
|
||||
@param type_arg Hint type
|
||||
@param fallback_value Value to be returned if the hint is not set
|
||||
|
||||
@return table hint value if hint is specified,
|
||||
otherwise fallback value.
|
||||
*/
|
||||
bool hint_table_state(const THD *thd, const TABLE_LIST *table_list,
|
||||
opt_hints_enum type_arg, bool fallback_value);
|
||||
|
||||
/**
|
||||
Returns table hint value if hint is specified, returns
|
||||
|
Reference in New Issue
Block a user