Commit 515b9ad0 authored by Monty's avatar Monty Committed by Oleg Smirnov

Added EQ_REF chaining to the greedy_optimizer

MDEV-28073 Slow query performance in MariaDB when using many table

The idea is to prefer and chain EQ_REF tables (tables that uses an
unique key to find a row) when searching for the best table combination.
This significantly reduces row combinations that has to be examined.
This is optimization is enabled when setting optimizer_prune_level=2
(which is now default).

Implementation:
- optimizer_prune_level has a new level, 2, which enables EQ_REF
  optimization in addition to the pruning done by level 1.
  Level 2 is now default.
- Added JOIN::eq_ref_tables that contains bits of tables that could use
  potentially use EQ_REF access in the query.  This is calculated
  in sort_and_filter_keyuse()

Under optimizer_prune_level=2:
- When the greedy_optimizer notices that the preceding table was an
  EQ_REF table, it tries to add an EQ_REF table next. If an EQ_REF
  table exists, only this one will be considered at this level.
  We also collect all EQ_REF tables chained by the next levels and these
  are ignored on the starting level as we have already examined these.
  If no EQ_REF table exists, we continue as normal.

This optimization speeds up the greedy_optimizer combination test with
~25%

Other things:
- I ported the changes in MySQL 5.7 to greedy_optimizer.test to MariaDB
  to be able to ensure we can handle all cases that MySQL can do.
- I have run all tests with --mysqld=--optimizer_prune_level=1 to verify that
  there where no test changes.
parent 6e7376eb
# include/check_qep.inc
#
# SUMMARY
#
# Designed to be used together with include/expect_qep.inc
#
# $query should be assigned a select statement using
# straight_join to force the tables to be joined in most
# optimal order.
#
# expect_qep.inc will then store the estimated 'Last_query_cost'
# and total # 'Handler_read%' for this straight_joined query.
#
# We should then assign a non-straight_join'ed version of
# the same query to $query and execute it using
# 'include/check_qep.inc'. Its estimated cost and
# #handler_reads will then be verified against the
# previous straight_joined query.
#
# USAGE
#
# let $query= <select straight_join optimal statement>;
# --source include/expect_qep.inc
# let $query= <select statement>;
# --source include/check_qep.inc
#
# EXAMPLE
# t/greedy_optimizer.test
#
flush status;
eval EXPLAIN $query;
eval $query;
let $cost=
query_get_value(SHOW STATUS LIKE 'Last_query_cost', Value, 1);
--disable_warnings
let $reads=
`select sum(variable_value)
from information_schema.session_status
where VARIABLE_NAME like 'Handler_read%'`;
--enable_warnings
#echo Cost: $cost, Handler_reads: $reads;
if ($cost != $best_cost)
{ echo ### FAILED: Query_cost: $cost, expected: $best_cost ###;
}
# Difference in handler reads are ok as tables in MariaDB are sorted according
# to order in the query and the tables in greedy_optimizer.inc has reference to
# rows that does not exists, so different table orders will do different
# number of reads
if ($reads != $best_reads)
{ echo ### NOTE: Handler_reads: $reads, expected: $best_reads ###;
}
# include/execute_with_statistics.inc
#
# SUMMARY
#
# Explain and execute the select statment in $query.
# Then report 'Last_query_cost' estimate from the query
# optimizer and total number of 'Handler_read%' when the
# query was executed.
# Intended usage is to verify that there are not regressions
# in either calculated or actuall cost for $query.
#
# USAGE
#
# let $query= <select statement>;
# --source include/execute_with_statistics.inc
#
# EXAMPLE
# t/greedy_optimizer.test
#
eval EXPLAIN $query;
SHOW STATUS LIKE 'Last_query_cost';
FLUSH STATUS;
eval $query;
--disable_warnings
SELECT SUM(variable_value) AS Total_handler_reads
FROM information_schema.session_status
WHERE variable_name LIKE 'Handler_read%';
--enable_warnings
# include/expect_qep.inc
#
# SUMMARY
#
# Designed to be used together with include/check_qep.inc
#
# $query should be assigned a select statement using
# straight_join to force the tables to be joined in most
# optimal order.
#
# expect_qep.inc will then store the estimated 'Last_query_cost'
# and total # 'Handler_read%' for this straight_joined query.
#
# We should then assign a non-straight_join'ed version of
# the same query to $query and execute it using
# 'include/check_qep.inc'. Its estimated cost and
# #handler_reads will then be verified against the
# previous straight_joined query.
#
# USAGE
#
# let $query= <select straight_join optimal statement>;
# --source include/expect_qep.inc
# let $query= <select statement>;
# --source include/check_qep.inc
#
# EXAMPLE
# t/greedy_optimizer.test
#
flush status;
eval EXPLAIN $query;
eval $query;
let $best_cost=
query_get_value(SHOW STATUS LIKE 'Last_query_cost', Value, 1);
--disable_warnings
let $best_reads=
`select sum(variable_value)
from information_schema.session_status
where VARIABLE_NAME like 'Handler_read%'`;
--enable_warnings
#echo Expect, cost: $best_cost, Handler_reads: $best_reads;
This diff is collapsed.
This diff is collapsed.
......@@ -890,7 +890,7 @@ insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B;
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
show status like '%cost%';
show status like 'Last_query_cost';
Variable_name Value
Last_query_cost 4.016090
select 'The cost of accessing t1 (dont care if it changes' '^';
......@@ -904,7 +904,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE A eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
1 SIMPLE B eq_ref PRIMARY PRIMARY 4 test.A.b 1
show status like '%cost%';
show status like 'Last_query_cost';
Variable_name Value
Last_query_cost 28.016090
select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
......
......@@ -692,13 +692,13 @@ create table t2 (a int, b int, primary key(a));
insert into t2 select @v:=A.a+10*B.a, @v from t1 A, t1 B;
explain select * from t1;
show status like '%cost%';
show status like 'Last_query_cost';
select 'The cost of accessing t1 (dont care if it changes' '^';
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
explain select * from t1, t2 A, t2 B where A.a = t1.a and B.a=A.b;
show status like '%cost%';
show status like 'Last_query_cost';
select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
......
......@@ -1744,9 +1744,9 @@ ON t4.carrier = t1.carrier;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index package_id package_id 5 NULL 45 Using where; Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1
1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index
1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1 Using where
1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index
1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index
SELECT COUNT(*)
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id)
......
......@@ -1753,9 +1753,9 @@ ON t4.carrier = t1.carrier;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index package_id package_id 5 NULL 45 Using where; Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index
1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1 Using where
1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index
1 SIMPLE t3 ref package_id package_id 5 test.t2.package_id 1 Using index
SELECT COUNT(*)
FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
JOIN t3 ON t3.package_id = t1.id)
......
......@@ -437,15 +437,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where
1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 1 test.t1.a7 1
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index
1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t1.a5 1
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where
1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where
1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where; Using index
1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
......@@ -459,15 +459,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where
1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where
1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 1 test.t1.a7 1
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index
1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t1.a5 1
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where
1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where
1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where; Using index
1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
......
......@@ -706,8 +706,9 @@ The following specify which files/extra groups are read (specified before remain
Controls the heuristic(s) applied during query
optimization to prune less-promising partial plans from
the optimizer search space. Meaning: 0 - do not apply any
heuristic, thus perform exhaustive search; 1 - prune
plans based on number of retrieved rows
heuristic, thus perform exhaustive search: 1 - prune
plans based on cost and number of retrieved rows eq_ref:
2 - prune also if we find an eq_ref chain
--optimizer-search-depth=#
Maximum depth of search performed by the query optimizer.
Values larger than the number of relations in a query
......@@ -1662,7 +1663,7 @@ old-mode UTF8_IS_UTF8MB3
old-passwords FALSE
old-style-user-limits FALSE
optimizer-max-sel-arg-weight 32000
optimizer-prune-level 1
optimizer-prune-level 2
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=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on
......
This diff is collapsed.
......@@ -888,3 +888,4 @@ select left(trace, 100) from information_schema.optimizer_trace;
set optimizer_trace='enabled=off';
--echo # End of 10.6 tests
......@@ -203,23 +203,27 @@ explain select * from t1 where a=1 or b=1 {
"considered_execution_plans": [
{
"plan_prefix": [],
"table": "t1",
"best_access_path": {
"considered_access_paths": [
{
"access_type": "index_merge",
"resulting_rows": 2,
"cost": 2.484903732,
"chosen": true
"get_costs_for_tables": [
{
"best_access_path": {
"table": "t1",
"considered_access_paths": [
{
"access_type": "index_merge",
"resulting_rows": 2,
"cost": 2.484903732,
"chosen": true
}
],
"chosen_access_method": {
"type": "index_merge",
"records": 2,
"cost": 2.484903732,
"uses_join_buffering": false
}
}
],
"chosen_access_method": {
"type": "index_merge",
"records": 2,
"cost": 2.484903732,
"uses_join_buffering": false
}
}
]
},
{
"plan_prefix": [],
......
......@@ -202,37 +202,40 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"considered_execution_plans": [
{
"plan_prefix": [],
"table": "t1",
"best_access_path": {
"considered_access_paths": [
{
"access_type": "ref",
"index": "key1",
"used_range_estimates": true,
"rows": 1,
"cost": 1.125146475,
"chosen": true
},
{
"type": "scan",
"chosen": false,
"cause": "cost"
"get_costs_for_tables": [
{
"best_access_path": {
"table": "t1",
"considered_access_paths": [
{
"access_type": "ref",
"index": "key1",
"used_range_estimates": true,
"rows": 1,
"cost": 1.125146475,
"chosen": true
},
{
"type": "scan",
"chosen": false,
"cause": "cost"
}
],
"chosen_access_method": {
"type": "ref",
"records": 1,
"cost": 1.125146475,
"uses_join_buffering": false
}
}
],
"chosen_access_method": {
"type": "ref",
"records": 1,
"cost": 1.125146475,
"uses_join_buffering": false
}
}
]
},
{
"plan_prefix": [],
"table": "t1",
"rows_for_plan": 1,
"cost_for_plan": 1.325146475,
"pruned_by_hanging_leaf": true
"cost_for_plan": 1.325146475
}
]
},
......
......@@ -89,23 +89,27 @@ select * from db1.t1 {
"considered_execution_plans": [
{
"plan_prefix": [],
"table": "t1",
"best_access_path": {
"considered_access_paths": [
{
"access_type": "scan",
"resulting_rows": 3,
"cost": 2.005126953,
"chosen": true
"get_costs_for_tables": [
{
"best_access_path": {
"table": "t1",
"considered_access_paths": [
{
"access_type": "scan",
"resulting_rows": 3,
"cost": 2.005126953,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
"records": 3,
"cost": 2.005126953,
"uses_join_buffering": false
}
}
],
"chosen_access_method": {
"type": "scan",
"records": 3,
"cost": 2.005126953,
"uses_join_buffering": false
}
}
]
},
{
"plan_prefix": [],
......@@ -214,23 +218,27 @@ select * from db1.v1 {
"considered_execution_plans": [
{
"plan_prefix": [],
"table": "t1",
"best_access_path": {
"considered_access_paths": [
{
"access_type": "scan",
"resulting_rows": 3,
"cost": 2.005126953,
"chosen": true
"get_costs_for_tables": [
{
"best_access_path": {
"table": "t1",
"considered_access_paths": [
{
"access_type": "scan",
"resulting_rows": 3,
"cost": 2.005126953,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
"records": 3,
"cost": 2.005126953,
"uses_join_buffering": false
}
}
],
"chosen_access_method": {
"type": "scan",
"records": 3,
"cost": 2.005126953,
"uses_join_buffering": false
}
}
]
},
{
"plan_prefix": [],
......
......@@ -1257,8 +1257,8 @@ EXPLAIN EXTENDED
SELECT * FROM language, country, continent
WHERE country_group = lang_group AND lang_group IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE language ALL NULL NULL NULL NULL 6 0.00 Using where
1 SIMPLE country ALL NULL NULL NULL NULL 2 0.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE language ALL NULL NULL NULL NULL 6 16.67 Using where
1 SIMPLE country ALL NULL NULL NULL NULL 2 50.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE continent ALL NULL NULL NULL NULL 6 100.00 Using join buffer (incremental, BNL join)
Warnings:
Note 1003 select `test`.`language`.`lang_group` AS `lang_group`,`test`.`language`.`lang` AS `lang`,`test`.`country`.`code` AS `code`,`test`.`country`.`country_group` AS `country_group`,`test`.`continent`.`cont_group` AS `cont_group`,`test`.`continent`.`cont` AS `cont` from `test`.`language` join `test`.`country` join `test`.`continent` where `test`.`country`.`country_group` = `test`.`language`.`lang_group` and `test`.`language`.`lang_group` is null
......
......@@ -216,10 +216,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
1 SIMPLE orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (27%) Using where; Using rowid filter
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
......
......@@ -248,10 +248,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
select o_year,
sum(case when nation = 'UNITED STATES' then volume else 0 end) /
sum(volume) as mkt_share
......
......@@ -120,19 +120,19 @@ ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_FLDRS ( FOLDERID)
REFERENCES t3 (FOLDERID );
ALTER TABLE t3 ADD FOREIGN KEY FK_FLDRS_PRNTID ( PARENTID)
REFERENCES t3 (FOLDERID );
SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3_a.FOLDERID FROM t3 as t3_a WHERE t3_a.PARENTID IN(SELECT t3_b.FOLDERID FROM t3 as t3_b WHERE t3_b.PARENTID IN(SELECT t3_c.FOLDERID FROM t3 as t3_c WHERE t3_c.PARENTID IN(SELECT t3_d.FOLDERID FROM t3 as t3_d WHERE t3_d.PARENTID IN(SELECT t3_e.FOLDERID FROM t3 as t3_e WHERE t3_e.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3_e.FOLDERNAME = 'Level1') AND t3_d.FOLDERNAME = 'Level2') AND t3_c.FOLDERNAME = 'Level3') AND t3_b.FOLDERNAME = 'CopiedFolder') AND t3_a.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
DOCID DOCNAME DOCTYPEID FOLDERID AUTHOR CREATED TITLE SUBTITLE DOCABSTRACT PUBLISHDATE EXPIRATIONDATE LOCKEDBY STATUS PARENTDOCID REPID MODIFIED MODIFIER PUBLISHSTATUS ORIGINATOR DOCTYPENAME CONTENTSIZE MIMETYPE
c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff17444553544200 c373e9f5ad0796c0eca4444553544200 Goldilocks 2003-06-09 11:21:06 Title: Last Discussion NULL Setting new abstract and keeping doc checked out 2003-06-09 10:51:26 2003-06-09 10:51:26 NULL NULL NULL 03eea05112b845949f3fd03278b5fe43 2003-06-09 11:21:06 admin 0 NULL Discussion NULL NULL
EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3_a.FOLDERID FROM t3 as t3_a WHERE t3_a.PARENTID IN(SELECT t3_b.FOLDERID FROM t3 as t3_b WHERE t3_b.PARENTID IN(SELECT t3_c.FOLDERID FROM t3 as t3_c WHERE t3_c.PARENTID IN(SELECT t3_d.FOLDERID FROM t3 as t3_d WHERE t3_d.PARENTID IN(SELECT t3_e.FOLDERID FROM t3 as t3_e WHERE t3_e.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3_e.FOLDERNAME = 'Level1') AND t3_d.FOLDERNAME = 'Level2') AND t3_c.FOLDERNAME = 'Level3') AND t3_b.FOLDERNAME = 'CopiedFolder') AND t3_a.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL DDOCTYPEID_IDX,DFOLDERID_IDX NULL NULL NULL 9 Using where
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 34 test.t2.DOCTYPEID 1
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 34 test.t2.DOCID 1
1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t2.FOLDERID 1 Using where
1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where
1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where
1 PRIMARY t3 eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3.PARENTID 1 Using where
1 PRIMARY t3 ref|filter PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX FFOLDERID_IDX|CMFLDRPARNT_IDX 34|35 test.t3.PARENTID 1 (29%) Using where; Using rowid filter
1 PRIMARY t3_a eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t2.FOLDERID 1 Using where
1 PRIMARY t3_b eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_a.PARENTID 1 Using where
1 PRIMARY t3_c eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_b.PARENTID 1 Using where
1 PRIMARY t3_d eq_ref PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 test.t3_c.PARENTID 1 Using where
1 PRIMARY t3_e ref|filter PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX FFOLDERID_IDX|CMFLDRPARNT_IDX 34|35 test.t3_d.PARENTID 1 (29%) Using where; Using rowid filter
drop table t1, t2, t3, t4;
CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB;
INSERT INTO t1 VALUES (1),(2);
......
......@@ -148,9 +148,9 @@ ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_FLDRS ( FOLDERID)
ALTER TABLE t3 ADD FOREIGN KEY FK_FLDRS_PRNTID ( PARENTID)
REFERENCES t3 (FOLDERID );
SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3_a.FOLDERID FROM t3 as t3_a WHERE t3_a.PARENTID IN(SELECT t3_b.FOLDERID FROM t3 as t3_b WHERE t3_b.PARENTID IN(SELECT t3_c.FOLDERID FROM t3 as t3_c WHERE t3_c.PARENTID IN(SELECT t3_d.FOLDERID FROM t3 as t3_d WHERE t3_d.PARENTID IN(SELECT t3_e.FOLDERID FROM t3 as t3_e WHERE t3_e.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3_e.FOLDERNAME = 'Level1') AND t3_d.FOLDERNAME = 'Level2') AND t3_c.FOLDERNAME = 'Level3') AND t3_b.FOLDERNAME = 'CopiedFolder') AND t3_a.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3_a.FOLDERID FROM t3 as t3_a WHERE t3_a.PARENTID IN(SELECT t3_b.FOLDERID FROM t3 as t3_b WHERE t3_b.PARENTID IN(SELECT t3_c.FOLDERID FROM t3 as t3_c WHERE t3_c.PARENTID IN(SELECT t3_d.FOLDERID FROM t3 as t3_d WHERE t3_d.PARENTID IN(SELECT t3_e.FOLDERID FROM t3 as t3_e WHERE t3_e.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3_e.FOLDERNAME = 'Level1') AND t3_d.FOLDERNAME = 'Level2') AND t3_c.FOLDERNAME = 'Level3') AND t3_b.FOLDERNAME = 'CopiedFolder') AND t3_a.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
drop table t1, t2, t3, t4;
# End of 4.1 tests
......
......@@ -2404,6 +2404,21 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
set statement optimizer_prune_level=1 for explain SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
3 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
3 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
......
......@@ -2446,6 +2446,21 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
set statement optimizer_prune_level=1 for explain SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
t1.dispatch_group IN
(SELECT t2.ugroup
FROM t2, t3 t3_i
WHERE t2.ugroup = t3_i.sys_id AND
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
3 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
3 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
SELECT t1.assignment_group
FROM t1, t3
WHERE t1.assignment_group = t3.sys_id AND
......
......@@ -2163,6 +2163,7 @@ eval $q;
set optimizer_switch='materialization=on';
eval explain $q;
eval set statement optimizer_prune_level=1 for explain $q;
eval $q;
DROP TABLE t1,t2,t3;
......
SET @start_global_value = @@global.optimizer_prune_level;
SELECT @start_global_value;
@start_global_value
1
2
SET @start_session_value = @@session.optimizer_prune_level;
SELECT @start_session_value;
@start_session_value
1
2
'#--------------------FN_DYNVARS_115_01-------------------------#'
SET @@global.optimizer_prune_level = 0;
SET @@global.optimizer_prune_level = DEFAULT;
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
1
2
SET @@session.optimizer_prune_level = 0;
SET @@session.optimizer_prune_level = DEFAULT;
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
1
2
'#--------------------FN_DYNVARS_115_02-------------------------#'
SET @@global.optimizer_prune_level = DEFAULT;
SELECT @@global.optimizer_prune_level = 1;
@@global.optimizer_prune_level = 1
SELECT @@global.optimizer_prune_level = 2;
@@global.optimizer_prune_level = 2
1
SET @@session.optimizer_prune_level = DEFAULT;
SELECT @@session.optimizer_prune_level = 1;
@@session.optimizer_prune_level = 1
SELECT @@session.optimizer_prune_level = 2;
@@session.optimizer_prune_level = 2
1
'#--------------------FN_DYNVARS_115_03-------------------------#'
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
1
2
SET @@global.optimizer_prune_level = 0;
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
......@@ -38,6 +38,10 @@ SET @@global.optimizer_prune_level = 1;
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
1
SET @@global.optimizer_prune_level = 2;
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
2
SET @@global.optimizer_prune_level = TRUE;
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
......@@ -49,7 +53,7 @@ SELECT @@global.optimizer_prune_level;
'#--------------------FN_DYNVARS_115_04-------------------------#'
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
1
2
SET @@session.optimizer_prune_level = 0;
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
......@@ -58,6 +62,10 @@ SET @@session.optimizer_prune_level = 1;
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
1
SET @@session.optimizer_prune_level = 2;
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
2
SET @@session.optimizer_prune_level = TRUE;
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
......@@ -69,7 +77,7 @@ SELECT @@session.optimizer_prune_level;
'#------------------FN_DYNVARS_115_05-----------------------#'
SET @@global.optimizer_prune_level = ON;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
'Bug# 34840: Since it is a boolean variable, it should not give errors on 'ON' & 'OFF' values';
'Bug# 34840: Since it is not a boolean variable, it should give errors on 'ON' & 'OFF' values';
SET @@global.optimizer_prune_level = OFF;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@global.optimizer_prune_level = 'ONN';
......@@ -86,10 +94,16 @@ Warning 1292 Truncated incorrect optimizer_prune_level value: '-1024'
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
0
'Bug# 34840: Since it is a boolean variable, it should give errors on numeric values';
'Bug# 34840: Since it is not a boolean variable, it should no give errors on numeric values';
SET @@global.optimizer_prune_level = 65536;
Warnings:
Warning 1292 Truncated incorrect optimizer_prune_level value: '65536'
SET @@global.optimizer_prune_level = 3;
Warnings:
Warning 1292 Truncated incorrect optimizer_prune_level value: '3'
select @@global.optimizer_prune_level;
@@global.optimizer_prune_level
2
SET @@global.optimizer_prune_level = 65530.34;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
SET @@global.optimizer_prune_level = test;
......@@ -121,7 +135,7 @@ Warnings:
Warning 1292 Truncated incorrect optimizer_prune_level value: '65550'
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
1
2
SET @@session.optimizer_prune_level = test;
ERROR 42000: Incorrect argument type to variable 'optimizer_prune_level'
'#------------------FN_DYNVARS_115_06-----------------------#'
......@@ -164,8 +178,8 @@ ERROR 42S22: Unknown column 'optimizer_prune_level' in 'field list'
SET @@global.optimizer_prune_level = @start_global_value;
SELECT @@global.optimizer_prune_level;
@@global.optimizer_prune_level
1
2
SET @@session.optimizer_prune_level = @start_session_value;
SELECT @@session.optimizer_prune_level;
@@session.optimizer_prune_level
1
2
......@@ -2265,9 +2265,9 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_PRUNE_LEVEL
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search; 1 - prune plans based on number of retrieved rows
VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search: 1 - prune plans based on cost and number of retrieved rows eq_ref: 2 - prune also if we find an eq_ref chain
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1
NUMERIC_MAX_VALUE 2
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
......
......@@ -2435,9 +2435,9 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_PRUNE_LEVEL
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search; 1 - prune plans based on number of retrieved rows
VARIABLE_COMMENT Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search: 1 - prune plans based on cost and number of retrieved rows eq_ref: 2 - prune also if we find an eq_ref chain
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1
NUMERIC_MAX_VALUE 2
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
......
......@@ -60,10 +60,10 @@ SELECT @@session.optimizer_prune_level;
###########################################################
SET @@global.optimizer_prune_level = DEFAULT;
SELECT @@global.optimizer_prune_level = 1;
SELECT @@global.optimizer_prune_level = 2;
SET @@session.optimizer_prune_level = DEFAULT;
SELECT @@session.optimizer_prune_level = 1;
SELECT @@session.optimizer_prune_level = 2;
--echo '#--------------------FN_DYNVARS_115_03-------------------------#'
......@@ -77,6 +77,8 @@ SET @@global.optimizer_prune_level = 0;
SELECT @@global.optimizer_prune_level;
SET @@global.optimizer_prune_level = 1;
SELECT @@global.optimizer_prune_level;
SET @@global.optimizer_prune_level = 2;
SELECT @@global.optimizer_prune_level;
SET @@global.optimizer_prune_level = TRUE;
SELECT @@global.optimizer_prune_level;
SET @@global.optimizer_prune_level = FALSE;
......@@ -94,6 +96,8 @@ SET @@session.optimizer_prune_level = 0;
SELECT @@session.optimizer_prune_level;
SET @@session.optimizer_prune_level = 1;
SELECT @@session.optimizer_prune_level;
SET @@session.optimizer_prune_level = 2;
SELECT @@session.optimizer_prune_level;
SET @@session.optimizer_prune_level = TRUE;
SELECT @@session.optimizer_prune_level;
SET @@session.optimizer_prune_level = FALSE;
......@@ -107,7 +111,7 @@ SELECT @@session.optimizer_prune_level;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.optimizer_prune_level = ON;
--echo 'Bug# 34840: Since it is a boolean variable, it should not give errors on 'ON' & 'OFF' values';
--echo 'Bug# 34840: Since it is not a boolean variable, it should give errors on 'ON' & 'OFF' values';
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.optimizer_prune_level = OFF;
--Error ER_WRONG_TYPE_FOR_VAR
......@@ -122,9 +126,11 @@ SET @@global.optimizer_prune_level = FELSE;
SET @@global.optimizer_prune_level = -1024;
SELECT @@global.optimizer_prune_level;
--echo 'Bug# 34840: Since it is a boolean variable, it should give errors on numeric values';
--echo 'Bug# 34840: Since it is not a boolean variable, it should no give errors on numeric values';
SET @@global.optimizer_prune_level = 65536;
SET @@global.optimizer_prune_level = 3;
select @@global.optimizer_prune_level;
--Error ER_WRONG_TYPE_FOR_VAR
SET @@global.optimizer_prune_level = 65530.34;
--Error ER_WRONG_TYPE_FOR_VAR
......
......@@ -159,10 +159,8 @@ Json_writer& Json_writer::add_member(const char *name, size_t len)
auto is_uniq_key= emplaced.second;
if(!is_uniq_key)
{
#ifdef QQQ
sql_print_error("Duplicated key: %s\n", emplaced.first->c_str());
VALIDITY_ASSERT(is_uniq_key);
#endif /* QQQ */
}
}
#endif
......
......@@ -769,7 +769,7 @@ void JOIN::add_keyuses_for_splitting()
added_keyuse->validity_ref= &keyuse_ext->validity_var;
}
if (sort_and_filter_keyuse(thd, &keyuse, true))
if (sort_and_filter_keyuse(this, &keyuse, true))
goto err;
optimize_keyuse(this, &keyuse);
......
This diff is collapsed.
......@@ -1261,6 +1261,8 @@ class JOIN :public Sql_alloc
table_map outer_join;
/* Bitmap of tables used in the select list items */
table_map select_list_used_tables;
/* Tables that have a possiblity to use EQ_ref */
table_map eq_ref_tables;
table_map allowed_top_level_tables;
ha_rows send_records,found_records,join_examined_rows, accepted_rows;
......@@ -2432,7 +2434,7 @@ 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 sort_and_filter_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse,
bool skip_unprefixed_keyparts);
struct st_cond_statistic
......
......@@ -2736,9 +2736,10 @@ static Sys_var_ulong Sys_optimizer_prune_level(
"Controls the heuristic(s) applied during query optimization to prune "
"less-promising partial plans from the optimizer search space. "
"Meaning: 0 - do not apply any heuristic, thus perform exhaustive "
"search; 1 - prune plans based on number of retrieved rows",
"search: 1 - prune plans based on cost and number of retrieved rows "
"eq_ref: 2 - prune also if we find an eq_ref chain",
SESSION_VAR(optimizer_prune_level), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 1), DEFAULT(1), BLOCK_SIZE(1));
VALID_RANGE(0, 2), DEFAULT(2), BLOCK_SIZE(1));
static Sys_var_ulong Sys_optimizer_selectivity_sampling_limit(
"optimizer_selectivity_sampling_limit",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment