mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +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
@@ -2513,43 +2513,42 @@ JOIN::optimize_inner()
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED))
|
||||
TABLE_LIST *tbl;
|
||||
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
|
||||
while ((tbl= li++))
|
||||
{
|
||||
TABLE_LIST *tbl;
|
||||
List_iterator_fast<TABLE_LIST> li(select_lex->leaf_tables);
|
||||
while ((tbl= li++))
|
||||
const bool is_derived_pushdown_allowed= hint_table_state(
|
||||
thd, tbl->table, DERIVED_CONDITION_PUSHDOWN_HINT_ENUM,
|
||||
optimizer_flag(thd, OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED));
|
||||
if (!is_derived_pushdown_allowed)
|
||||
{
|
||||
/*
|
||||
/* Run optimize phase on this derived table/view. */
|
||||
if (tbl->is_view_or_derived() &&
|
||||
tbl->handle_derived(thd->lex, DT_OPTIMIZE))
|
||||
DBUG_RETURN(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tbl->is_materialized_derived())
|
||||
{
|
||||
JOIN *join= tbl->get_unit()->first_select()->join;
|
||||
if (join &&
|
||||
join->optimization_state == JOIN::OPTIMIZATION_PHASE_1_DONE &&
|
||||
join->with_two_phase_optimization)
|
||||
continue;
|
||||
/*
|
||||
Do not push conditions from where into materialized inner tables
|
||||
of outer joins: this is not valid.
|
||||
*/
|
||||
if (tbl->is_materialized_derived())
|
||||
if (!tbl->is_inner_table_of_outer_join())
|
||||
{
|
||||
JOIN *join= tbl->get_unit()->first_select()->join;
|
||||
if (join &&
|
||||
join->optimization_state == JOIN::OPTIMIZATION_PHASE_1_DONE &&
|
||||
join->with_two_phase_optimization)
|
||||
continue;
|
||||
/*
|
||||
Do not push conditions from where into materialized inner tables
|
||||
of outer joins: this is not valid.
|
||||
*/
|
||||
if (!tbl->is_inner_table_of_outer_join())
|
||||
{
|
||||
if (pushdown_cond_for_derived(thd, conds, tbl))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (mysql_handle_single_derived(thd->lex, tbl, DT_OPTIMIZE))
|
||||
DBUG_RETURN(1);
|
||||
if (pushdown_cond_for_derived(thd, conds, tbl))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (mysql_handle_single_derived(thd->lex, tbl, DT_OPTIMIZE))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Run optimize phase for all derived tables/views used in this SELECT. */
|
||||
if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
{
|
||||
if (select_lex->where)
|
||||
{
|
||||
|
Reference in New Issue
Block a user