summaryrefslogtreecommitdiff
path: root/mysql-test/t/innodb_ext_key.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-12-31 02:25:57 -0800
committerIgor Babaev <igor@askmonty.org>2011-12-31 02:25:57 -0800
commitb6b5f9fabe4866a8753e81e1f80593b645f35d8e (patch)
tree5ea9c96070eeb391ca24850300a800289d365f26 /mysql-test/t/innodb_ext_key.test
parent1c47e1ca0d9b2753b2f447df9efad2d14fbba74b (diff)
downloadmariadb-git-b6b5f9fabe4866a8753e81e1f80593b645f35d8e.tar.gz
Implementation of the MWL#247: Make the optimizer use extended keys.
The main patch. .
Diffstat (limited to 'mysql-test/t/innodb_ext_key.test')
-rw-r--r--mysql-test/t/innodb_ext_key.test294
1 files changed, 294 insertions, 0 deletions
diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test
new file mode 100644
index 00000000000..b8bab60f04b
--- /dev/null
+++ b/mysql-test/t/innodb_ext_key.test
@@ -0,0 +1,294 @@
+--source include/have_innodb.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3,t4;
+DROP DATABASE IF EXISTS dbt3_s001;
+--enable_warnings
+
+SET SESSION STORAGE_ENGINE='InnoDB';
+
+CREATE DATABASE dbt3_s001;
+
+use dbt3_s001;
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+--source include/dbt3_s001.inc
+--enable_warnings
+--enable_result_log
+--enable_query_log
+
+set @save_ext_key_optimizer_switch=@@optimizer_switch;
+
+set optimizer_switch='extended_keys=off';
+explain
+select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
+flush status;
+select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
+flush status;
+select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select count(*) from lineitem
+ where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
+flush status;
+select count(*) from lineitem
+ where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select count(*) from lineitem
+ where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
+flush status;
+select count(*) from lineitem
+ where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select count(*) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
+flush status;
+select count(*) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select count(*) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
+flush status;
+select count(*) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+flush status;
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+flush status;
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
+flush status;
+select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
+flush status;
+select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select min(l_orderkey) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+flush status;
+select min(l_orderkey) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select min(l_orderkey) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+flush status;
+select min(l_orderkey) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select max(l_linenumber) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey=130;
+flush status;
+select max(l_linenumber) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey=130;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select max(l_linenumber) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey=130;
+flush status;
+select max(l_linenumber) from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey=130;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey=130
+ or l_receiptdate='1992-07-01' and l_orderkey=5603;
+flush status;
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey=130
+ or l_receiptdate='1992-07-01' and l_orderkey=5603;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey=130
+ or l_receiptdate='1992-07-01' and l_orderkey=5603;
+flush status;
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey=130
+ or l_receiptdate='1992-07-01' and l_orderkey=5603;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+flush status;
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+flush status;
+select l_orderkey, l_linenumber
+ from lineitem use index (i_l_shipdate, i_l_receiptdate)
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+explain
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+flush status;
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+explain
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+flush status;
+select l_orderkey, l_linenumber from lineitem
+ where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
+ or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+--replace_column 9 #
+explain
+select max(l_orderkey) from lineitem
+ where l_partkey between 1 and 10 group by l_partkey;
+flush status;
+select max(l_orderkey) from lineitem
+ where l_partkey between 1 and 10 group by l_partkey;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+--replace_column 9 #
+explain
+select max(l_orderkey) from lineitem
+ where l_partkey between 1 and 10 group by l_partkey;
+flush status;
+select max(l_orderkey) from lineitem
+ where l_partkey between 1 and 10 group by l_partkey;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=off';
+--replace_column 9 #
+explain
+select max(l_orderkey) from lineitem
+ where l_suppkey in (1,4) group by l_suppkey;
+flush status;
+select max(l_orderkey) from lineitem
+ where l_suppkey in (1,4) group by l_suppkey;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+--replace_column 9 #
+explain
+select max(l_orderkey) from lineitem
+ where l_suppkey in (1,4) group by l_suppkey;
+flush status;
+select max(l_orderkey) from lineitem
+ where l_suppkey in (1,4) group by l_suppkey;
+show status like 'handler_read%';
+
+create index i_p_retailprice on part(p_retailprice);
+
+set optimizer_switch='extended_keys=off';
+--replace_column 9 #
+explain
+select o_orderkey, p_partkey
+ from part use index (i_p_retailprice),
+ lineitem use index (i_l_partkey), orders
+ where p_retailprice > 1100 and o_orderdate='1997-01-01'
+ and o_orderkey=l_orderkey and p_partkey=l_partkey;
+flush status;
+select o_orderkey, p_partkey
+ from part use index (i_p_retailprice),
+ lineitem use index (i_l_partkey), orders
+ where p_retailprice > 1100 and o_orderdate='1997-01-01'
+ and o_orderkey=l_orderkey and p_partkey=l_partkey;
+show status like 'handler_read%';
+
+set optimizer_switch='extended_keys=on';
+--replace_column 9 #
+explain
+select o_orderkey, p_partkey
+ from part use index (i_p_retailprice),
+ lineitem use index (i_l_partkey), orders
+ where p_retailprice > 1100 and o_orderdate='1997-01-01'
+ and o_orderkey=l_orderkey and p_partkey=l_partkey;
+flush status;
+select o_orderkey, p_partkey
+ from part use index (i_p_retailprice),
+ lineitem use index (i_l_partkey), orders
+ where p_retailprice > 1100 and o_orderdate='1997-01-01'
+ and o_orderkey=l_orderkey and p_partkey=l_partkey;
+show status like 'handler_read%';
+
+set optimizer_switch=@save_ext_key_optimizer_switch;
+
+DROP DATABASE dbt3_s001;
+
+SET SESSION STORAGE_ENGINE=DEFAULT;