mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
This is a full cost-based implementation of the optimization that employs
splitting technique for equi-joins of materialized derived tables/views/CTEs. (see mdev-13369 and mdev-13389).
This commit is contained in:
@ -119,6 +119,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
|
||||
../sql/session_tracker.cc
|
||||
../sql/proxy_protocol.cc
|
||||
../sql/sql_tvc.cc ../sql/sql_tvc.h
|
||||
../sql/opt_split.cc
|
||||
${GEN_SOURCES}
|
||||
${MYSYS_LIBWRAP_SOURCE}
|
||||
)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -665,7 +665,7 @@ The following options may be given as the first argument:
|
||||
join_cache_hashed, join_cache_bka,
|
||||
optimize_join_buffer_size, table_elimination,
|
||||
extended_keys, exists_to_in, orderby_uses_equalities,
|
||||
condition_pushdown_for_derived, split_grouping_derived
|
||||
condition_pushdown_for_derived, split_materialized
|
||||
--optimizer-use-condition-selectivity=#
|
||||
Controls selectivity of which conditions the optimizer
|
||||
takes into account to calculate cardinality of a partial
|
||||
@ -1510,7 +1510,7 @@ old-style-user-limits FALSE
|
||||
optimizer-prune-level 1
|
||||
optimizer-search-depth 62
|
||||
optimizer-selectivity-sampling-limit 100
|
||||
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
optimizer-use-condition-selectivity 1
|
||||
performance-schema FALSE
|
||||
performance-schema-accounts-size -1
|
||||
|
@ -141,7 +141,7 @@ order by s_suppkey;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY supplier ALL PRIMARY NULL NULL NULL 10 100.00 Using filesort
|
||||
1 PRIMARY <derived3> ref key0 key0 5 dbt3_s001.supplier.s_suppkey 10 100.00 Using where
|
||||
3 LATERAL DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 268 75.00 Using where
|
||||
3 DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 268 100.00 Using where; Using temporary; Using filesort
|
||||
2 SUBQUERY <derived4> ALL NULL NULL NULL NULL 268 100.00
|
||||
4 DERIVED lineitem range i_l_shipdate i_l_shipdate 4 NULL 268 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
@ -162,7 +162,7 @@ order by s_suppkey;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY supplier ALL PRIMARY NULL NULL NULL 10 100.00 Using filesort
|
||||
1 PRIMARY <derived3> ref key0 key0 5 dbt3_s001.supplier.s_suppkey 10 100.00 Using where
|
||||
3 LATERAL DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 268 100.00 Using where
|
||||
3 DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 268 100.00 Using where; Using temporary; Using filesort
|
||||
2 SUBQUERY <derived4> ALL NULL NULL NULL NULL 268 100.00
|
||||
4 DERIVED lineitem range i_l_shipdate i_l_shipdate 4 NULL 268 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
|
@ -144,7 +144,7 @@ order by s_suppkey;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY supplier index PRIMARY PRIMARY 4 NULL 10 100.00
|
||||
1 PRIMARY <derived3> ref key0 key0 5 dbt3_s001.supplier.s_suppkey 10 100.00 Using where
|
||||
3 LATERAL DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 229 75.11 Using where
|
||||
3 DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 229 100.00 Using where; Using temporary; Using filesort
|
||||
2 SUBQUERY <derived4> ALL NULL NULL NULL NULL 229 100.00
|
||||
4 DERIVED lineitem range i_l_shipdate i_l_shipdate 4 NULL 229 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
@ -165,7 +165,7 @@ order by s_suppkey;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY supplier index PRIMARY PRIMARY 4 NULL 10 100.00
|
||||
1 PRIMARY <derived3> ref key0 key0 5 dbt3_s001.supplier.s_suppkey 10 100.00 Using where
|
||||
3 LATERAL DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 229 100.00 Using where
|
||||
3 DERIVED lineitem range i_l_shipdate,i_l_suppkey i_l_shipdate 4 NULL 229 100.00 Using where; Using temporary; Using filesort
|
||||
2 SUBQUERY <derived4> ALL NULL NULL NULL NULL 228 100.00
|
||||
4 DERIVED lineitem range i_l_shipdate i_l_shipdate 4 NULL 229 100.00 Using where; Using temporary; Using filesort
|
||||
Warnings:
|
||||
|
@ -1,63 +1,63 @@
|
||||
SET @start_global_value = @@global.optimizer_switch;
|
||||
SELECT @start_global_value;
|
||||
@start_global_value
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
show global variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
show session variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
optimizer_switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
select * from information_schema.global_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
select * from information_schema.session_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
OPTIMIZER_SWITCH index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
set global optimizer_switch=10;
|
||||
set session optimizer_switch=5;
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=off,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
index_merge=on,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
set global optimizer_switch="index_merge_sort_union=on";
|
||||
set session optimizer_switch="index_merge=off";
|
||||
select @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
show global variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
optimizer_switch index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
show session variables like 'optimizer_switch';
|
||||
Variable_name Value
|
||||
optimizer_switch index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
optimizer_switch index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
select * from information_schema.global_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
OPTIMIZER_SWITCH index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
select * from information_schema.session_variables where variable_name='optimizer_switch';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
OPTIMIZER_SWITCH index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
OPTIMIZER_SWITCH index_merge=off,index_merge_union=off,index_merge_sort_union=on,index_merge_intersection=off,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
set session optimizer_switch="default";
|
||||
select @@session.optimizer_switch;
|
||||
@@session.optimizer_switch
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_grouping_derived=off
|
||||
index_merge=off,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=off,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=off
|
||||
set optimizer_switch = replace(@@optimizer_switch, '=off', '=on');
|
||||
Warnings:
|
||||
Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
set global optimizer_switch=1.1;
|
||||
ERROR 42000: Incorrect argument type to variable 'optimizer_switch'
|
||||
set global optimizer_switch=1e1;
|
||||
@ -69,4 +69,4 @@ ERROR 42000: Variable 'optimizer_switch' can't be set to the value of 'foobar'
|
||||
SET @@global.optimizer_switch = @start_global_value;
|
||||
SELECT @@global.optimizer_switch;
|
||||
@@global.optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
|
@ -8,6 +8,7 @@ where variable_name not like 'aria%' and
|
||||
variable_name not like 'debug%' and
|
||||
variable_name not like 'wsrep%' and
|
||||
variable_name not in (
|
||||
'in_predicate_conversion_threshold',
|
||||
'have_openssl',
|
||||
'have_symlink',
|
||||
'hostname',
|
||||
@ -2672,17 +2673,17 @@ ENUM_VALUE_LIST NULL
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_SWITCH
|
||||
SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE FLAGSET
|
||||
VARIABLE_COMMENT Fine-tune the optimizer behavior
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_grouping_derived,default
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,default
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_USE_CONDITION_SELECTIVITY
|
||||
|
@ -2883,17 +2883,17 @@ ENUM_VALUE_LIST NULL
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_SWITCH
|
||||
SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
SESSION_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
GLOBAL_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
DEFAULT_VALUE index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE FLAGSET
|
||||
VARIABLE_COMMENT Fine-tune the optimizer behavior
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_grouping_derived,default
|
||||
ENUM_VALUE_LIST index_merge,index_merge_union,index_merge_sort_union,index_merge_intersection,index_merge_sort_intersection,engine_condition_pushdown,index_condition_pushdown,derived_merge,derived_with_keys,firstmatch,loosescan,materialization,in_to_exists,semijoin,partial_match_rowid_merge,partial_match_table_scan,subquery_cache,mrr,mrr_cost_based,mrr_sort_keys,outer_join_with_cache,semijoin_with_cache,join_cache_incremental,join_cache_hashed,join_cache_bka,optimize_join_buffer_size,table_elimination,extended_keys,exists_to_in,orderby_uses_equalities,condition_pushdown_for_derived,split_materialized,default
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME OPTIMIZER_USE_CONDITION_SELECTIVITY
|
||||
|
@ -2145,7 +2145,7 @@ drop table t1;
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_switch= @@optimizer_switch;
|
||||
set optimizer_switch='split_grouping_derived=off';
|
||||
set optimizer_switch='split_materialized=off';
|
||||
|
||||
create table t1 (a int, c varchar(16));
|
||||
insert into t1 values
|
||||
@ -2256,28 +2256,62 @@ set optimizer_switch= @save_optimizer_switch;
|
||||
--echo #
|
||||
|
||||
let
|
||||
$no_splitting= set statement optimizer_switch='split_grouping_derived=off' for;
|
||||
$no_splitting= set statement optimizer_switch='split_materialized=off' for;
|
||||
|
||||
create table t1 (a int);
|
||||
create table t1 (a int, b int, index idx_b(b)) engine=myisam;
|
||||
insert into t1 values
|
||||
(8), (5), (1), (2), (9), (7), (2), (7);
|
||||
(8,3), (5,7), (1,2), (2,1), (9,7), (7,5), (2,2), (7,3),
|
||||
(9,3), (8,1), (4,5), (2,3);
|
||||
|
||||
create table t2 (a int, b int, index idx(a));
|
||||
create table t2 (a int, b int, c char(127), index idx_a(a)) engine=myisam;
|
||||
insert into t2 values
|
||||
(7,10), (1,20), (2,23), (7,18), (1,30),
|
||||
(4,71), (3,15), (7,82), (8,12), (4,15),
|
||||
(11,33), (10,42), (4,53), (10,17), (2,90);
|
||||
(7,10,'x'), (1,20,'a'), (2,23,'b'), (7,18,'z'), (1,30,'c'),
|
||||
(4,71,'d'), (3,15,'x'), (7,82,'y'), (8,12,'t'), (4,15,'b'),
|
||||
(11,33,'a'), (10,42,'u'), (4,53,'p'), (10,17,'r'), (2,90,'x'),
|
||||
(17,10,'s'), (11,20,'v'), (12,23,'y'), (17,18,'a'), (11,30,'d'),
|
||||
(24,71,'h'), (23,15,'i'), (27,82,'k'), (28,12,'p'), (24,15,'q'),
|
||||
(31,33,'f'), (30,42,'h'), (40,53,'m'), (30,17,'o'), (21,90,'b'),
|
||||
(37,10,'e'), (31,20,'g'), (32,23,'f'), (37,18,'n'), (41,30,'l'),
|
||||
(54,71,'j'), (53,15,'w'), (57,82,'z'), (58,12,'k'), (54,15,'p'),
|
||||
(61,33,'c'), (60,42,'a'), (62,53,'x'), (67,17,'g'), (64,90,'v');
|
||||
|
||||
insert into t2 select a+10, b+10, concat(c,'f') from t2;
|
||||
|
||||
analyze table t1,t2;
|
||||
|
||||
let $q1=
|
||||
select t1.a,t.max,t.min
|
||||
select t1.a,t.s,t.m
|
||||
from t1 join
|
||||
(select a, max(t2.b) max, min(t2.b) min from t2 group by t2.a) t
|
||||
on t1.a=t.a;
|
||||
(select a, sum(t2.b) as s, min(t2.c) as m from t2 group by t2.a) t
|
||||
on t1.a=t.a
|
||||
where t1.b < 3;
|
||||
|
||||
eval $no_splitting $q1;
|
||||
eval $q1;
|
||||
eval explain extended $q1;
|
||||
eval explain format=json $q1;
|
||||
eval prepare stmt from "$q1";
|
||||
execute stmt;
|
||||
execute stmt;
|
||||
deallocate prepare stmt;
|
||||
|
||||
let $q10=
|
||||
select t1.a,t.s,t.m
|
||||
from t1 join
|
||||
(select a, sum(t2.b) as s, min(t2.b) as m from t2 group by t2.a) t
|
||||
on t1.a=t.a
|
||||
where t1.b <= 5;
|
||||
|
||||
eval $no_splitting $q10;
|
||||
eval $q10;
|
||||
eval explain extended $q10;
|
||||
eval explain format=json $q10;
|
||||
eval prepare stmt from "$q10";
|
||||
execute stmt;
|
||||
execute stmt;
|
||||
deallocate prepare stmt;
|
||||
|
||||
delete from t1 where t1.b between 2 and 5;
|
||||
|
||||
let $q2=
|
||||
select t1.a,t.max,t.min
|
||||
@ -2290,68 +2324,122 @@ eval $q2;
|
||||
eval explain extended $q2;
|
||||
eval explain format=json $q2;
|
||||
|
||||
create table t3 (a int, c varchar(16));
|
||||
create table t3 (a int, b int, c char(127), index idx_b(b)) engine=myisam;
|
||||
insert into t3 values
|
||||
(8,'aa'), (5,'cc'), (1,'bb'), (2,'aa'), (9,'cc'),
|
||||
(7,'aa'), (2,'aa'), (7,'bb');
|
||||
(8,11,'aa'), (5,15,'cc'), (1,14,'bb'), (2,12,'aa'), (7,17,'cc'),
|
||||
(7,18,'aa'), (2,11,'aa'), (7,10,'bb'), (3,11,'dd'), (4,12,'ee'),
|
||||
(5,14,'dd'), (9,12,'ee');
|
||||
|
||||
create table t4 (a int, b int, c varchar(16), index idx(a,c));
|
||||
create table t4 (a int, b int, c char(127), index idx(a,c)) engine=myisam;
|
||||
insert into t4 values
|
||||
(7,10,'cc'), (1,20,'aa'), (2,23,'bb'), (7,18,'cc'), (1,30,'bb'),
|
||||
(4,71,'xx'), (3,15,'aa'), (7,82,'bb'), (8,12,'dd'), (4,15,'aa'),
|
||||
(11,33,'yy'), (10,42,'zz'), (4,53,'xx'), (10,17,'yy'), (7,12,'bb'),
|
||||
(4,71,'xx'), (3,15,'aa'), (7,82,'aa'), (8,12,'dd'), (4,15,'aa'),
|
||||
(11,33,'yy'), (10,42,'zz'), (4,53,'xx'), (10,17,'yy'), (7,12,'cc'),
|
||||
(8,20,'dd'), (7,32,'bb'), (1,50,'aa'), (3,40,'bb'), (3,77,'aa');
|
||||
|
||||
insert into t4 select a+10, b+10, concat(c,'f') from t4;
|
||||
|
||||
analyze table t3,t4;
|
||||
|
||||
let $q3=
|
||||
select t3.a,t3.c,t.max,t.min
|
||||
from t3 join
|
||||
(select a, c, max(b) max, min(b) min from t4 group by a,c) t
|
||||
on t3.a=t.a and t3.c=t.c;
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b > 15;
|
||||
|
||||
eval $no_splitting $q3;
|
||||
eval $q3;
|
||||
eval explain extended $q3;
|
||||
eval explain format=json $q3;
|
||||
|
||||
let $q30=
|
||||
select t3.a,t3.c,t.max,t.min
|
||||
from t3 join
|
||||
(select a, c, max(b) max, min(b) min from t4 group by a,c) t
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b <= 15;
|
||||
|
||||
eval $no_splitting $q30;
|
||||
eval $q30;
|
||||
eval explain extended $q30;
|
||||
eval explain format=json $q30;
|
||||
|
||||
let $q4=
|
||||
select t3.a,t3.c,t.max,t.min
|
||||
from t3 join
|
||||
(select a, c, max(b) max, min(b) min from t4 group by c,a) t
|
||||
on t3.a=t.a and t3.c=t.c;
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b > 15;
|
||||
|
||||
eval $no_splitting $q4;
|
||||
eval $q4;
|
||||
eval explain extended $q4;
|
||||
eval explain format=json $q4;
|
||||
|
||||
drop index idx on t2;
|
||||
create index idx on t2(b);
|
||||
create index idx on t3(a);
|
||||
create index idx2 on t4(c);
|
||||
insert into t3 select a+1, concat(c,'f') from t3;
|
||||
insert into t3 select a+1, concat(c,'h') from t3;
|
||||
insert into t4 select a+1, b+10, concat(c,'h') from t4;
|
||||
let $q40=
|
||||
select t3.a,t3.c,t.max,t.min
|
||||
from t3 join
|
||||
(select a, c, max(b) max, min(b) min from t4 group by c,a) t
|
||||
on t3.a=t.a and t3.c=t.c
|
||||
where t3.b <= 15;
|
||||
|
||||
eval $no_splitting $q40;
|
||||
eval $q40;
|
||||
eval explain extended $q40;
|
||||
eval explain format=json $q40;
|
||||
|
||||
drop index idx_a on t2;
|
||||
create index idx on t2(c,b);
|
||||
create index idx_a on t3(a);
|
||||
create index idx_c on t4(c);
|
||||
insert into t3 select a+10, b+10, concat(c,'f') from t3;
|
||||
insert into t3 select a+100, b+100, concat(c,'g') from t3;
|
||||
insert into t4 select a+100, b+100, concat(c,'g') from t4;
|
||||
insert into t4 select a+1000, b+1000, concat(c,'h') from t4;
|
||||
|
||||
analyze table t2,t3,t4;
|
||||
|
||||
let $q5=
|
||||
select t2.a,t2.b,t3.c,t.max,t.min
|
||||
select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
|
||||
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
|
||||
where t2.b > 50 and t2.a=t3.a and t3.c=t.c;
|
||||
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
|
||||
|
||||
eval $no_splitting $q5;
|
||||
eval $q5;
|
||||
eval explain extended $q5;
|
||||
eval explain format=json $q5;
|
||||
|
||||
let $q50=
|
||||
select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
|
||||
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
|
||||
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
|
||||
|
||||
eval $no_splitting $q50;
|
||||
eval $q50;
|
||||
eval explain extended $q50;
|
||||
eval explain format=json $q50;
|
||||
|
||||
let $q6=
|
||||
select *
|
||||
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
|
||||
where t2.b > 50 and t2.a=t3.a and t3.c=t.c;
|
||||
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
|
||||
|
||||
eval $no_splitting $q6;
|
||||
eval $q6;
|
||||
eval explain extended $q6;
|
||||
eval explain format=json $q6;
|
||||
|
||||
let $q60=
|
||||
select *
|
||||
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
|
||||
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
|
||||
|
||||
eval $no_splitting $q60;
|
||||
eval $q60;
|
||||
eval explain extended $q60;
|
||||
eval explain format=json $q60;
|
||||
|
||||
drop table t1,t2,t3,t4;
|
||||
|
||||
--echo #
|
||||
@ -2365,18 +2453,23 @@ INSERT INTO t1 VALUES (1),(9),(3);
|
||||
CREATE TABLE t2 (a int, i int);
|
||||
INSERT INTO t2 VALUES (1,9),(2,3),(3,7),(4,1);
|
||||
|
||||
CREATE TABLE t3 (a int, c varchar(8), index(c));
|
||||
CREATE TABLE t3 (a int, c char(127), index(c));
|
||||
INSERT INTO t3 VALUES (1,'foo'),(3,'bar'),(4,'foo'),(2,'bar');
|
||||
INSERT INTO t3 SELECT a, concat(c,'a') FROM t3;
|
||||
|
||||
CREATE TABLE t4 (c varchar(8));
|
||||
INSERT INTO t4 VALUES ('abc'),('foo'),('def');
|
||||
CREATE TABLE t4 (a int, c char(127), index(a));
|
||||
INSERT INTO t4 VALUES
|
||||
(3,'abc'),(1,'foo'),(4,'def'),(8,'xxx'),(3,'yyy'),
|
||||
(5,'zzz'),(9,'xyz'),(2,'yxz'),(5,'zxy'),(7,'zyx') ;
|
||||
|
||||
ANALYZE TABLE t1,t2,t3,t4;
|
||||
|
||||
CREATE VIEW v1 AS
|
||||
SELECT c FROM t3
|
||||
WHERE a IN ( SELECT t2.a FROM t1 JOIN t2 WHERE t1.i = t2.i ) GROUP BY c ;
|
||||
|
||||
let $q1=
|
||||
SELECT * FROM t4 WHERE c IN ( SELECT c FROM v1 );
|
||||
SELECT * FROM t4 WHERE c IN ( SELECT c FROM v1 ) and a < 2;
|
||||
|
||||
eval $no_splitting $q1;
|
||||
eval $q1;
|
||||
|
@ -145,6 +145,7 @@ SET (SQL_SOURCE
|
||||
sql_cte.cc
|
||||
sql_sequence.cc sql_sequence.h ha_sequence.h
|
||||
sql_tvc.cc sql_tvc.h
|
||||
opt_split.cc
|
||||
${WSREP_SOURCES}
|
||||
table_cache.cc encryption.cc temporary_tables.cc
|
||||
proxy_protocol.cc
|
||||
|
1132
sql/opt_split.cc
Normal file
1132
sql/opt_split.cc
Normal file
File diff suppressed because it is too large
Load Diff
@ -446,10 +446,6 @@ static bool convert_subq_to_jtbm(JOIN *parent_join,
|
||||
Item_in_subselect *subq_pred, bool *remove);
|
||||
static TABLE_LIST *alloc_join_nest(THD *thd);
|
||||
static uint get_tmp_table_rec_length(Ref_ptr_array p_list, uint elements);
|
||||
static double get_tmp_table_lookup_cost(THD *thd, double row_count,
|
||||
uint row_size);
|
||||
static double get_tmp_table_write_cost(THD *thd, double row_count,
|
||||
uint row_size);
|
||||
bool find_eq_ref_candidate(TABLE *table, table_map sj_inner_tables);
|
||||
static SJ_MATERIALIZATION_INFO *
|
||||
at_sjmat_pos(const JOIN *join, table_map remaining_tables, const JOIN_TAB *tab,
|
||||
@ -2468,7 +2464,7 @@ static uint get_tmp_table_rec_length(Ref_ptr_array p_items, uint elements)
|
||||
@return the cost of one lookup
|
||||
*/
|
||||
|
||||
static double
|
||||
double
|
||||
get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size)
|
||||
{
|
||||
if (row_count * row_size > thd->variables.max_heap_table_size)
|
||||
@ -2488,7 +2484,7 @@ get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size)
|
||||
@return the cost of writing one row
|
||||
*/
|
||||
|
||||
static double
|
||||
double
|
||||
get_tmp_table_write_cost(THD *thd, double row_count, uint row_size)
|
||||
{
|
||||
double lookup_cost= get_tmp_table_lookup_cost(thd, row_count, row_size);
|
||||
|
@ -5507,8 +5507,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Optimizer and executor structure for the materialized semi-join info. This
|
||||
structure contains
|
||||
|
@ -231,6 +231,7 @@
|
||||
*/
|
||||
#define HEAP_TEMPTABLE_LOOKUP_COST 0.05
|
||||
#define DISK_TEMPTABLE_LOOKUP_COST 1.0
|
||||
#define SORT_INDEX_CMP_COST 0.02
|
||||
|
||||
#define MY_CHARSET_BIN_MB_MAXLEN 1
|
||||
|
||||
|
@ -227,7 +227,7 @@
|
||||
#define OPTIMIZER_SWITCH_EXISTS_TO_IN (1ULL << 28)
|
||||
#define OPTIMIZER_SWITCH_ORDERBY_EQ_PROP (1ULL << 29)
|
||||
#define OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED (1ULL << 30)
|
||||
#define OPTIMIZER_SWITCH_SPLIT_GROUPING_DERIVED (1ULL << 31)
|
||||
#define OPTIMIZER_SWITCH_SPLIT_MATERIALIZED (1ULL << 31)
|
||||
|
||||
#define OPTIMIZER_SWITCH_DEFAULT (OPTIMIZER_SWITCH_INDEX_MERGE | \
|
||||
OPTIMIZER_SWITCH_INDEX_MERGE_UNION | \
|
||||
@ -254,7 +254,7 @@
|
||||
OPTIMIZER_SWITCH_EXISTS_TO_IN | \
|
||||
OPTIMIZER_SWITCH_ORDERBY_EQ_PROP | \
|
||||
OPTIMIZER_SWITCH_COND_PUSHDOWN_FOR_DERIVED | \
|
||||
OPTIMIZER_SWITCH_SPLIT_GROUPING_DERIVED)
|
||||
OPTIMIZER_SWITCH_SPLIT_MATERIALIZED)
|
||||
|
||||
/*
|
||||
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
|
||||
|
@ -85,7 +85,6 @@ LEX_CSTRING distinct_key= {STRING_WITH_LEN("distinct_key")};
|
||||
|
||||
struct st_sargable_param;
|
||||
|
||||
static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
|
||||
static bool make_join_statistics(JOIN *join, List<TABLE_LIST> &leaves,
|
||||
DYNAMIC_ARRAY *keyuse);
|
||||
static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
@ -93,8 +92,6 @@ static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
uint tables, COND *conds,
|
||||
table_map table_map, SELECT_LEX *select_lex,
|
||||
SARGABLE_PARAM **sargables);
|
||||
static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
bool skip_unprefixed_keyparts);
|
||||
static int sort_keyuse(KEYUSE *a,KEYUSE *b);
|
||||
static bool are_tables_local(JOIN_TAB *jtab, table_map used_tables);
|
||||
static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
|
||||
@ -1125,7 +1122,6 @@ int JOIN::optimize()
|
||||
if (optimization_state != JOIN::NOT_OPTIMIZED)
|
||||
return FALSE;
|
||||
optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS;
|
||||
is_for_splittable_grouping_derived= false;
|
||||
res= optimize_inner();
|
||||
}
|
||||
if (!with_two_phase_optimization ||
|
||||
@ -1571,9 +1567,6 @@ int JOIN::optimize_stage2()
|
||||
if (subq_exit_fl)
|
||||
goto setup_subq_exit;
|
||||
|
||||
if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (thd->check_killed())
|
||||
DBUG_RETURN(1);
|
||||
|
||||
@ -1581,6 +1574,9 @@ int JOIN::optimize_stage2()
|
||||
if (get_best_combination())
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_WITH_KEYS))
|
||||
drop_unused_derived_keys();
|
||||
|
||||
@ -3671,6 +3667,10 @@ JOIN::destroy()
|
||||
cleanup_item_list(tmp_all_fields3);
|
||||
destroy_sj_tmp_tables(this);
|
||||
delete_dynamic(&keyuse);
|
||||
if (save_qep)
|
||||
delete(save_qep);
|
||||
if (ext_keyuses_for_splitting)
|
||||
delete(ext_keyuses_for_splitting);
|
||||
delete procedure;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@ -4124,6 +4124,12 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
|
||||
DBUG_EXECUTE("opt", print_keyuse_array(keyuse_array););
|
||||
}
|
||||
|
||||
for (s= stat; s < stat_end; s++)
|
||||
{
|
||||
if (s->table->is_splittable())
|
||||
s->add_keyuses_for_splitting();
|
||||
}
|
||||
|
||||
join->const_table_map= no_rows_const_tables;
|
||||
join->const_tables= const_count;
|
||||
eliminate_tables(join);
|
||||
@ -4597,9 +4603,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
|
||||
if (join->choose_subquery_plan(all_table_map & ~join->const_table_map))
|
||||
goto error;
|
||||
|
||||
if (join->improve_chosen_plan(join->thd))
|
||||
goto error;
|
||||
|
||||
DEBUG_SYNC(join->thd, "inside_make_join_statistics");
|
||||
|
||||
DBUG_RETURN(0);
|
||||
@ -4629,23 +4632,6 @@ error:
|
||||
keyuse Pointer to possible keys
|
||||
*****************************************************************************/
|
||||
|
||||
/// Used when finding key fields
|
||||
struct KEY_FIELD {
|
||||
Field *field;
|
||||
Item_bool_func *cond;
|
||||
Item *val; ///< May be empty if diff constant
|
||||
uint level;
|
||||
uint optimize;
|
||||
bool eq_func;
|
||||
/**
|
||||
If true, the condition this struct represents will not be satisfied
|
||||
when val IS NULL.
|
||||
*/
|
||||
bool null_rejecting;
|
||||
bool *cond_guard; /* See KEYUSE::cond_guard */
|
||||
uint sj_pred_no; /* See KEYUSE::sj_pred_no */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Merge new key definitions to old ones, remove those not used in both.
|
||||
@ -5296,7 +5282,7 @@ Item_func_ne::add_key_fields(JOIN *join, KEY_FIELD **key_fields,
|
||||
/*
|
||||
QQ: perhaps test for !is_local_field(args[1]) is not really needed here.
|
||||
Other comparison functions, e.g. Item_func_le, Item_func_gt, etc,
|
||||
do not have this test. See Item_bool_func2::add_key_field_optimize_op().
|
||||
do not have this test. See Item_bool_func2::add_key_fieldoptimize_op().
|
||||
Check with the optimizer team.
|
||||
*/
|
||||
if (is_local_field(args[0]) && !is_local_field(args[1]))
|
||||
@ -5479,6 +5465,7 @@ add_keyuse(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field,
|
||||
keyuse.null_rejecting= key_field->null_rejecting;
|
||||
keyuse.cond_guard= key_field->cond_guard;
|
||||
keyuse.sj_pred_no= key_field->sj_pred_no;
|
||||
keyuse.validity_ref= 0;
|
||||
return (insert_dynamic(keyuse_array,(uchar*) &keyuse));
|
||||
}
|
||||
|
||||
@ -5525,6 +5512,8 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
|
||||
{
|
||||
if (!field->can_optimize_hash_join(key_field->cond, key_field->val))
|
||||
return false;
|
||||
if (form->is_splittable())
|
||||
form->add_splitting_info_for_key_field(key_field);
|
||||
/*
|
||||
If a key use is extracted from an equi-join predicate then it is
|
||||
added not only as a key use for every index whose component can
|
||||
@ -5538,7 +5527,6 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array, KEY_FIELD *key_field)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
|
||||
JOIN_TAB *stat,COND *cond,table_map usable_tables)
|
||||
@ -5600,6 +5588,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
|
||||
keyuse.optimize= 0;
|
||||
keyuse.keypart_map= 0;
|
||||
keyuse.sj_pred_no= UINT_MAX;
|
||||
keyuse.validity_ref= 0;
|
||||
return insert_dynamic(keyuse_array,(uchar*) &keyuse);
|
||||
}
|
||||
|
||||
@ -5887,7 +5876,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
|
||||
Special treatment for ft-keys.
|
||||
*/
|
||||
|
||||
static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
bool skip_unprefixed_keyparts)
|
||||
{
|
||||
KEYUSE key_end, *prev, *save_pos, *use;
|
||||
@ -5956,7 +5945,7 @@ static bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
Update some values in keyuse for faster choose_plan() loop.
|
||||
*/
|
||||
|
||||
static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array)
|
||||
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array)
|
||||
{
|
||||
KEYUSE *end,*keyuse= dynamic_element(keyuse_array, 0, KEYUSE*);
|
||||
|
||||
@ -5997,7 +5986,6 @@ static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check for the presence of AGGFN(DISTINCT a) queries that may be subject
|
||||
to loose index scan.
|
||||
@ -6305,6 +6293,7 @@ best_access_path(JOIN *join,
|
||||
bool best_uses_jbuf= FALSE;
|
||||
MY_BITMAP *eq_join_set= &s->table->eq_join_set;
|
||||
KEYUSE *hj_start_key= 0;
|
||||
SplM_plan_info *spl_plan= 0;
|
||||
|
||||
disable_jbuf= disable_jbuf || idx == join->const_tables;
|
||||
|
||||
@ -6315,6 +6304,9 @@ best_access_path(JOIN *join,
|
||||
|
||||
loose_scan_opt.init(join, s, remaining_tables);
|
||||
|
||||
if (s->table->is_splittable())
|
||||
spl_plan= s->choose_best_splitting(record_count, remaining_tables);
|
||||
|
||||
if (s->keyuse)
|
||||
{ /* Use key if possible */
|
||||
KEYUSE *keyuse;
|
||||
@ -6379,6 +6371,7 @@ best_access_path(JOIN *join,
|
||||
2. we won't get two ref-or-null's
|
||||
*/
|
||||
if (!(remaining_tables & keyuse->used_tables) &&
|
||||
(!keyuse->validity_ref || *keyuse->validity_ref) &&
|
||||
s->access_from_tables_is_allowed(keyuse->used_tables,
|
||||
join->sjm_lookup_tables) &&
|
||||
!(ref_or_null_part && (keyuse->optimize &
|
||||
@ -6691,6 +6684,7 @@ best_access_path(JOIN *join,
|
||||
tmp += s->startup_cost;
|
||||
loose_scan_opt.check_ref_access_part2(key, start_key, records, tmp);
|
||||
} /* not ft_key */
|
||||
|
||||
if (tmp + 0.0001 < best_time - records/(double) TIME_FOR_COMPARE)
|
||||
{
|
||||
best_time= tmp + records/(double) TIME_FOR_COMPARE;
|
||||
@ -6878,6 +6872,7 @@ best_access_path(JOIN *join,
|
||||
pos->ref_depend_map= best_ref_depends_map;
|
||||
pos->loosescan_picker.loosescan_key= MAX_KEY;
|
||||
pos->use_join_buffer= best_uses_jbuf;
|
||||
pos->spl_plan= spl_plan;
|
||||
|
||||
loose_scan_opt.save_to_position(s, loose_scan_pos);
|
||||
|
||||
@ -8932,192 +8927,15 @@ JOIN_TAB *next_depth_first_tab(JOIN* join, JOIN_TAB* tab)
|
||||
return tab;
|
||||
}
|
||||
|
||||
static
|
||||
bool key_can_be_used_to_split_by_fields(KEY *key_info, uint used_key_parts,
|
||||
List<Field> &fields)
|
||||
{
|
||||
if (used_key_parts < fields.elements)
|
||||
return false;
|
||||
List_iterator_fast<Field> li(fields);
|
||||
Field *fld;
|
||||
KEY_PART_INFO *start= key_info->key_part;
|
||||
KEY_PART_INFO *end= start + fields.elements;
|
||||
while ((fld= li++))
|
||||
{
|
||||
KEY_PART_INFO *key_part;
|
||||
for (key_part= start; key_part < end; key_part++)
|
||||
{
|
||||
if (key_part->fieldnr == fld->field_index + 1)
|
||||
break;
|
||||
}
|
||||
if (key_part == end)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JOIN::check_for_splittable_grouping_derived(THD *thd)
|
||||
{
|
||||
partition_list= 0;
|
||||
st_select_lex_unit *unit= select_lex->master_unit();
|
||||
TABLE_LIST *derived= unit->derived;
|
||||
if (!optimizer_flag(thd, OPTIMIZER_SWITCH_SPLIT_GROUPING_DERIVED))
|
||||
return false;
|
||||
if (!(derived && derived->is_materialized_derived()))
|
||||
return false;
|
||||
if (unit->first_select()->next_select())
|
||||
return false;
|
||||
if (derived->prohibit_cond_pushdown)
|
||||
return false;
|
||||
if (derived->is_recursive_with_table())
|
||||
return false;
|
||||
if (group_list)
|
||||
{
|
||||
if (!select_lex->have_window_funcs())
|
||||
partition_list= group_list;
|
||||
}
|
||||
else if (select_lex->have_window_funcs() &&
|
||||
select_lex->window_specs.elements == 1)
|
||||
{
|
||||
partition_list=
|
||||
select_lex->window_specs.head()->partition_list->first;
|
||||
}
|
||||
if (!partition_list)
|
||||
return false;
|
||||
|
||||
ORDER *ord;
|
||||
TABLE *table= 0;
|
||||
key_map ref_keys;
|
||||
uint group_fields= 0;
|
||||
ref_keys.set_all();
|
||||
for (ord= partition_list; ord; ord= ord->next, group_fields++)
|
||||
{
|
||||
Item *ord_item= *ord->item;
|
||||
if (ord_item->real_item()->type() != Item::FIELD_ITEM)
|
||||
return false;
|
||||
Field *ord_field= ((Item_field *) (ord_item->real_item()))->field;
|
||||
if (!table)
|
||||
table= ord_field->table;
|
||||
else if (table != ord_field->table)
|
||||
return false;
|
||||
ref_keys.intersect(ord_field->part_of_key);
|
||||
}
|
||||
if (ref_keys.is_clear_all())
|
||||
return false;
|
||||
|
||||
uint i;
|
||||
List<Field> grouping_fields;
|
||||
List<Field> splitting_fields;
|
||||
List_iterator<Item> li(fields_list);
|
||||
for (ord= partition_list; ord; ord= ord->next)
|
||||
{
|
||||
Item *item;
|
||||
i= 0;
|
||||
while ((item= li++))
|
||||
{
|
||||
if ((*ord->item)->eq(item, 0))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
if (!item)
|
||||
return false;
|
||||
if (splitting_fields.push_back(derived->table->field[i], thd->mem_root))
|
||||
return false;
|
||||
Item_field *ord_field= (Item_field *)(item->real_item());
|
||||
if (grouping_fields.push_back(ord_field->field, thd->mem_root))
|
||||
return false;
|
||||
li.rewind();
|
||||
}
|
||||
|
||||
for (i= 0; i < table->s->keys; i++)
|
||||
{
|
||||
if (!(ref_keys.is_set(i)))
|
||||
continue;
|
||||
KEY *key_info= table->key_info + i;
|
||||
if (key_can_be_used_to_split_by_fields(key_info,
|
||||
table->actual_n_key_parts(key_info),
|
||||
grouping_fields))
|
||||
break;
|
||||
}
|
||||
if (i == table->s->keys)
|
||||
return false;
|
||||
|
||||
derived->table->splitting_fields= splitting_fields;
|
||||
is_for_splittable_grouping_derived= true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool JOIN::check_two_phase_optimization(THD *thd)
|
||||
{
|
||||
if (!check_for_splittable_grouping_derived(thd))
|
||||
return false;
|
||||
if (check_for_splittable_materialized())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Item *JOIN_TAB::get_splitting_cond_for_grouping_derived(THD *thd)
|
||||
{
|
||||
/* this is a stub */
|
||||
TABLE_LIST *derived= table->pos_in_table_list;
|
||||
st_select_lex *sel= derived->get_unit()->first_select();
|
||||
Item *cond= 0;
|
||||
table_map used_tables= OUTER_REF_TABLE_BIT;
|
||||
POSITION *pos= join->best_positions;
|
||||
for (; pos->table != this; pos++)
|
||||
{
|
||||
used_tables|= pos->table->table->map;
|
||||
}
|
||||
|
||||
if (!pos->key)
|
||||
return 0;
|
||||
|
||||
KEY *key_info= table->key_info + pos->key->key;
|
||||
if (!key_can_be_used_to_split_by_fields(key_info,
|
||||
key_info->user_defined_key_parts,
|
||||
table->splitting_fields))
|
||||
return 0;
|
||||
|
||||
create_ref_for_key(join, this, pos->key,
|
||||
false, used_tables);
|
||||
List<Item> cond_list;
|
||||
KEY_PART_INFO *start= key_info->key_part;
|
||||
KEY_PART_INFO *end= start + table->splitting_fields.elements;
|
||||
List_iterator_fast<Field> li(table->splitting_fields);
|
||||
Field *fld= li++;
|
||||
for (ORDER *ord= sel->join->partition_list; ord;
|
||||
ord= ord->next, fld= li++)
|
||||
{
|
||||
Item *left_item= (*ord->item)->build_clone(thd);
|
||||
uint i= 0;
|
||||
for (KEY_PART_INFO *key_part= start; key_part < end; key_part++, i++)
|
||||
{
|
||||
if (key_part->fieldnr == fld->field_index + 1)
|
||||
break;
|
||||
}
|
||||
Item *right_item= ref.items[i]->build_clone(thd);
|
||||
Item_func_eq *eq_item= 0;
|
||||
right_item= right_item->build_clone(thd);
|
||||
if (left_item && right_item)
|
||||
{
|
||||
right_item->walk(&Item::set_fields_as_dependent_processor,
|
||||
false, join->select_lex);
|
||||
right_item->update_used_tables();
|
||||
eq_item= new (thd->mem_root) Item_func_eq(thd, left_item, right_item);
|
||||
}
|
||||
if (!eq_item || cond_list.push_back(eq_item, thd->mem_root))
|
||||
return 0;
|
||||
}
|
||||
switch (cond_list.elements) {
|
||||
case 0: break;
|
||||
case 1: cond= cond_list.head(); break;
|
||||
default: cond= new (thd->mem_root) Item_cond_and(thd, cond_list);
|
||||
}
|
||||
if (cond)
|
||||
cond->fix_fields(thd,0);
|
||||
return cond;
|
||||
}
|
||||
|
||||
bool JOIN::inject_cond_into_where(Item *injected_cond)
|
||||
{
|
||||
Item *where_item= injected_cond;
|
||||
@ -9152,48 +8970,6 @@ bool JOIN::inject_cond_into_where(Item *injected_cond)
|
||||
|
||||
}
|
||||
|
||||
bool JOIN::push_splitting_cond_into_derived(THD *thd, Item *cond)
|
||||
{
|
||||
enum_reopt_result reopt_result= REOPT_NONE;
|
||||
table_map all_table_map= 0;
|
||||
for (JOIN_TAB *tab= join_tab;
|
||||
tab < join_tab + top_join_tab_count; tab++)
|
||||
all_table_map|= tab->table->map;
|
||||
reopt_result= reoptimize(cond, all_table_map & ~const_table_map, NULL);
|
||||
if (reopt_result == REOPT_ERROR)
|
||||
return true;
|
||||
if (inject_cond_into_where(cond))
|
||||
return true;
|
||||
if (cond->used_tables() & OUTER_REF_TABLE_BIT)
|
||||
{
|
||||
select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
|
||||
st_select_lex_unit *unit= select_lex->master_unit();
|
||||
unit->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JOIN::improve_chosen_plan(THD *thd)
|
||||
{
|
||||
for (JOIN_TAB *tab= join_tab + const_tables;
|
||||
tab < join_tab + table_count; tab++)
|
||||
{
|
||||
TABLE_LIST *tbl= tab->table->pos_in_table_list;
|
||||
if (tbl->is_materialized_derived())
|
||||
{
|
||||
st_select_lex *sel= tbl->get_unit()->first_select();
|
||||
JOIN *derived_join= sel->join;
|
||||
if (derived_join && derived_join->is_for_splittable_grouping_derived)
|
||||
{
|
||||
Item *cond= tab->get_splitting_cond_for_grouping_derived(thd);
|
||||
if (cond && derived_join->push_splitting_cond_into_derived(thd, cond))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static Item * const null_ptr= NULL;
|
||||
|
||||
@ -9262,6 +9038,9 @@ bool JOIN::get_best_combination()
|
||||
full_join=0;
|
||||
hash_join= FALSE;
|
||||
|
||||
if (fix_all_splittings_in_plan())
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
fix_semijoin_strategies_for_picked_join_order(this);
|
||||
|
||||
JOIN_TAB_RANGE *root_range;
|
||||
@ -9602,6 +9381,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
|
||||
do
|
||||
{
|
||||
if (!(~used_tables & keyuse->used_tables) &&
|
||||
(!keyuse->validity_ref || *keyuse->validity_ref) &&
|
||||
j->keyuse_is_valid_for_access_in_chosen_plan(join, keyuse))
|
||||
{
|
||||
if (are_tables_local(j, keyuse->val->used_tables()))
|
||||
@ -9672,6 +9452,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j,
|
||||
for (i=0 ; i < keyparts ; keyuse++,i++)
|
||||
{
|
||||
while (((~used_tables) & keyuse->used_tables) ||
|
||||
(keyuse->validity_ref && !(*keyuse->validity_ref)) ||
|
||||
!j->keyuse_is_valid_for_access_in_chosen_plan(join, keyuse) ||
|
||||
keyuse->keypart == NO_KEYPART ||
|
||||
(keyuse->keypart !=
|
||||
@ -17660,7 +17441,6 @@ err:
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void *Virtual_tmp_table::operator new(size_t size, THD *thd) throw()
|
||||
|
@ -73,9 +73,45 @@ typedef struct keyuse_t {
|
||||
*/
|
||||
uint sj_pred_no;
|
||||
|
||||
/*
|
||||
If this is NULL than KEYUSE is always enabled.
|
||||
Otherwise it points to the enabling flag for this keyuse (true <=> enabled)
|
||||
*/
|
||||
bool *validity_ref;
|
||||
|
||||
bool is_for_hash_join() { return is_hash_join_key_no(key); }
|
||||
} KEYUSE;
|
||||
|
||||
|
||||
struct KEYUSE_EXT: public KEYUSE
|
||||
{
|
||||
/*
|
||||
This keyuse can be used only when the partial join being extended
|
||||
contains the tables from this table map
|
||||
*/
|
||||
table_map needed_in_prefix;
|
||||
/* The enabling flag for keyuses usable for splitting */
|
||||
bool validity_var;
|
||||
};
|
||||
|
||||
/// Used when finding key fields
|
||||
struct KEY_FIELD {
|
||||
Field *field;
|
||||
Item_bool_func *cond;
|
||||
Item *val; ///< May be empty if diff constant
|
||||
uint level;
|
||||
uint optimize;
|
||||
bool eq_func;
|
||||
/**
|
||||
If true, the condition this struct represents will not be satisfied
|
||||
when val IS NULL.
|
||||
*/
|
||||
bool null_rejecting;
|
||||
bool *cond_guard; /* See KEYUSE::cond_guard */
|
||||
uint sj_pred_no; /* See KEYUSE::sj_pred_no */
|
||||
};
|
||||
|
||||
|
||||
#define NO_KEYPART ((uint)(-1))
|
||||
|
||||
class store_key;
|
||||
@ -201,6 +237,8 @@ class SJ_TMP_TABLE;
|
||||
class JOIN_TAB_RANGE;
|
||||
class AGGR_OP;
|
||||
class Filesort;
|
||||
struct SplM_plan_info;
|
||||
class SplM_opt_info;
|
||||
|
||||
typedef struct st_join_table {
|
||||
st_join_table() {}
|
||||
@ -614,8 +652,10 @@ typedef struct st_join_table {
|
||||
bool use_order() const; ///< Use ordering provided by chosen index?
|
||||
bool sort_table();
|
||||
bool remove_duplicates();
|
||||
Item *get_splitting_cond_for_grouping_derived(THD *thd);
|
||||
|
||||
void add_keyuses_for_splitting();
|
||||
SplM_plan_info *choose_best_splitting(double record_count,
|
||||
table_map remaining_tables);
|
||||
bool fix_splitting(SplM_plan_info *spl_plan, table_map remaining_tables);
|
||||
} JOIN_TAB;
|
||||
|
||||
|
||||
@ -920,6 +960,9 @@ typedef struct st_position
|
||||
Firstmatch_picker firstmatch_picker;
|
||||
LooseScan_picker loosescan_picker;
|
||||
Sj_materialization_picker sjmat_picker;
|
||||
|
||||
/* Info on splitting plan used at this position */
|
||||
SplM_plan_info *spl_plan;
|
||||
} POSITION;
|
||||
|
||||
typedef Bounds_checked_array<Item_null_result*> Item_null_array;
|
||||
@ -1053,11 +1096,13 @@ protected:
|
||||
/* Support for plan reoptimization with rewritten conditions. */
|
||||
enum_reopt_result reoptimize(Item *added_where, table_map join_tables,
|
||||
Join_plan_state *save_to);
|
||||
/* Choose a subquery plan for a table-less subquery. */
|
||||
bool choose_tableless_subquery_plan();
|
||||
|
||||
public:
|
||||
void save_query_plan(Join_plan_state *save_to);
|
||||
void reset_query_plan();
|
||||
void restore_query_plan(Join_plan_state *restore_from);
|
||||
/* Choose a subquery plan for a table-less subquery. */
|
||||
bool choose_tableless_subquery_plan();
|
||||
|
||||
public:
|
||||
JOIN_TAB *join_tab, **best_ref;
|
||||
@ -1415,9 +1460,14 @@ public:
|
||||
*/
|
||||
bool implicit_grouping;
|
||||
|
||||
bool is_for_splittable_grouping_derived;
|
||||
bool with_two_phase_optimization;
|
||||
ORDER *partition_list;
|
||||
|
||||
/* Saved execution plan for this join */
|
||||
Join_plan_state *save_qep;
|
||||
/* Info on splittability of the table materialized by this plan*/
|
||||
SplM_opt_info *spl_opt_info;
|
||||
/* Contains info on keyuses usable for splitting */
|
||||
Dynamic_array<KEYUSE_EXT> *ext_keyuses_for_splitting;
|
||||
|
||||
JOIN_TAB *sort_and_group_aggr_tab;
|
||||
|
||||
@ -1465,7 +1515,10 @@ public:
|
||||
need_distinct= 0;
|
||||
skip_sort_order= 0;
|
||||
with_two_phase_optimization= 0;
|
||||
is_for_splittable_grouping_derived= 0;
|
||||
save_qep= 0;
|
||||
spl_opt_info= 0;
|
||||
ext_keyuses_for_splitting= 0;
|
||||
spl_opt_info= 0;
|
||||
need_tmp= 0;
|
||||
hidden_group_fields= 0; /*safety*/
|
||||
error= 0;
|
||||
@ -1674,10 +1727,12 @@ public:
|
||||
const char *message);
|
||||
JOIN_TAB *first_breadth_first_tab() { return join_tab; }
|
||||
bool check_two_phase_optimization(THD *thd);
|
||||
bool check_for_splittable_grouping_derived(THD *thd);
|
||||
bool inject_cond_into_where(Item *injected_cond);
|
||||
bool push_splitting_cond_into_derived(THD *thd, Item *cond);
|
||||
bool improve_chosen_plan(THD *thd);
|
||||
bool check_for_splittable_materialized();
|
||||
void add_keyuses_for_splitting();
|
||||
bool inject_best_splitting_cond(table_map remaining_tables);
|
||||
bool fix_all_splittings_in_plan();
|
||||
|
||||
bool transform_in_predicates_into_in_subq(THD *thd);
|
||||
private:
|
||||
/**
|
||||
@ -2295,6 +2350,11 @@ bool open_tmp_table(TABLE *table);
|
||||
void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps);
|
||||
double prev_record_reads(POSITION *positions, uint idx, table_map found_ref);
|
||||
void fix_list_after_tbl_changes(SELECT_LEX *new_parent, List<TABLE_LIST> *tlist);
|
||||
double get_tmp_table_lookup_cost(THD *thd, double row_count, uint row_size);
|
||||
double get_tmp_table_write_cost(THD *thd, double row_count, uint row_size);
|
||||
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
|
||||
bool sort_and_filter_keyuse(THD *thd, DYNAMIC_ARRAY *keyuse,
|
||||
bool skip_unprefixed_keyparts);
|
||||
|
||||
struct st_cond_statistic
|
||||
{
|
||||
|
@ -2457,7 +2457,7 @@ export const char *optimizer_switch_names[]=
|
||||
"exists_to_in",
|
||||
"orderby_uses_equalities",
|
||||
"condition_pushdown_for_derived",
|
||||
"split_grouping_derived",
|
||||
"split_materialized",
|
||||
"default",
|
||||
NullS
|
||||
};
|
||||
|
14
sql/table.h
14
sql/table.h
@ -1033,6 +1033,8 @@ struct st_cond_statistic;
|
||||
/* Bitmap of table's fields */
|
||||
typedef Bitmap<MAX_FIELDS> Field_map;
|
||||
|
||||
class SplM_opt_info;
|
||||
|
||||
struct TABLE
|
||||
{
|
||||
TABLE() {} /* Remove gcc warning */
|
||||
@ -1312,7 +1314,13 @@ public:
|
||||
bool stats_is_read; /* Persistent statistics is read for the table */
|
||||
bool histograms_are_read;
|
||||
MDL_ticket *mdl_ticket;
|
||||
List<Field> splitting_fields;
|
||||
|
||||
/*
|
||||
This is used only for potentially splittable materialized tables and it
|
||||
points to the info used by the optimizer to apply splitting optimization
|
||||
*/
|
||||
SplM_opt_info *spl_opt_info;
|
||||
key_map keys_usable_for_splitting;
|
||||
|
||||
void init(THD *thd, TABLE_LIST *tl);
|
||||
bool fill_item_list(List<Item> *item_list) const;
|
||||
@ -1457,6 +1465,10 @@ public:
|
||||
bool with_cleanup);
|
||||
Field *find_field_by_name(LEX_CSTRING *str) const;
|
||||
bool export_structure(THD *thd, class Row_definition_list *defs);
|
||||
bool is_splittable() { return spl_opt_info != NULL; }
|
||||
void set_spl_opt_info(SplM_opt_info *spl_info);
|
||||
void deny_splitting();
|
||||
void add_splitting_info_for_key_field(struct KEY_FIELD *key_field);
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
drop table if exists t;
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
|
||||
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
|
||||
explain select x,id from t force index (x) where x=0 and id=0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
drop table if exists t;
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb;
|
||||
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
|
||||
explain select x,id from t force index (x) where x=0 and id=0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
drop table if exists t;
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb;
|
||||
insert into t values (0,0,0,0),(0,1,0,1);
|
||||
explain select c,a,b from t where c=0 and a=0 and b=1;
|
||||
|
@ -1,7 +1,7 @@
|
||||
drop table if exists t;
|
||||
select @@optimizer_switch;
|
||||
@@optimizer_switch
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_grouping_derived=on
|
||||
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on
|
||||
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb;
|
||||
insert into t values (0,0,0,0),(0,1,0,1);
|
||||
explain select c,a,b from t where c=0 and a=0 and b=1;
|
||||
|
Reference in New Issue
Block a user