Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
Description
Currently some of the subquery rewrites are done in check_and_do_in_subquery_rewrites().
This function is called from
- JOIN::prepare() // the "primary" call
- Item_exists_subselect::exists2in_processor // the secondary
This task is about moving subquery rewrites from JOIN::prepare() phase into JOIN::optimize().
check_and_do_in_subquery_rewrites() does several rewrites:
- Convert subquery predicate into semi-join, or
|
- Mark the subquery for execution using materialization, or
|
- Perform IN->EXISTS transformation, or
|
- Perform more/less ALL/ANY -> MIN/MAX rewrite
|
- Substitute trivial scalar-context subquery with its value
|
Note that for semi-joins, check_and_do_in_subquery_rewrites() doesn't actually do the rewrites. It checks the condition and adds the subquery into SELECT_LEX::sj_subselects.
The actual conversion happens in JOIN::optimize_inner():
if (select_lex->first_cond_optimization) |
{
|
/* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */ |
if (convert_join_subqueries_to_semijoins(this)) |
DBUG_RETURN(1); /* purecov: inspected */ |
/* dump_TABLE_LIST_graph(select_lex, select_lex->leaf_tables); */ |
select_lex->update_used_tables();
|
}
|
Attachments
Issue Links
- is duplicated by
-
MDEV-23860 Move all optimization query re-writes from the prepare phase into the optimizer phase
- Closed