summaryrefslogtreecommitdiff
path: root/mysql-test/t/greedy_optimizer.test
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2004-05-10 15:48:50 +0300
committerunknown <timour@mysql.com>2004-05-10 15:48:50 +0300
commita51ba6133d2724d45f54ece233efca93e4d2393b (patch)
treedf3a799fcb71add098c537586a4dcd1f6ecd8577 /mysql-test/t/greedy_optimizer.test
parent4c56ede41c6d8148063df723e701281a860ce48e (diff)
downloadmariadb-git-a51ba6133d2724d45f54ece233efca93e4d2393b.tar.gz
Complete implementation of WL#1469 "Greedy algorithm to search for an optimal execution plan",
consisting of pos-review fixes and improvements. mysql-test/r/distinct.result: Adjusted to account for pre-sorting of tables before optimiziation. mysql-test/r/func_group.result: Adjusted to account for pre-sorting of tables before optimiziation. mysql-test/r/greedy_optimizer.result: - Adjusted to account for pre-sorting of tables before optimiziation. - Removed unnecessary test. - More comments. mysql-test/r/select.result: - Adjusted to account for pre-sorting of tables before optimiziation. mysql-test/t/greedy_optimizer.test: - Adjusted to account for pre-sorting of tables before optimiziation. - Removed unnecessary test. - More comments. sql/mysql_priv.h: Moved function print_plan() to sql_test.cc sql/sql_select.cc: - Simplified the recursion in best_extension_by_limited_search() and aligned it with its pseudo-code. - Renamed functions to better reflect their semantics. - Post-review changes of function specifications. - Moved function print_plan() to sql_test.cc. sql/sql_test.cc: Moved function print_plan() to sql_test.cc
Diffstat (limited to 'mysql-test/t/greedy_optimizer.test')
-rw-r--r--mysql-test/t/greedy_optimizer.test70
1 files changed, 32 insertions, 38 deletions
diff --git a/mysql-test/t/greedy_optimizer.test b/mysql-test/t/greedy_optimizer.test
index b6adc1cb26e..8fd5bbb022a 100644
--- a/mysql-test/t/greedy_optimizer.test
+++ b/mysql-test/t/greedy_optimizer.test
@@ -135,32 +135,39 @@ insert into t7 values (21,2,3,4,5,6);
# The actual test begins here
#
-# first check the default values for the optimizer paramters
+# Check the default values for the optimizer paramters
+
select @@plan_search_depth;
select @@heuristic;
--- These are all possible values for the parameters that control the optimizer
--- (total 8 combinations):
+-- This value swithes back to the old implementation of 'find_best()'
+-- set plan_search_depth=63; - old (independent of the heuristic)
+--
+-- These are the values for the parameters that control the greedy optimizer
+-- (total 6 combinations - 3 for plan_search_depth, 2 for heuristic):
--
--- set plan_search_depth=0; -- automatic
--- set plan_search_depth=1; -- min
--- set plan_search_depth=62; -- max - default
--- set plan_search_depth=63; -- old
--- select @@plan_search_depth;
+-- set plan_search_depth=0; - automatic
+-- set plan_search_depth=1; - min
+-- set plan_search_depth=62; - max (default)
--
--- set heuristic=0 -- exhaustive;
--- set heuristic=1 -- heuristic; -- default
--- select @@heuristic;
+-- set heuristic=0 - exhaustive;
+-- set heuristic=1 - heuristic; -- default
+
#
-# Compile some simple queries with all combinations of the query
-# optimizer parameters.
+# Compile several queries with all combinations of the query
+# optimizer parameters. Each test query has two variants, where
+# in the second variant the tables in the FROM clause are in
+# inverse order to the tables in the first variant.
+# Due to pre-sorting of tables before compilation, there should
+# be no difference in the plans for each two such query variants.
#
-set heuristic=0;
-select @@heuristic;
+# First, for reference compile the test queries with the 'old' optimization
+# procedure 'find_best'. Notice that 'find_best' does not depend on the
+# choice of heuristic.
-set plan_search_depth=0;
+set plan_search_depth=63;
select @@plan_search_depth;
-- 6-table join, chain
@@ -179,7 +186,13 @@ 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;
show status like 'Last_query_cost';
-set plan_search_depth=1;
+
+# Test the new optimization procedures
+
+set heuristic=0;
+select @@heuristic;
+
+set plan_search_depth=0;
select @@plan_search_depth;
-- 6-table join, chain
@@ -198,7 +211,7 @@ 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;
show status like 'Last_query_cost';
-set plan_search_depth=62;
+set plan_search_depth=1;
select @@plan_search_depth;
-- 6-table join, chain
@@ -217,7 +230,7 @@ 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;
show status like 'Last_query_cost';
-set plan_search_depth=63;
+set plan_search_depth=62;
select @@plan_search_depth;
-- 6-table join, chain
@@ -297,23 +310,4 @@ 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;
show status like 'Last_query_cost';
-set plan_search_depth=63;
-select @@plan_search_depth;
-
--- 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;
-show status like 'Last_query_cost';
-explain select t1.c11 from t7, t6, t5, t4, t3, t2, t1 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;
-show status like 'Last_query_cost';
--- 6-table join, star
-explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 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;
-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;
-show status like 'Last_query_cost';
--- 6-table join, clique
-explain select t1.c11 from t1, t2, t3, t4, t5, t6, t7 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';
-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';
-
drop table t1,t2,t3,t4,t5,t6,t7;