Commit 432b842e authored by timour@mysql.com's avatar timour@mysql.com

Better names for two system variables:

- heuristic => optimizer_prune_level
- plan_search_depth => optimizer_search_depth
parent 40f7f588
...@@ -108,15 +108,15 @@ insert into t7 values (18,2,3,4,5,6); ...@@ -108,15 +108,15 @@ insert into t7 values (18,2,3,4,5,6);
insert into t7 values (19,2,3,4,5,6); insert into t7 values (19,2,3,4,5,6);
insert into t7 values (20,2,3,4,5,6); insert into t7 values (20,2,3,4,5,6);
insert into t7 values (21,2,3,4,5,6); insert into t7 values (21,2,3,4,5,6);
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
62 62
select @@heuristic; select @@optimizer_prune_level;
@@heuristic @@optimizer_prune_level
1 1
set plan_search_depth=63; set optimizer_search_depth=63;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
63 63
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -190,13 +190,13 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -190,13 +190,13 @@ id select_type table type possible_keys key key_len ref rows Extra
show status like 'Last_query_cost'; show status like 'Last_query_cost';
Variable_name Value Variable_name Value
Last_query_cost 794.838037 Last_query_cost 794.838037
set heuristic=0; set optimizer_prune_level=0;
select @@heuristic; select @@optimizer_prune_level;
@@heuristic @@optimizer_prune_level
0 0
set plan_search_depth=0; set optimizer_search_depth=0;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
0 0
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -270,9 +270,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -270,9 +270,9 @@ id select_type table type possible_keys key key_len ref rows Extra
show status like 'Last_query_cost'; show status like 'Last_query_cost';
Variable_name Value Variable_name Value
Last_query_cost 274.419727 Last_query_cost 274.419727
set plan_search_depth=1; set optimizer_search_depth=1;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
1 1
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -346,9 +346,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -346,9 +346,9 @@ id select_type table type possible_keys key key_len ref rows Extra
show status like 'Last_query_cost'; show status like 'Last_query_cost';
Variable_name Value Variable_name Value
Last_query_cost 794.838037 Last_query_cost 794.838037
set plan_search_depth=62; set optimizer_search_depth=62;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
62 62
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -422,13 +422,13 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -422,13 +422,13 @@ id select_type table type possible_keys key key_len ref rows Extra
show status like 'Last_query_cost'; show status like 'Last_query_cost';
Variable_name Value Variable_name Value
Last_query_cost 274.419727 Last_query_cost 274.419727
set heuristic=1; set optimizer_prune_level=1;
select @@heuristic; select @@optimizer_prune_level;
@@heuristic @@optimizer_prune_level
1 1
set plan_search_depth=0; set optimizer_search_depth=0;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
0 0
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -502,9 +502,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -502,9 +502,9 @@ id select_type table type possible_keys key key_len ref rows Extra
show status like 'Last_query_cost'; show status like 'Last_query_cost';
Variable_name Value Variable_name Value
Last_query_cost 794.838037 Last_query_cost 794.838037
set plan_search_depth=1; set optimizer_search_depth=1;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
1 1
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -578,9 +578,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -578,9 +578,9 @@ id select_type table type possible_keys key key_len ref rows Extra
show status like 'Last_query_cost'; show status like 'Last_query_cost';
Variable_name Value Variable_name Value
Last_query_cost 794.838037 Last_query_cost 794.838037
set plan_search_depth=62; set optimizer_search_depth=62;
select @@plan_search_depth; select @@optimizer_search_depth;
@@plan_search_depth @@optimizer_search_depth
62 62
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
...@@ -137,21 +137,21 @@ insert into t7 values (21,2,3,4,5,6); ...@@ -137,21 +137,21 @@ insert into t7 values (21,2,3,4,5,6);
# Check the default values for the optimizer paramters # Check the default values for the optimizer paramters
select @@plan_search_depth; select @@optimizer_search_depth;
select @@heuristic; select @@optimizer_prune_level;
-- This value swithes back to the old implementation of 'find_best()' -- This value swithes back to the old implementation of 'find_best()'
-- set plan_search_depth=63; - old (independent of the heuristic) -- set optimizer_search_depth=63; - old (independent of the optimizer_prune_level)
-- --
-- These are the values for the parameters that control the greedy optimizer -- These are the values for the parameters that control the greedy optimizer
-- (total 6 combinations - 3 for plan_search_depth, 2 for heuristic): -- (total 6 combinations - 3 for optimizer_search_depth, 2 for optimizer_prune_level):
-- --
-- set plan_search_depth=0; - automatic -- set optimizer_search_depth=0; - automatic
-- set plan_search_depth=1; - min -- set optimizer_search_depth=1; - min
-- set plan_search_depth=62; - max (default) -- set optimizer_search_depth=62; - max (default)
-- --
-- set heuristic=0 - exhaustive; -- set optimizer_prune_level=0 - exhaustive;
-- set heuristic=1 - heuristic; -- default -- set optimizer_prune_level=1 - heuristic; -- default
# #
...@@ -167,8 +167,8 @@ select @@heuristic; ...@@ -167,8 +167,8 @@ select @@heuristic;
# procedure 'find_best'. Notice that 'find_best' does not depend on the # procedure 'find_best'. Notice that 'find_best' does not depend on the
# choice of heuristic. # choice of heuristic.
set plan_search_depth=63; set optimizer_search_depth=63;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
...@@ -189,11 +189,11 @@ show status like 'Last_query_cost'; ...@@ -189,11 +189,11 @@ show status like 'Last_query_cost';
# Test the new optimization procedures # Test the new optimization procedures
set heuristic=0; set optimizer_prune_level=0;
select @@heuristic; select @@optimizer_prune_level;
set plan_search_depth=0; set optimizer_search_depth=0;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
...@@ -211,8 +211,8 @@ show status like 'Last_query_cost'; ...@@ -211,8 +211,8 @@ show status like 'Last_query_cost';
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
show status like 'Last_query_cost'; show status like 'Last_query_cost';
set plan_search_depth=1; set optimizer_search_depth=1;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
...@@ -230,8 +230,8 @@ show status like 'Last_query_cost'; ...@@ -230,8 +230,8 @@ show status like 'Last_query_cost';
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
show status like 'Last_query_cost'; show status like 'Last_query_cost';
set plan_search_depth=62; set optimizer_search_depth=62;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
...@@ -250,11 +250,11 @@ explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and ...@@ -250,11 +250,11 @@ explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and
show status like 'Last_query_cost'; show status like 'Last_query_cost';
set heuristic=1; set optimizer_prune_level=1;
select @@heuristic; select @@optimizer_prune_level;
set plan_search_depth=0; set optimizer_search_depth=0;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
...@@ -272,8 +272,8 @@ show status like 'Last_query_cost'; ...@@ -272,8 +272,8 @@ show status like 'Last_query_cost';
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
show status like 'Last_query_cost'; show status like 'Last_query_cost';
set plan_search_depth=1; set optimizer_search_depth=1;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
...@@ -291,8 +291,8 @@ show status like 'Last_query_cost'; ...@@ -291,8 +291,8 @@ show status like 'Last_query_cost';
explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76; explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
show status like 'Last_query_cost'; show status like 'Last_query_cost';
set plan_search_depth=62; set optimizer_search_depth=62;
select @@plan_search_depth; select @@optimizer_search_depth;
-- 6-table join, chain -- 6-table join, chain
explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71; explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
......
...@@ -3777,8 +3777,8 @@ enum options_mysqld ...@@ -3777,8 +3777,8 @@ enum options_mysqld
OPT_TIME_FORMAT, OPT_TIME_FORMAT,
OPT_DATETIME_FORMAT, OPT_DATETIME_FORMAT,
OPT_LOG_QUERIES_NOT_USING_INDEXES, OPT_LOG_QUERIES_NOT_USING_INDEXES,
OPT_PLAN_SEARCH_DEPTH, OPT_OPTIMIZER_SEARCH_DEPTH,
OPT_HEURISTIC OPT_OPTIMIZER_PRUNE_LEVEL
}; };
...@@ -4403,11 +4403,6 @@ log and this option does nothing anymore.", ...@@ -4403,11 +4403,6 @@ log and this option does nothing anymore.",
"Use stopwords from this file instead of built-in list.", "Use stopwords from this file instead of built-in list.",
(gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR, (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"heuristic", OPT_HEURISTIC,
"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 rows and read time.",
(gptr*) &global_system_variables.heuristic,
(gptr*) &max_system_variables.heuristic,
0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0},
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
{"innodb_mirrored_log_groups", OPT_INNODB_MIRRORED_LOG_GROUPS, {"innodb_mirrored_log_groups", OPT_INNODB_MIRRORED_LOG_GROUPS,
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.", "Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
...@@ -4648,10 +4643,15 @@ The minimum value for this variable is 4096.", ...@@ -4648,10 +4643,15 @@ The minimum value for this variable is 4096.",
"If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.", "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.",
(gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG, (gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG,
REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0}, REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0},
{"plan_search_depth", OPT_PLAN_SEARCH_DEPTH, {"optimizer_prune_level", OPT_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.",
(gptr*) &global_system_variables.optimizer_prune_level,
(gptr*) &max_system_variables.optimizer_prune_level,
0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0},
{"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH,
"Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Smaller values than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value; if set to MAX_TABLES+2, the optimizer will switch to the original find_best (used for testing/comparison).", "Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Smaller values than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value; if set to MAX_TABLES+2, the optimizer will switch to the original find_best (used for testing/comparison).",
(gptr*) &global_system_variables.plan_search_depth, (gptr*) &global_system_variables.optimizer_search_depth,
(gptr*) &max_system_variables.plan_search_depth, (gptr*) &max_system_variables.optimizer_search_depth,
0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0},
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE, {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
"The size of the buffer that is allocated when preloading indexes", "The size of the buffer that is allocated when preloading indexes",
......
...@@ -160,7 +160,6 @@ sys_var_str sys_ft_boolean_syntax("ft_boolean_syntax", ...@@ -160,7 +160,6 @@ sys_var_str sys_ft_boolean_syntax("ft_boolean_syntax",
sys_update_ftb_syntax, sys_update_ftb_syntax,
sys_default_ftb_syntax, sys_default_ftb_syntax,
ft_boolean_syntax); ft_boolean_syntax);
sys_var_thd_ulong sys_heuristic("heuristic", &SV::heuristic);
sys_var_str sys_init_connect("init_connect", 0, sys_var_str sys_init_connect("init_connect", 0,
sys_update_init_connect, sys_update_init_connect,
sys_default_init_connect,0); sys_default_init_connect,0);
...@@ -263,8 +262,10 @@ sys_var_thd_ulong sys_net_retry_count("net_retry_count", ...@@ -263,8 +262,10 @@ sys_var_thd_ulong sys_net_retry_count("net_retry_count",
0, fix_net_retry_count); 0, fix_net_retry_count);
sys_var_thd_bool sys_new_mode("new", &SV::new_mode); sys_var_thd_bool sys_new_mode("new", &SV::new_mode);
sys_var_thd_bool sys_old_passwords("old_passwords", &SV::old_passwords); sys_var_thd_bool sys_old_passwords("old_passwords", &SV::old_passwords);
sys_var_thd_ulong sys_plan_search_depth("plan_search_depth", sys_var_thd_ulong sys_optimizer_prune_level("optimizer_prune_level",
&SV::plan_search_depth); &SV::optimizer_prune_level);
sys_var_thd_ulong sys_optimizer_search_depth("optimizer_search_depth",
&SV::optimizer_search_depth);
sys_var_thd_ulong sys_preload_buff_size("preload_buffer_size", sys_var_thd_ulong sys_preload_buff_size("preload_buffer_size",
&SV::preload_buff_size); &SV::preload_buff_size);
sys_var_thd_ulong sys_read_buff_size("read_buffer_size", sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
...@@ -491,7 +492,6 @@ sys_var *sys_variables[]= ...@@ -491,7 +492,6 @@ sys_var *sys_variables[]=
&sys_ft_boolean_syntax, &sys_ft_boolean_syntax,
&sys_foreign_key_checks, &sys_foreign_key_checks,
&sys_group_concat_max_len, &sys_group_concat_max_len,
&sys_heuristic,
&sys_identity, &sys_identity,
&sys_init_connect, &sys_init_connect,
&sys_init_slave, &sys_init_slave,
...@@ -540,7 +540,8 @@ sys_var *sys_variables[]= ...@@ -540,7 +540,8 @@ sys_var *sys_variables[]=
&sys_net_write_timeout, &sys_net_write_timeout,
&sys_new_mode, &sys_new_mode,
&sys_old_passwords, &sys_old_passwords,
&sys_plan_search_depth, &sys_optimizer_prune_level,
&sys_optimizer_search_depth,
&sys_preload_buff_size, &sys_preload_buff_size,
&sys_pseudo_thread_id, &sys_pseudo_thread_id,
&sys_query_alloc_block_size, &sys_query_alloc_block_size,
...@@ -750,6 +751,10 @@ struct show_var_st init_vars[]= { ...@@ -750,6 +751,10 @@ struct show_var_st init_vars[]= {
{sys_new_mode.name, (char*) &sys_new_mode, SHOW_SYS}, {sys_new_mode.name, (char*) &sys_new_mode, SHOW_SYS},
{sys_old_passwords.name, (char*) &sys_old_passwords, SHOW_SYS}, {sys_old_passwords.name, (char*) &sys_old_passwords, SHOW_SYS},
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG}, {"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
{sys_optimizer_prune_level.name, (char*) &sys_optimizer_prune_level,
SHOW_SYS},
{sys_optimizer_search_depth.name,(char*) &sys_optimizer_search_depth,
SHOW_SYS},
{"pid_file", (char*) pidfile_name, SHOW_CHAR}, {"pid_file", (char*) pidfile_name, SHOW_CHAR},
{"port", (char*) &mysqld_port, SHOW_INT}, {"port", (char*) &mysqld_port, SHOW_INT},
{sys_preload_buff_size.name, (char*) &sys_preload_buff_size, SHOW_SYS}, {sys_preload_buff_size.name, (char*) &sys_preload_buff_size, SHOW_SYS},
...@@ -817,8 +822,6 @@ struct show_var_st init_vars[]= { ...@@ -817,8 +822,6 @@ struct show_var_st init_vars[]= {
{"version_compile_machine", (char*) MACHINE_TYPE, SHOW_CHAR}, {"version_compile_machine", (char*) MACHINE_TYPE, SHOW_CHAR},
{sys_os.name, (char*) &sys_os, SHOW_SYS}, {sys_os.name, (char*) &sys_os, SHOW_SYS},
{sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS},
{sys_heuristic.name, (char*) &sys_heuristic, SHOW_SYS},
{sys_plan_search_depth.name,(char*) &sys_plan_search_depth, SHOW_SYS},
{NullS, NullS, SHOW_LONG} {NullS, NullS, SHOW_LONG}
}; };
......
...@@ -384,6 +384,8 @@ struct system_variables ...@@ -384,6 +384,8 @@ struct system_variables
ulong net_retry_count; ulong net_retry_count;
ulong net_wait_timeout; ulong net_wait_timeout;
ulong net_write_timeout; ulong net_write_timeout;
ulong optimizer_prune_level;
ulong optimizer_search_depth;
ulong preload_buff_size; ulong preload_buff_size;
ulong query_cache_type; ulong query_cache_type;
ulong read_buff_size; ulong read_buff_size;
...@@ -392,8 +394,6 @@ struct system_variables ...@@ -392,8 +394,6 @@ struct system_variables
ulong table_type; ulong table_type;
ulong tmp_table_size; ulong tmp_table_size;
ulong tx_isolation; ulong tx_isolation;
ulong heuristic;
ulong plan_search_depth;
/* Determines which non-standard SQL behaviour should be enabled */ /* Determines which non-standard SQL behaviour should be enabled */
ulong sql_mode; ulong sql_mode;
ulong default_week_format; ulong default_week_format;
......
...@@ -55,12 +55,12 @@ static void best_access_path(JOIN *join, JOIN_TAB *s, THD *thd, ...@@ -55,12 +55,12 @@ static void best_access_path(JOIN *join, JOIN_TAB *s, THD *thd,
double record_count, double read_time); double record_count, double read_time);
static void optimize_straight_join(JOIN *join, table_map join_tables); static void optimize_straight_join(JOIN *join, table_map join_tables);
static void greedy_search(JOIN *join, table_map remaining_tables, static void greedy_search(JOIN *join, table_map remaining_tables,
uint depth, uint heuristic); uint depth, uint prune_level);
static void best_extension_by_limited_search(JOIN *join, static void best_extension_by_limited_search(JOIN *join,
table_map remaining_tables, table_map remaining_tables,
uint idx, double record_count, uint idx, double record_count,
double read_time, uint depth, double read_time, uint depth,
uint heuristic); uint prune_level);
static uint determine_search_depth(JOIN* join); static uint determine_search_depth(JOIN* join);
static int join_tab_cmp(const void* ptr1, const void* ptr2); static int join_tab_cmp(const void* ptr1, const void* ptr2);
/* /*
...@@ -3063,8 +3063,8 @@ best_access_path(JOIN *join, ...@@ -3063,8 +3063,8 @@ best_access_path(JOIN *join,
static void static void
choose_plan(JOIN *join, table_map join_tables) choose_plan(JOIN *join, table_map join_tables)
{ {
uint search_depth= join->thd->variables.plan_search_depth; uint search_depth= join->thd->variables.optimizer_search_depth;
uint heuristic= join->thd->variables.heuristic; uint prune_level= join->thd->variables.optimizer_prune_level;
DBUG_ENTER("choose_plan"); DBUG_ENTER("choose_plan");
...@@ -3094,7 +3094,7 @@ choose_plan(JOIN *join, table_map join_tables) ...@@ -3094,7 +3094,7 @@ choose_plan(JOIN *join, table_map join_tables)
if (search_depth == 0) if (search_depth == 0)
/* Automatically determine a reasonable value for 'search_depth' */ /* Automatically determine a reasonable value for 'search_depth' */
search_depth= determine_search_depth(join); search_depth= determine_search_depth(join);
greedy_search(join, join_tables, search_depth, heuristic); greedy_search(join, join_tables, search_depth, prune_level);
} }
} }
...@@ -3245,7 +3245,7 @@ optimize_straight_join(JOIN *join, table_map join_tables) ...@@ -3245,7 +3245,7 @@ optimize_straight_join(JOIN *join, table_map join_tables)
for the query for the query
remaining_tables set of tables not included into the partial plan yet remaining_tables set of tables not included into the partial plan yet
search_depth controlls the exhaustiveness of the search search_depth controlls the exhaustiveness of the search
heuristic the pruning heuristics that should be applied during prune_level the pruning heuristics that should be applied during
search search
DESCRIPTION DESCRIPTION
...@@ -3315,7 +3315,7 @@ static void ...@@ -3315,7 +3315,7 @@ static void
greedy_search(JOIN *join, greedy_search(JOIN *join,
table_map remaining_tables, table_map remaining_tables,
uint search_depth, uint search_depth,
uint heuristic) uint prune_level)
{ {
double record_count= 1.0; double record_count= 1.0;
double read_time= 0.0; double read_time= 0.0;
...@@ -3334,7 +3334,7 @@ greedy_search(JOIN *join, ...@@ -3334,7 +3334,7 @@ greedy_search(JOIN *join,
/* Find the extension of the current QEP with the lowest cost */ /* Find the extension of the current QEP with the lowest cost */
join->best_read= DBL_MAX; join->best_read= DBL_MAX;
best_extension_by_limited_search(join, remaining_tables, idx, record_count, best_extension_by_limited_search(join, remaining_tables, idx, record_count,
read_time, search_depth, heuristic); read_time, search_depth, prune_level);
if (rem_size <= search_depth) if (rem_size <= search_depth)
{ {
...@@ -3398,7 +3398,7 @@ greedy_search(JOIN *join, ...@@ -3398,7 +3398,7 @@ greedy_search(JOIN *join,
read_time the cost of the best partial plan read_time the cost of the best partial plan
search_depth maximum depth of the recursion and thus size of the found search_depth maximum depth of the recursion and thus size of the found
optimal plan (0 < search_depth <= join->tables+1). optimal plan (0 < search_depth <= join->tables+1).
heuristic pruning heuristics that should be applied during optimization prune_level pruning heuristics that should be applied during optimization
(values: 0 = EXHAUSTIVE, 1 = PRUNE_BY_TIME_OR_ROWS) (values: 0 = EXHAUSTIVE, 1 = PRUNE_BY_TIME_OR_ROWS)
DESCRIPTION DESCRIPTION
...@@ -3482,7 +3482,7 @@ greedy_search(JOIN *join, ...@@ -3482,7 +3482,7 @@ greedy_search(JOIN *join,
When 'best_extension_by_limited_search' is called for the first time, When 'best_extension_by_limited_search' is called for the first time,
'join->best_read' must be set to the largest possible value (e.g. DBL_MAX). 'join->best_read' must be set to the largest possible value (e.g. DBL_MAX).
The actual implementation provides a way to optionally use pruning The actual implementation provides a way to optionally use pruning
heuristics (controlled by the parameter 'heuristic') to reduce the search heuristic (controlled by the parameter 'prune_level') to reduce the search
space by skipping some partial plans. space by skipping some partial plans.
The parameter 'search_depth' provides control over the recursion The parameter 'search_depth' provides control over the recursion
depth, and thus the size of the resulting optimal plan. depth, and thus the size of the resulting optimal plan.
...@@ -3498,7 +3498,7 @@ best_extension_by_limited_search(JOIN *join, ...@@ -3498,7 +3498,7 @@ best_extension_by_limited_search(JOIN *join,
double record_count, double record_count,
double read_time, double read_time,
uint search_depth, uint search_depth,
uint heuristic) uint prune_level)
{ {
THD *thd= join->thd; THD *thd= join->thd;
if (thd->killed) // Abort if (thd->killed) // Abort
...@@ -3543,7 +3543,7 @@ best_extension_by_limited_search(JOIN *join, ...@@ -3543,7 +3543,7 @@ best_extension_by_limited_search(JOIN *join,
Prune some less promising partial plans. This heuristic may miss Prune some less promising partial plans. This heuristic may miss
the optimal QEPs, thus it results in a non-exhaustive search. the optimal QEPs, thus it results in a non-exhaustive search.
*/ */
if (heuristic == 1) if (prune_level == 1)
{ {
if (best_record_count > current_record_count || if (best_record_count > current_record_count ||
best_read_time > current_read_time || best_read_time > current_read_time ||
...@@ -3563,7 +3563,7 @@ best_extension_by_limited_search(JOIN *join, ...@@ -3563,7 +3563,7 @@ best_extension_by_limited_search(JOIN *join,
else else
{ {
DBUG_EXECUTE("opt", print_plan(join, read_time, record_count, idx, DBUG_EXECUTE("opt", print_plan(join, read_time, record_count, idx,
"prune_by_heuristic");); "pruned_by_heuristic"););
continue; continue;
} }
} }
...@@ -3577,7 +3577,7 @@ best_extension_by_limited_search(JOIN *join, ...@@ -3577,7 +3577,7 @@ best_extension_by_limited_search(JOIN *join,
current_record_count, current_record_count,
current_read_time, current_read_time,
search_depth - 1, search_depth - 1,
heuristic); prune_level);
if (thd->killed) if (thd->killed)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
swap(JOIN_TAB*, join->best_ref[idx], *pos); swap(JOIN_TAB*, join->best_ref[idx], *pos);
......
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