summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2022-10-04 16:16:06 +0300
committerMonty <monty@mariadb.org>2022-10-04 21:46:44 +0300
commit30f3d767ef4a8789860452127d8e04b92fadaabc (patch)
tree4a2c0b88479e3812e98bbbe849b3123f4cc0dd75
parenta35f715f440eb9ce93e4245cb1e4e5bc6f6972a2 (diff)
downloadmariadb-git-10.7-selectivity.tar.gz
Added test cases for preceding test10.7-selectivity
This includes all test changes from "Changing all cost calculation to be given in milliseconds" and forwards
-rw-r--r--mysql-test/include/analyze-format.inc2
-rw-r--r--mysql-test/include/common-tests.inc20
-rw-r--r--mysql-test/main/analyze_stmt_orderby.result6
-rw-r--r--mysql-test/main/compress.result19
-rw-r--r--mysql-test/main/costs.result42
-rw-r--r--mysql-test/main/cte_nonrecursive.result14
-rw-r--r--mysql-test/main/cte_recursive.result43
-rw-r--r--mysql-test/main/delete.result9
-rw-r--r--mysql-test/main/delete.test7
-rw-r--r--mysql-test/main/delete_innodb.result2
-rw-r--r--mysql-test/main/derived.result2
-rw-r--r--mysql-test/main/derived_split_innodb.result24
-rw-r--r--mysql-test/main/except.result12
-rw-r--r--mysql-test/main/explain_json.test7
-rw-r--r--mysql-test/main/fulltext.result7
-rw-r--r--mysql-test/main/fulltext.test2
-rw-r--r--mysql-test/main/func_group.result8
-rw-r--r--mysql-test/main/func_group_innodb.result6
-rw-r--r--mysql-test/main/func_group_innodb.test2
-rw-r--r--mysql-test/main/func_in.result2
-rw-r--r--mysql-test/main/greedy_optimizer.result260
-rw-r--r--mysql-test/main/group_min_max.result24
-rw-r--r--mysql-test/main/group_min_max.test1
-rw-r--r--mysql-test/main/ignored_index.result14
-rw-r--r--mysql-test/main/ignored_index.test8
-rw-r--r--mysql-test/main/index_intersect.result274
-rw-r--r--mysql-test/main/information_schema.result1
-rw-r--r--mysql-test/main/innodb_ext_key,off.rdiff36
-rw-r--r--mysql-test/main/innodb_ext_key.result25
-rw-r--r--mysql-test/main/innodb_ext_key.test16
-rw-r--r--mysql-test/main/innodb_mysql_lock2.test1
-rw-r--r--mysql-test/main/invisible_field_debug.result6
-rw-r--r--mysql-test/main/join_nested.result14
-rw-r--r--mysql-test/main/join_outer.result2
-rw-r--r--mysql-test/main/key.result6
-rw-r--r--mysql-test/main/key_cache.result20
-rw-r--r--mysql-test/main/key_cache.test12
-rw-r--r--mysql-test/main/myisam.result13
-rw-r--r--mysql-test/main/myisam.test1
-rw-r--r--mysql-test/main/mysqld--help.result45
-rw-r--r--mysql-test/main/named_pipe.result19
-rw-r--r--mysql-test/main/opt_trace.result3524
-rw-r--r--mysql-test/main/opt_trace.test65
-rw-r--r--mysql-test/main/opt_trace_index_merge.result122
-rw-r--r--mysql-test/main/opt_trace_index_merge_innodb.result36
-rw-r--r--mysql-test/main/opt_trace_security.result36
-rw-r--r--mysql-test/main/opt_trace_selectivity.result36
-rw-r--r--mysql-test/main/opt_trace_ucs2.result2
-rw-r--r--mysql-test/main/optimizer_costs.result340
-rw-r--r--mysql-test/main/optimizer_costs.test187
-rw-r--r--mysql-test/main/optimizer_costs2-master.opt1
-rw-r--r--mysql-test/main/optimizer_costs2.result8
-rw-r--r--mysql-test/main/optimizer_costs2.test6
-rw-r--r--mysql-test/main/order_by.result168
-rw-r--r--mysql-test/main/order_by.test17
-rw-r--r--mysql-test/main/partition.result4
-rw-r--r--mysql-test/main/partition_pruning.result40
-rw-r--r--mysql-test/main/partition_range.result69
-rw-r--r--mysql-test/main/partition_range.test31
-rw-r--r--mysql-test/main/pool_of_threads.result19
-rw-r--r--mysql-test/main/range_vs_index_merge.result57
-rw-r--r--mysql-test/main/range_vs_index_merge.test12
-rw-r--r--mysql-test/main/range_vs_index_merge_innodb.result72
-rw-r--r--mysql-test/main/rowid_filter.result394
-rw-r--r--mysql-test/main/rowid_filter.test2
-rw-r--r--mysql-test/main/show_explain.result2
-rw-r--r--mysql-test/main/ssl.result19
-rw-r--r--mysql-test/main/ssl_compress.result19
-rw-r--r--mysql-test/main/status.result20
-rw-r--r--mysql-test/main/subselect.result86
-rw-r--r--mysql-test/main/subselect.test39
-rw-r--r--mysql-test/main/subselect_mat_cost.result49
-rw-r--r--mysql-test/main/subselect_mat_cost.test31
-rw-r--r--mysql-test/main/subselect_no_semijoin.result87
-rw-r--r--mysql-test/suite/innodb_fts/t/fulltext.test2
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_embedded.result60
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result60
77 files changed, 4250 insertions, 2506 deletions
diff --git a/mysql-test/include/analyze-format.inc b/mysql-test/include/analyze-format.inc
index 7e18524e44e..59d3426a43b 100644
--- a/mysql-test/include/analyze-format.inc
+++ b/mysql-test/include/analyze-format.inc
@@ -1,3 +1,3 @@
# The time on ANALYSE FORMAT=JSON is rather variable
---replace_regex /("(r_total_time_ms|r_table_time_ms|r_other_time_ms|r_buffer_size|r_filling_time_ms)": )[^, \n]*/\1"REPLACED"/
+--replace_regex /("(r_total_time_ms|r_table_time_ms|r_other_time_ms|r_buffer_size|r_filling_time_ms|r_unpack_time_ms)": )[^, \n]*/\1"REPLACED"/
diff --git a/mysql-test/include/common-tests.inc b/mysql-test/include/common-tests.inc
index 9c6b29858c8..9b54b049f8b 100644
--- a/mysql-test/include/common-tests.inc
+++ b/mysql-test/include/common-tests.inc
@@ -13,6 +13,11 @@
drop table if exists t1,t2,t3,t4;
--enable_warnings
+# We have to use Aria instead of MyISAM as MyISAM has a very high row
+# access cost which causes some tests to use use join_cache instead of eq_ref
+
+set @@default_storage_engine="aria";
+
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -1429,7 +1434,7 @@ set tmp_memory_table_size=default;
select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10;
#
-# A big order by that should trigger a merge in filesort
+# A big order by that should traigger a merge in filesort
#
select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2;
@@ -1446,9 +1451,9 @@ select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr orde
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
-#
-# Some test with ORDER BY and limit
-#
+--echo #
+--echo # Some test with ORDER BY and limit
+--echo #
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
@@ -1501,7 +1506,7 @@ create table t4 (
companyname char(30) NOT NULL default '',
PRIMARY KEY (companynr),
UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
+) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
--disable_query_log
INSERT INTO t4 (companynr, companyname) VALUES (29,'company 1');
@@ -1555,8 +1560,9 @@ explain select companynr,companyname from t2 left join t4 using (companynr) wher
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
delete from t2 where fld1=999999;
-#
-# Test left join optimization
+--echo #
+--echo # Test left join optimization
+--echo #
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result
index 11736c47a49..78e971bd7af 100644
--- a/mysql-test/main/analyze_stmt_orderby.result
+++ b/mysql-test/main/analyze_stmt_orderby.result
@@ -441,7 +441,8 @@ ANALYZE
"buffer_size": "65",
"join_type": "BNL",
"attached_condition": "t3.a = t0.a",
- "r_filtered": 10
+ "r_filtered": 10,
+ "r_unpack_time_ms": "REPLACED"
}
}
}
@@ -516,7 +517,8 @@ ANALYZE
"buffer_size": "119",
"join_type": "BNL",
"attached_condition": "t5.a = t6.a",
- "r_filtered": 21.42857143
+ "r_filtered": 21.42857143,
+ "r_unpack_time_ms": "REPLACED"
}
}
}
diff --git a/mysql-test/main/compress.result b/mysql-test/main/compress.result
index 24979346149..f5c85d3eb6f 100644
--- a/mysql-test/main/compress.result
+++ b/mysql-test/main/compress.result
@@ -6,6 +6,7 @@ select * from information_schema.session_status where variable_name= 'COMPRESSIO
VARIABLE_NAME VARIABLE_VALUE
COMPRESSION ON
drop table if exists t1,t2,t3,t4;
+set @@default_storage_engine="aria";
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -606,6 +607,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
+#
+# Some test with ORDER BY and limit
+#
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
@@ -1295,7 +1299,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
PRIMARY KEY (companynr),
UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
+) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
companynr companyname
00 Unknown
@@ -1385,6 +1389,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
+#
+# Test left join optimization
+#
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
@@ -1399,15 +1406,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1423,11 +1430,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/main/costs.result b/mysql-test/main/costs.result
index 879d586790b..27ce1cbbfb0 100644
--- a/mysql-test/main/costs.result
+++ b/mysql-test/main/costs.result
@@ -7,11 +7,11 @@ insert into t1 values(20,2,2,2,2),(21,3,4,5,6);
explain select sum(e) as "table_scan" from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 12
-Last_query_cost 5.500000
+Last_query_cost 0.012556
explain select sum(a) as "index scan" from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 12 Using index
-Last_query_cost 3.202929
+Last_query_cost 0.007441
#
# Range scans should be used if we don't examine all rows in the table
#
@@ -21,71 +21,71 @@ id select_type table type possible_keys key key_len ref rows Extra
Last_query_cost 0.000000
explain select count(*) from t1 where a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 12 Using where; Using index
-Last_query_cost 3.202929
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 12 Using where; Using index
+Last_query_cost 0.002795
explain select count(*) from t1 where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 12 Using where; Using index
-Last_query_cost 3.202929
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 12 Using where; Using index
+Last_query_cost 0.002795
explain select count(*) from t1 where a > 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 11 Using where; Using index
-Last_query_cost 2.997685
+Last_query_cost 0.002665
#
# Shorter indexes are prefered over longer indexs
#
explain select sum(a+b) from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL ba 9 NULL 12 Using index
-Last_query_cost 3.204394
+Last_query_cost 0.007441
explain select count(*) from t1 where b between 5 and 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range ba,bda ba 5 NULL 6 Using where; Using index
-Last_query_cost 1.872197
+Last_query_cost 0.002015
explain select sum(b+c) from t1 where b between 5 and 6 and c between 5 and 6;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range ba,bda,cba,cb cb 10 NULL 2 Using where; Using index
-Last_query_cost 0.970781
+1 SIMPLE t1 range ba,bda,cba,cb cba 10 NULL 2 Using where; Using index
+Last_query_cost 0.001494
# Cost of 'd' should be slightly smaller as key 'ba' is longer than 'd'
explain select count(*) from t1 where b > 6;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range ba,bda ba 5 NULL 5 Using where; Using index
-Last_query_cost 1.646831
+Last_query_cost 0.001885
explain select count(*) from t1 where d > 6;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range d d 5 NULL 5 Using where; Using index
-Last_query_cost 1.646343
+Last_query_cost 0.001885
#
# Check covering index usage
#
explain select a,b,c from t1 where a=b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL cba 14 NULL 12 Using where; Using index
-Last_query_cost 3.205859
+Last_query_cost 0.007441
#
# Prefer ref keys over ranges
#
explain select count(*) from t1 where b=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref ba,bda ba 5 const 2 Using index
-Last_query_cost 0.950732
+Last_query_cost 0.001059
explain select count(*) from t1 where b=2 and c=2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref ba,bda,cba,cb cb 10 const,const 2 Using index
-Last_query_cost 0.950781
+1 SIMPLE t1 ref ba,bda,cba,cb cba 10 const,const 2 Using index
+Last_query_cost 0.001059
explain select count(*) from t1 where b=3 and c between 3 and 4;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range ba,bda,cba,cb cb 10 NULL 2 Using where; Using index
-Last_query_cost 0.970781
+1 SIMPLE t1 range ba,bda,cba,cb cba 10 NULL 2 Using where; Using index
+Last_query_cost 0.001494
#
# Prefer eq keys over ref keys
#
explain select a,b,e from t1 where a=10 or a=11;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
-Last_query_cost 2.520488
+Last_query_cost 0.003090
explain select a,b,e from t1 where d=10 or d=11;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range d d 5 NULL 2 Using index condition
-Last_query_cost 2.520537
+Last_query_cost 0.003090
drop table t1;
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index 58418cc7d9d..cadaa5f819a 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -150,16 +150,14 @@ explain
with t as (select a from t1 where a<5)
select * from t2 where c in (select a from t);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 4
-1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
-3 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t2); Using join buffer (flat, BNL join)
explain
select * from t2
where c in (select a from (select a from t1 where a<5) as t);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 4
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
-2 MATERIALIZED t1 ALL NULL NULL NULL NULL 8 Using where
+1 PRIMARY t2 ALL NULL NULL NULL NULL 4 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; FirstMatch(t2); Using join buffer (flat, BNL join)
# materialized t is used in a subquery
with t as (select count(*) as c from t1 where b >= 'c' group by a)
select * from t2 where c in (select c from t);
@@ -2300,14 +2298,14 @@ WHERE col1 IN ( SELECT col FROM t );
SELECT * FROM tt;
col2
2018-10-01
-2018-10-01
2017-10-01
+2018-10-01
SELECT t4.col1
FROM tt, t4
WHERE t4.col2 = tt.col2 AND t4.col1 IN ( SELECT col FROM t );
col1
-8
4
+8
DROP TABLE t,tt;
CALL SP1();
col1
diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result
index 45390262b47..5441843d9a6 100644
--- a/mysql-test/main/cte_recursive.result
+++ b/mysql-test/main/cte_recursive.result
@@ -692,10 +692,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived3> ref key0 key0 5 c.h_id 2 100.00
1 PRIMARY <derived3> ref key0 key0 5 c.w_id 2 100.00
3 DERIVED folks ALL NULL NULL NULL NULL 12 100.00 Using where
-4 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00
-4 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (flat, BNL join)
-5 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00
-5 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 75.00 Using where; Using join buffer (flat, BNL join)
+4 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where
+4 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 2 100.00
+5 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where
+5 RECURSIVE UNION <derived2> ref key0 key0 5 test.p.id 2 100.00
NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL
2 DERIVED <derived3> ALL NULL NULL NULL NULL 12 100.00 Using where
Warnings:
@@ -3785,8 +3785,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY <derived3> ref key0 key0 23 test.t1.a1 1 FirstMatch(t1)
3 DERIVED t2 const PRIMARY PRIMARY 22 const 1 Using index
-4 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 2 Using where
-4 RECURSIVE UNION tt2 ref b1 b1 23 cte.a2 2
+4 RECURSIVE UNION tt2 ALL b1 NULL NULL NULL 14 Using where
+4 RECURSIVE UNION <derived3> ref key0 key0 23 test.tt2.b1 1
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
analyze format=json select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
@@ -3864,28 +3864,29 @@ ANALYZE
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
- "table_name": "<derived3>",
+ "table_name": "tt2",
"access_type": "ALL",
+ "possible_keys": ["b1"],
"r_loops": 1,
- "rows": 2,
- "r_rows": 1,
+ "rows": 14,
+ "r_rows": 14,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
- "attached_condition": "cte.a2 is not null"
+ "attached_condition": "tt2.b1 is not null"
},
"table": {
- "table_name": "tt2",
+ "table_name": "<derived3>",
"access_type": "ref",
- "possible_keys": ["b1"],
- "key": "b1",
+ "possible_keys": ["key0"],
+ "key": "key0",
"key_length": "23",
- "used_key_parts": ["b1"],
- "ref": ["cte.a2"],
- "r_loops": 1,
- "rows": 2,
- "r_rows": 1,
+ "used_key_parts": ["a2"],
+ "ref": ["test.tt2.b1"],
+ "r_loops": 14,
+ "rows": 1,
+ "r_rows": 0.071428571,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 100,
@@ -4354,9 +4355,9 @@ NULL UNION RESULT <union4,5> ALL NULL NULL NULL NULL NULL
3 DERIVED v ALL NULL NULL NULL NULL 12 Using where
3 DERIVED h ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
3 DERIVED w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join)
-2 RECURSIVE UNION h ALL NULL NULL NULL NULL 12
-2 RECURSIVE UNION <derived4> ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-2 RECURSIVE UNION w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (incremental, BNL join)
+2 RECURSIVE UNION h ALL NULL NULL NULL NULL 12 Using where
+2 RECURSIVE UNION <derived4> ref key0 key0 5 test.h.id 2
+2 RECURSIVE UNION w ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union3,2> ALL NULL NULL NULL NULL NULL
prepare stmt from "with recursive
ancestor_couples(h_id, h_name, h_dob, h_father, h_mother,
diff --git a/mysql-test/main/delete.result b/mysql-test/main/delete.result
index ed3683d52f9..830f60aa3c7 100644
--- a/mysql-test/main/delete.result
+++ b/mysql-test/main/delete.result
@@ -92,6 +92,9 @@ select * from t1;
a b
1 apple
drop table t1;
+#
+# IGNORE option
+#
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
@@ -125,10 +128,14 @@ a b
33 10
0 11
2 12
+explain delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t12 ALL PRIMARY NULL NULL NULL 3
+1 PRIMARY t11 eq_ref PRIMARY PRIMARY 4 test.t12.a 1 Using where
+2 DEPENDENT SUBQUERY t2 ALL PRIMARY NULL NULL NULL 3 Using where
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
Warnings:
Warning 1242 Subquery returns more than 1 row
-Warning 1242 Subquery returns more than 1 row
select * from t11;
a b
0 10
diff --git a/mysql-test/main/delete.test b/mysql-test/main/delete.test
index c82420640c2..b95919ee4a4 100644
--- a/mysql-test/main/delete.test
+++ b/mysql-test/main/delete.test
@@ -106,9 +106,9 @@ delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
select * from t1;
drop table t1;
-#
-# IGNORE option
-#
+--echo #
+--echo # IGNORE option
+--echo #
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
@@ -122,6 +122,7 @@ select * from t2;
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11;
select * from t12;
+explain delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
select * from t11;
select * from t12;
diff --git a/mysql-test/main/delete_innodb.result b/mysql-test/main/delete_innodb.result
index b9f4c8bdaf5..ae9b415152f 100644
--- a/mysql-test/main/delete_innodb.result
+++ b/mysql-test/main/delete_innodb.result
@@ -17,7 +17,7 @@ a
b
EXPLAIN DELETE b FROM t1 AS a JOIN t1 AS b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE a index NULL PRIMARY 255 NULL 3 Using index
+1 SIMPLE a ALL NULL NULL NULL NULL 3
1 SIMPLE b ALL NULL NULL NULL NULL 3
DELETE b FROM t1 AS a JOIN t1 AS b;
SELECT * FROM t1;
diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result
index ada69a58d28..30ef641f523 100644
--- a/mysql-test/main/derived.result
+++ b/mysql-test/main/derived.result
@@ -236,7 +236,7 @@ count(*)
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where
2 DERIVED A ALL NULL NULL NULL NULL 2 Using where
3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
drop table t1;
diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result
index be3de7dbc02..c326a895a38 100644
--- a/mysql-test/main/derived_split_innodb.result
+++ b/mysql-test/main/derived_split_innodb.result
@@ -21,7 +21,7 @@ WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ref c1,n1_c1_n2 c1 1 const 2 Using index condition; Using where; Using temporary; Using filesort
1 PRIMARY <derived2> ref key0 key0 8 test.t1.n1,test.t1.n2 2
-2 DERIVED t1 ref c1,n1_c1_n2 c1 1 const 2 Using index condition; Using where; Using temporary; Using filesort
+2 LATERAL DERIVED t1 ref c1,n1_c1_n2 n1_c1_n2 4 test.t1.n1 1 Using where; Using index
SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t
WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1;
n1
@@ -128,8 +128,8 @@ left join
(v1 join t1 as t on v1.f1=t.f1 and t.f2 = null)
on t1.f1=t.f1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t const f2 NULL NULL NULL 1 Impossible ON condition
-1 PRIMARY <derived2> const key1 NULL NULL NULL 1 Impossible ON condition
+1 PRIMARY t const f2 NULL NULL NULL 0 Impossible ON condition
+1 PRIMARY <derived2> const key1 NULL NULL NULL 0 Impossible ON condition
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 DERIVED t2 ALL PRIMARY NULL NULL NULL 3 Using temporary; Using filesort
set statement optimizer_switch='split_materialized=off' for explain select t.f2
@@ -138,8 +138,8 @@ left join
(v1 join t1 as t on v1.f1=t.f1 and t.f2 = null)
on t1.f1=t.f1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t const f2 NULL NULL NULL 1 Impossible ON condition
-1 PRIMARY <derived3> const key1 NULL NULL NULL 1 Impossible ON condition
+1 PRIMARY t const f2 NULL NULL NULL 0 Impossible ON condition
+1 PRIMARY <derived3> const key1 NULL NULL NULL 0 Impossible ON condition
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
3 DERIVED t2 index NULL PRIMARY 4 NULL 3
drop view v1;
@@ -157,26 +157,26 @@ set statement optimizer_switch='split_materialized=off' for EXPLAIN
SELECT *
FROM
t1 JOIN
-(SELECT t1.a, t1.b FROM t1, t2 WHERE t1.b = t2.c GROUP BY t1.a, t1.b) as dt
+(SELECT t1_inner.a, t1_inner.b FROM t1 as t1_inner, t2 as t2_inner WHERE t1_inner.b = t2_inner.c GROUP BY t1_inner.a, t1_inner.b) as dt
WHERE
t1.a = dt.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a,a_2 a_2 10 NULL 6 Using where; Using index
1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2
-3 DERIVED t1 index NULL a_2 10 NULL 6 Using where; Using index
-3 DERIVED t2 ref c c 5 test.t1.b 1 Using index
+3 DERIVED t1_inner index NULL a_2 10 NULL 6 Using where; Using index
+3 DERIVED t2_inner ref c c 5 test.t1_inner.b 1 Using index
set statement optimizer_switch='split_materialized=on' for EXPLAIN
SELECT *
FROM
t1 JOIN
-(SELECT t1.a, t1.b FROM t1, t2 WHERE t1.b = t2.c GROUP BY t1.a, t1.b) as dt
+(SELECT t1_inner.a, t1_inner.b FROM t1 as t1_inner, t2 as t2_inner WHERE t1_inner.b = t2_inner.c GROUP BY t1_inner.a, t1_inner.b) as dt
WHERE
t1.a = dt.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a,a_2 a_2 10 NULL 6 Using where; Using index
1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2
-3 DERIVED t1 index a,a_2 a_2 10 NULL 6 Using where; Using index; Using temporary; Using filesort
-3 DERIVED t2 ref c c 5 test.t1.b 1 Using index
+3 DERIVED t1_inner index a,a_2 a_2 10 NULL 6 Using where; Using index
+3 DERIVED t2_inner ref c c 5 test.t1_inner.b 1 Using index
DROP TABLE t1, t2;
#
# Bug mdev-25714: usage non-splitting covering index is cheaper than
@@ -210,7 +210,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
1 PRIMARY t1 ref idx idx 4 test.t2.id 1
1 PRIMARY <derived2> ref key0 key0 9 test.t2.id,test.t1.id 2
-2 LATERAL DERIVED t3 ref idx1,idx2 idx2 4 test.t1.itemid 1 Using index condition; Using where
+2 DERIVED t3 ref idx1,idx2 idx1 4 const 5 Using where; Using index
select t1.id, t1.itemid, dt.id, t2.id
from t1,
(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt,
diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result
index 96efeb03c5e..803a4aee8e2 100644
--- a/mysql-test/main/except.result
+++ b/mysql-test/main/except.result
@@ -334,7 +334,8 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "119",
"join_type": "BNL",
- "r_filtered": 100
+ "r_filtered": 100,
+ "r_unpack_time_ms": "REPLACED"
}
}
},
@@ -370,7 +371,8 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "119",
"join_type": "BNL",
- "r_filtered": 100
+ "r_filtered": 100,
+ "r_unpack_time_ms": "REPLACED"
}
}
}
@@ -435,7 +437,8 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "119",
"join_type": "BNL",
- "r_filtered": 100
+ "r_filtered": 100,
+ "r_unpack_time_ms": "REPLACED"
}
}
},
@@ -471,7 +474,8 @@ ANALYZE
"buffer_type": "flat",
"buffer_size": "119",
"join_type": "BNL",
- "r_filtered": 100
+ "r_filtered": 100,
+ "r_unpack_time_ms": "REPLACED"
}
}
}
diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test
index e527b70c486..b48cc5d44c5 100644
--- a/mysql-test/main/explain_json.test
+++ b/mysql-test/main/explain_json.test
@@ -2,6 +2,7 @@
# EXPLAIN FORMAT=JSON tests. These are tests developed for MariaDB.
#
--source include/default_optimizer_switch.inc
+--source include/have_sequence.inc
--disable_warnings
drop table if exists t0,t1,t2;
@@ -117,7 +118,7 @@ select * from t1 where a in (select max(a) from t1 group by b);
create table t2 like t1;
insert into t2 select * from t1;
explain format=json
-select * from t1,t2 where t1.a in ( select a from t0);
+select * from t1,t2 where t1.a in ( select seq+0 from seq_1_to_100);
--echo #
--echo # First-Match
@@ -271,13 +272,17 @@ create index idx_t1_0 on t1 (a1);
create index idx_t1_1 on t1 (a1,a2,b,c);
create index idx_t1_2 on t1 (a1,a2,b);
analyze table t1;
+select count(*) from t1;
explain select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+explain select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a');
explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
+
explain format=json select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
+explain format=json select count(distinct a1,a2,b) from t1 where a1 >= "" and (a2 >= 'b') and (b = 'a');
drop table t1;
--echo #
diff --git a/mysql-test/main/fulltext.result b/mysql-test/main/fulltext.result
index 6f294eb4631..7644ab43ca8 100644
--- a/mysql-test/main/fulltext.result
+++ b/mysql-test/main/fulltext.result
@@ -594,6 +594,9 @@ CREATE TABLE t2 (a int, b2 char(10), FULLTEXT KEY b2 (b2));
INSERT INTO t2 VALUES (1,'Scargill');
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 VALUES (1,1), (2,1);
+SELECT * FROM t2 where MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE);
+a b2
+1 Scargill
# t2 should use full text index
EXPLAIN
SELECT count(*) FROM t1 WHERE
@@ -603,8 +606,8 @@ WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE)
);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
-2 MATERIALIZED t2 fulltext b2 b2 0 1 Using where
-2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where
+2 DEPENDENT SUBQUERY t2 fulltext b2 b2 0 1 Using where
+2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using where
# should return 0
SELECT count(*) FROM t1 WHERE
not exists(
diff --git a/mysql-test/main/fulltext.test b/mysql-test/main/fulltext.test
index c7aeae3fa31..da089297a15 100644
--- a/mysql-test/main/fulltext.test
+++ b/mysql-test/main/fulltext.test
@@ -544,6 +544,8 @@ INSERT INTO t2 VALUES (1,'Scargill');
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 VALUES (1,1), (2,1);
+SELECT * FROM t2 where MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE);
+
--echo # t2 should use full text index
EXPLAIN
SELECT count(*) FROM t1 WHERE
diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result
index 01959e5a642..0d9979ee583 100644
--- a/mysql-test/main/func_group.result
+++ b/mysql-test/main/func_group.result
@@ -608,7 +608,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain
select min(a1) from t1 where (a1 < 'KKK' or a1 > 'KKK');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 3 NULL 15 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 3 NULL 14 Using where; Using index
explain
select max(a3) from t1 where a2 < 2 and a3 < 'SEA';
id select_type table type possible_keys key key_len ref rows Extra
@@ -653,7 +653,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain
select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index k2 k2 4 NULL 7 Using where; Using index
+1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index
1 SIMPLE t1 index NULL PRIMARY 3 NULL 15 Using index; Using join buffer (flat, BNL join)
drop table t1, t2;
create table t1 (a char(10));
@@ -1337,7 +1337,7 @@ INSERT INTO t2 ( a, b, c ) VALUES
( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ), ( 2, NULL, 2 ), ( 2, 3, 4 ), ( 2, 4, 4 );
EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL a NULL NULL NULL 6 Using where
+1 SIMPLE t2 ref a a 5 const 3
SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1;
MIN(b) MIN(c)
3 2
@@ -1857,7 +1857,7 @@ NULL
EXPLAIN EXTENDED
SELECT MAX(a) FROM t1 WHERE (1,2) IN (SELECT a,b FROM t2 WHERE b<5) and a<10;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch
+1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch
1 PRIMARY t1 range a a 4 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = 1 and `test`.`t2`.`b` = 2 and `test`.`t1`.`a` < 10
diff --git a/mysql-test/main/func_group_innodb.result b/mysql-test/main/func_group_innodb.result
index f5a823e4638..9f69f424f33 100644
--- a/mysql-test/main/func_group_innodb.result
+++ b/mysql-test/main/func_group_innodb.result
@@ -246,12 +246,12 @@ INSERT INTO t1(a, b, c) VALUES
('', 'a', 1), ('', 'a', 1), ('', 'a', 2), ('', 'a', 2), ('', 'a', 3),
('', 'a', 3), ('', 'a', 4), ('', 'a', 4), ('', 'a', 5), ('', 'a', 5);
ANALYZE TABLE t1;
-SELECT MIN(c) FROM t1 GROUP BY b;
-MIN(c)
-0
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL b 263 NULL 2 Using index for group-by
+SELECT MIN(c) FROM t1 GROUP BY b;
+MIN(c)
+0
DROP TABLE t1;
#
# MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field
diff --git a/mysql-test/main/func_group_innodb.test b/mysql-test/main/func_group_innodb.test
index 748c64a43c6..5e7b885ad4b 100644
--- a/mysql-test/main/func_group_innodb.test
+++ b/mysql-test/main/func_group_innodb.test
@@ -196,8 +196,8 @@ INSERT INTO t1(a, b, c) VALUES
ANALYZE TABLE t1;
-- enable_result_log
-SELECT MIN(c) FROM t1 GROUP BY b;
EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b;
+SELECT MIN(c) FROM t1 GROUP BY b;
DROP TABLE t1;
diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result
index 1363a017dfd..569fdfe4cbf 100644
--- a/mysql-test/main/func_in.result
+++ b/mysql-test/main/func_in.result
@@ -522,7 +522,7 @@ a
b
explain select f1 from t1 where f1 in ('a','b');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
+1 SIMPLE t1 range t1f1_idx t1f1_idx 2 NULL 2 Using where; Using index
select f1 from t1 where f1 in (2,1);
f1
1
diff --git a/mysql-test/main/greedy_optimizer.result b/mysql-test/main/greedy_optimizer.result
index 371dbfd8abb..90f010a898c 100644
--- a/mysql-test/main/greedy_optimizer.result
+++ b/mysql-test/main/greedy_optimizer.result
@@ -127,7 +127,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 1.650792
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
@@ -139,55 +139,55 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 1.650792
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1330.797643
+Last_query_cost 0.578969
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1330.797643
+Last_query_cost 0.578969
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1334.341393
+Last_query_cost 0.577421
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1334.341393
+Last_query_cost 0.577421
set optimizer_prune_level=0;
select @@optimizer_prune_level;
@@optimizer_prune_level
@@ -198,108 +198,108 @@ select @@optimizer_search_depth;
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 Using where
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2437.438350
+Last_query_cost 1.405695
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 Using where
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2437.438350
+Last_query_cost 1.405695
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 653.372751
+Last_query_cost 0.494717
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 653.372751
+Last_query_cost 0.494717
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 662.822751
+Last_query_cost 0.453737
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 662.822751
+Last_query_cost 0.453737
set optimizer_search_depth=1;
select @@optimizer_search_depth;
@@optimizer_search_depth
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t7 index PRIMARY PRIMARY 4 NULL 21 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 34.290931
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t7 index PRIMARY PRIMARY 4 NULL 21 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 34.290931
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
+1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 9 Using index
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
@@ -307,11 +307,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1762.798851
+Last_query_cost 14.789649
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
+1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 9 Using index
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
@@ -319,7 +319,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1762.798851
+Last_query_cost 14.789649
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
@@ -331,7 +331,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1767.523851
+Last_query_cost 1.698604
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
@@ -343,83 +343,83 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1767.523851
+Last_query_cost 1.698604
set optimizer_search_depth=62;
select @@optimizer_search_depth;
@@optimizer_search_depth
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 Using where
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2437.438350
+Last_query_cost 1.405695
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1 Using where
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2437.438350
+Last_query_cost 1.405695
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 653.372751
+Last_query_cost 0.494717
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 653.372751
+Last_query_cost 0.494717
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 662.822751
+Last_query_cost 0.453737
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
-1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 662.822751
+Last_query_cost 0.453737
set optimizer_prune_level=1;
select @@optimizer_prune_level;
@@optimizer_prune_level
@@ -439,7 +439,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 1.650792
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
@@ -451,87 +451,87 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 1.650792
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1330.797643
+Last_query_cost 0.578969
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1330.797643
+Last_query_cost 0.578969
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1334.341393
+Last_query_cost 0.577421
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1334.341393
+Last_query_cost 0.577421
set optimizer_search_depth=1;
select @@optimizer_search_depth;
@@optimizer_search_depth
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t7 index PRIMARY PRIMARY 4 NULL 21 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 34.290931
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t7 index PRIMARY PRIMARY 4 NULL 21 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.c22 1
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.c42 1
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 34.290931
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
+1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 9 Using index
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
@@ -539,11 +539,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1762.798851
+Last_query_cost 14.789649
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
+1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 9 Using index
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
@@ -551,7 +551,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1762.798851
+Last_query_cost 14.789649
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
@@ -563,7 +563,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1767.523851
+Last_query_cost 1.698604
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where
@@ -575,7 +575,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1767.523851
+Last_query_cost 1.698604
set optimizer_search_depth=62;
select @@optimizer_search_depth;
@@optimizer_search_depth
@@ -591,7 +591,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 1.650792
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;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
@@ -603,55 +603,55 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t6.c62 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 2445.013350
+Last_query_cost 1.650792
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1330.797643
+Last_query_cost 0.578969
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using index
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using index
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using index
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1330.797643
+Last_query_cost 0.578969
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1334.341393
+Last_query_cost 0.577421
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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.c21 1 Using where
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.c12 1 Using where
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
-1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t1.c14 1 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t7 eq_ref PRIMARY PRIMARY 4 test.t1.c16 1 Using where
show status like 'Last_query_cost';
Variable_name Value
-Last_query_cost 1334.341393
+Last_query_cost 0.577421
drop table t1,t2,t3,t4,t5,t6,t7;
CREATE TABLE t1 (a int, b int, d int, i int);
INSERT INTO t1 VALUES (1,1,1,1);
diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result
index 73db7e5ff96..d8c6d6c0929 100644
--- a/mysql-test/main/group_min_max.result
+++ b/mysql-test/main/group_min_max.result
@@ -2080,7 +2080,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain extended select a1,a2,min(b),max(b) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 100.00 Using where; Using index
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 97.06 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
explain extended select a1,a2,b,min(c),max(c) from t1
@@ -2100,7 +2100,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 100.00 Using where; Using index
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 97.06 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
@@ -2230,7 +2230,7 @@ a
BB
EXPLAIN SELECT a FROM t1 WHERE a='AA' GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 4 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 7 NULL 1 Using where; Using index for group-by
EXPLAIN SELECT a FROM t1 WHERE a='BB' GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref PRIMARY PRIMARY 7 const 1 Using where; Using index
@@ -2368,11 +2368,11 @@ CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
INSERT INTO t2 SELECT a,b,b FROM t1;
explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a,b a 10 NULL 2 Using where; Using index for group-by
+1 SIMPLE t1 range a,b a 10 NULL 1 Using where; Using index for group-by
insert into t1 select 1,seq from seq_1_to_100;
explain SELECT MAX(b), a FROM t1 WHERE b < 2 AND a = 1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a,b a 10 NULL 2 Using where; Using index for group-by
+1 SIMPLE t1 range a,b a 10 NULL 1 Using where; Using index for group-by
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -2388,7 +2388,7 @@ MIN(b) a
2 1
explain SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index for group-by
SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
MIN(c)
2
@@ -2678,7 +2678,7 @@ a b
3 13
explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 range a,index a 5 NULL 3 100.00 Using where; Using index for group-by; Using temporary
+1 SIMPLE t1 range a,index a 5 NULL 1 100.00 Using where; Using index for group-by; Using temporary
Warnings:
Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,max(`test`.`t1`.`b`) + 1 AS `max(b)+1` from `test`.`t1` where `test`.`t1`.`a` = 0 group by `test`.`t1`.`a`
drop table t1;
@@ -3579,7 +3579,7 @@ a c COUNT(DISTINCT c, a, b)
EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range a a 5 NULL 1 Using where; Using index
+1 SIMPLE t2 range a a 15 NULL 1 Using where; Using index for group-by
SELECT COUNT(DISTINCT c, a, b) FROM t2
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
COUNT(DISTINCT c, a, b)
@@ -3673,7 +3673,7 @@ insert into t1 values(1,'A'),(1 , 'B'), (1, 'C'), (2, 'A'),
(3, 'A'), (3, 'B'), (3, 'C'), (3, 'D');
explain SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL f1 5 NULL 8 Using index for group-by (scanning)
+1 SIMPLE t1 range NULL f1 5 NULL 8 Using index for group-by
SELECT f1, COUNT(DISTINCT f2) FROM t1 GROUP BY f1;
f1 COUNT(DISTINCT f2)
1 3
@@ -4036,10 +4036,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select min(a) from t1 where a between "a" and "Cafeeeeeeeeeeeeeeeeeeeeeeeeee";
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index
+1 SIMPLE t1 range a a 13 NULL 2 Using where; Using index
explain select min(a) from t1 where a between "abbbbbbbbbbbbbbbbbbbb" and "Cafe2";
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index
+1 SIMPLE t1 range a a 13 NULL 2 Using where; Using index
drop table t1;
#
# MDEV-15433: Optimizer does not use group by optimization with distinct
@@ -4106,7 +4106,7 @@ CREATE TABLE t1 (p int NOT NULL, a int NOT NULL, PRIMARY KEY (p,a));
insert into t1 select 2,seq from seq_0_to_1000;
EXPLAIN select MIN(a) from t1 where p = 2 group by p;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index for group-by
SELECT MIN(a) from t1 where p = 2 group by p;
MIN(a)
0
diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test
index c2e9db1c7be..35ef7301ef1 100644
--- a/mysql-test/main/group_min_max.test
+++ b/mysql-test/main/group_min_max.test
@@ -1391,6 +1391,7 @@ SELECT a, c, COUNT(DISTINCT c, a, b) FROM t2 GROUP BY a, b, c;
EXPLAIN SELECT COUNT(DISTINCT c, a, b) FROM t2
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
+
SELECT COUNT(DISTINCT c, a, b) FROM t2
WHERE a > 5 AND b BETWEEN 10 AND 20 GROUP BY a, b, c;
diff --git a/mysql-test/main/ignored_index.result b/mysql-test/main/ignored_index.result
index 84263dddd4d..ea36713e9fa 100644
--- a/mysql-test/main/ignored_index.result
+++ b/mysql-test/main/ignored_index.result
@@ -255,17 +255,15 @@ DROP TABLE t1;
# IGNORED fulltext indexes.
#
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
-INSERT INTO t1 VALUES('Some data', 'for full-text search');
-ANALYZE TABLE t1;
-Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
-test.t1 analyze Warning Engine-independent statistics are not collected for column 'b'
-test.t1 analyze status OK
-EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections");
+INSERT INTO t1 VALUES('Some data', 'for full-text search'),("hello","hello world"),("mars","here I come");
+SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("search");
+a b
+Some data for full-text search
+EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("search");
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 fulltext a a 0 1 Using where
ALTER TABLE t1 ALTER INDEX a IGNORED;
-EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections");
+SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("search");
ERROR HY000: Can't find FULLTEXT index matching the column list
DROP TABLE t1;
#
diff --git a/mysql-test/main/ignored_index.test b/mysql-test/main/ignored_index.test
index a3d46fe6046..b2fadcd5862 100644
--- a/mysql-test/main/ignored_index.test
+++ b/mysql-test/main/ignored_index.test
@@ -222,13 +222,11 @@ DROP TABLE t1;
--echo # IGNORED fulltext indexes.
--echo #
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
-INSERT INTO t1 VALUES('Some data', 'for full-text search');
-ANALYZE TABLE t1;
-
-let $query=
-EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections");
+INSERT INTO t1 VALUES('Some data', 'for full-text search'),("hello","hello world"),("mars","here I come");
+let $query=SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("search");
--eval $query
+--eval EXPLAIN $query
ALTER TABLE t1 ALTER INDEX a IGNORED;
--error ER_FT_MATCHING_KEY_NOT_FOUND
diff --git a/mysql-test/main/index_intersect.result b/mysql-test/main/index_intersect.result
index 1f31636860f..9758425d98c 100644
--- a/mysql-test/main/index_intersect.result
+++ b/mysql-test/main/index_intersect.result
@@ -75,7 +75,7 @@ EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 300000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Population,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
+1 SIMPLE City range Population,Name Name 35 NULL # Using index condition; Using where
EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
@@ -712,7 +712,275 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Population,Country,Name Name,Country 35,3 NULL # Using sort_intersect(Name,Country); Using where
+1 SIMPLE City range Population,Country,Name Name 35 NULL # Using index condition; Using where
+QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
+EXPLAIN
+SELECT * FROM City
+WHERE Name BETWEEN 'G' AND 'J' AND Population > 500000 AND Country LIKE 'C%' {
+ "steps": [
+ {
+ "join_preparation": {
+ "select_id": 1,
+ "steps": [
+ {
+ "expanded_query": "select City.`ID` AS `ID`,City.`Name` AS `Name`,City.Country AS Country,City.Population AS Population from City where City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'"
+ }
+ ]
+ }
+ },
+ {
+ "join_optimization": {
+ "select_id": 1,
+ "steps": [
+ {
+ "condition_processing": {
+ "condition": "WHERE",
+ "original_condition": "City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'",
+ "steps": [
+ {
+ "transformation": "equality_propagation",
+ "resulting_condition": "City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'"
+ },
+ {
+ "transformation": "constant_propagation",
+ "resulting_condition": "City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'"
+ },
+ {
+ "transformation": "trivial_condition_removal",
+ "resulting_condition": "City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'"
+ }
+ ]
+ }
+ },
+ {
+ "table_dependencies": [
+ {
+ "table": "City",
+ "row_may_be_null": false,
+ "map_bit": 0,
+ "depends_on_map_bits": []
+ }
+ ]
+ },
+ {
+ "ref_optimizer_key_uses": []
+ },
+ {
+ "rows_estimation": [
+ {
+ "table": "City",
+ "range_analysis": {
+ "table_scan": {
+ "rows": 4079,
+ "cost": 0.659034395
+ },
+ "potential_range_indexes": [
+ {
+ "index": "PRIMARY",
+ "usable": false,
+ "cause": "not applicable"
+ },
+ {
+ "index": "Population",
+ "usable": true,
+ "key_parts": ["Population"]
+ },
+ {
+ "index": "Country",
+ "usable": true,
+ "key_parts": ["Country"]
+ },
+ {
+ "index": "Name",
+ "usable": true,
+ "key_parts": ["Name"]
+ }
+ ],
+ "setup_range_conditions": [],
+ "analyzing_range_alternatives": {
+ "range_scan_alternatives": [
+ {
+ "index": "Population",
+ "ranges": ["(500000) < (Population)"],
+ "rowid_ordered": false,
+ "using_mrr": false,
+ "index_only": false,
+ "rows": 540,
+ "cost": 0.667779759,
+ "chosen": false,
+ "cause": "cost"
+ },
+ {
+ "index": "Country",
+ "ranges": ["(C\0\0) <= (Country) <= (Cÿÿ)"],
+ "rowid_ordered": false,
+ "using_mrr": false,
+ "index_only": false,
+ "rows": 538,
+ "cost": 0.665312021,
+ "chosen": false,
+ "cause": "cost"
+ },
+ {
+ "index": "Name",
+ "ranges": ["(G) <= (Name) <= (J)"],
+ "rowid_ordered": false,
+ "using_mrr": false,
+ "index_only": false,
+ "rows": 226,
+ "cost": 0.280344893,
+ "chosen": true
+ }
+ ],
+ "analyzing_roworder_intersect": {
+ "cause": "too few roworder scans"
+ },
+ "analyzing_sort_intersect": {
+ "potential_index_scans": [
+ {
+ "index": "Population",
+ "cost": 0.058326157,
+ "chosen": true,
+ "cause": "first occurrence of index prefix"
+ },
+ {
+ "index": "Country",
+ "cost": 0.058113617,
+ "chosen": true,
+ "cause": "first occurrence of index prefix"
+ },
+ {
+ "index": "Name",
+ "cost": 0.024957377,
+ "chosen": true,
+ "cause": "first occurrence of index prefix"
+ }
+ ],
+ "selected_index_scans": [
+ {
+ "index": "Name",
+ "keyparts": ["Name"],
+ "rows": 226,
+ "filtered_records": 0
+ },
+ {
+ "index": "Country",
+ "keyparts": ["Country"],
+ "rows": 538,
+ "filtered_records": 0
+ },
+ {
+ "index": "Population",
+ "keyparts": ["Population"],
+ "rows": 540,
+ "filtered_records": 0
+ }
+ ]
+ },
+ "analyzing_index_merge_union": []
+ },
+ "group_index_range": {
+ "chosen": false,
+ "cause": "no group by or distinct"
+ },
+ "chosen_range_access_summary": {
+ "range_access_plan": {
+ "type": "range_scan",
+ "index": "Name",
+ "rows": 226,
+ "ranges": ["(G) <= (Name) <= (J)"]
+ },
+ "rows_for_plan": 226,
+ "cost_for_plan": 0.280344893,
+ "chosen": true
+ }
+ }
+ },
+ {
+ "selectivity_for_indexes": [
+ {
+ "index_name": "Name",
+ "selectivity_from_index": 0.055405737
+ },
+ {
+ "index_name": "Country",
+ "selectivity_from_index": 0.131895072
+ },
+ {
+ "index_name": "Population",
+ "selectivity_from_index": 0.132385389
+ }
+ ],
+ "selectivity_for_columns": [],
+ "cond_selectivity": 9.674385e-4
+ }
+ ]
+ },
+ {
+ "considered_execution_plans": [
+ {
+ "plan_prefix": [],
+ "table": "City",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 1
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "range",
+ "rows": 226,
+ "rows_after_filter": 226,
+ "rows_out": 3.946181571,
+ "cost": 0.280344893,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "range",
+ "rows_read": 226,
+ "rows_out": 3.946181571,
+ "cost": 0.280344893,
+ "uses_join_buffering": false
+ }
+ },
+ "rows_for_plan": 3.946181571,
+ "cost_for_plan": 0.280344893
+ }
+ ]
+ },
+ {
+ "best_join_order": ["City"],
+ "rows": 3.946181571,
+ "cost": 0.280344893
+ },
+ {
+ "substitute_best_equal": {
+ "condition": "WHERE",
+ "resulting_condition": "City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'"
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "City",
+ "attached": "City.`Name` between 'G' and 'J' and City.Population > 500000 and City.Country like 'C%'"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "join_execution": {
+ "select_id": 1,
+ "steps": []
+ }
+ }
+ ]
+} 0 0
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
@@ -723,7 +991,7 @@ SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
AND Country BETWEEN 'S' AND 'Z';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge PRIMARY,Population,Country Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
+1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result
index 0ce5cbea37d..bbaa513b84c 100644
--- a/mysql-test/main/information_schema.result
+++ b/mysql-test/main/information_schema.result
@@ -71,6 +71,7 @@ INDEX_STATISTICS
KEYWORDS
KEY_CACHES
KEY_COLUMN_USAGE
+OPTIMIZER_COSTS
OPTIMIZER_TRACE
PARAMETERS
PARTITIONS
diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff
index 75f5a3432b4..212a0b3f12e 100644
--- a/mysql-test/main/innodb_ext_key,off.rdiff
+++ b/mysql-test/main/innodb_ext_key,off.rdiff
@@ -1,20 +1,17 @@
---- main/innodb_ext_key.result
-+++ main/innodb_ext_key,off.reject
+--- innodb_ext_key.result
++++ innodb_ext_key,off.reject
@@ -9,7 +9,7 @@
explain
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 8 const,const 1 Using index
-+1 SIMPLE lineitem index_merge PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey,i_l_shipdate 4,4 NULL 1 Using intersect(i_l_orderkey,i_l_shipdate); Using where; Using index
++1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 const 6 Using where; Using index
flush status;
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
count(*)
-@@ -17,9 +17,9 @@
- show status like 'handler_read%';
- Variable_name Value
+@@ -19,7 +19,7 @@
Handler_read_first 0
--Handler_read_key 1
-+Handler_read_key 2
+ Handler_read_key 1
Handler_read_last 0
-Handler_read_next 1
+Handler_read_next 6
@@ -98,16 +95,13 @@
where l_shipdate='1992-07-01' and l_orderkey=130;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
-+1 SIMPLE lineitem index_merge PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey,i_l_shipdate 4,4 NULL 1 Using intersect(i_l_orderkey,i_l_shipdate); Using where; Using index
++1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_shipdate 4 const 6 Using where; Using index
flush status;
select max(l_linenumber) from lineitem
where l_shipdate='1992-07-01' and l_orderkey=130;
-@@ -143,9 +143,9 @@
- show status like 'handler_read%';
- Variable_name Value
+@@ -145,7 +145,7 @@
Handler_read_first 0
--Handler_read_key 1
-+Handler_read_key 2
+ Handler_read_key 1
Handler_read_last 0
-Handler_read_next 0
+Handler_read_next 6
@@ -178,7 +172,7 @@
where l_partkey between 1 and 10 group by l_partkey;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE lineitem range i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 NULL # Using where; Using index for group-by
-+1 SIMPLE lineitem range i_l_suppkey_partkey,i_l_partkey i_l_partkey 5 NULL # Using where; Using index
++1 SIMPLE lineitem range i_l_suppkey_partkey,i_l_partkey i_l_suppkey_partkey 5 NULL # Using where; Using index
flush status;
select max(l_orderkey) from lineitem
where l_partkey between 1 and 10 group by l_partkey;
@@ -236,17 +230,17 @@
Handler_read_retry 0
Handler_read_rnd 0
@@ -314,8 +314,8 @@
- select * from t0, part ignore index (primary)
+ select straight_join * from t0, part ignore index (primary)
where p_partkey=t0.a and p_size=1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t0 ALL NULL NULL NULL NULL 5 Using where
-1 SIMPLE part eq_ref i_p_size i_p_size 9 const,dbt3_s001.t0.a 1
+1 SIMPLE t0 ALL NULL NULL NULL NULL 5
+1 SIMPLE part ref i_p_size i_p_size 5 const 5 Using index condition
- select * from t0, part ignore index (primary)
+ select straight_join * from t0, part ignore index (primary)
where p_partkey=t0.a and p_size=1;
a p_partkey p_name p_mfgr p_brand p_type p_size p_container p_retailprice p_comment
-@@ -494,7 +494,7 @@
+@@ -495,7 +495,7 @@
select * from t1, t3 where t3.col1=t1.a and t3.col2=t1.a and t3.pk1=t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL # Using where
@@ -255,7 +249,7 @@
drop table t1,t2,t3;
#
# Bug mdev-4340: performance regression with extended_keys=on
-@@ -725,13 +725,13 @@
+@@ -726,13 +726,13 @@
select * from t1 force index(index_date_updated)
where index_date_updated= 10 and index_id < 800;
id select_type table type possible_keys key key_len ref rows Extra
@@ -271,7 +265,7 @@
drop table t0,t1,t2;
#
# MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff'
-@@ -766,13 +766,14 @@
+@@ -767,13 +767,14 @@
"select_id": 1,
"table": {
"table_name": "t1",
@@ -290,7 +284,7 @@
"index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'",
"attached_condition": "t1.f1 <= '3'"
}
-@@ -799,8 +800,8 @@
+@@ -800,8 +801,8 @@
"access_type": "range",
"possible_keys": ["k1"],
"key": "k1",
diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result
index 8cc7cfce861..cc3da56fae0 100644
--- a/mysql-test/main/innodb_ext_key.result
+++ b/mysql-test/main/innodb_ext_key.result
@@ -308,15 +308,15 @@ Handler_read_rnd_next 0
# when extended_keys=on
#
create table t0 (a int);
-insert into t0 values (1), (2), (3), (4), (5);
+insert into t0 select seq from seq_1_to_5;
create index i_p_size on part(p_size);
explain
-select * from t0, part ignore index (primary)
+select straight_join * from t0, part ignore index (primary)
where p_partkey=t0.a and p_size=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE part eq_ref i_p_size i_p_size 9 const,dbt3_s001.t0.a 1
-select * from t0, part ignore index (primary)
+select straight_join * from t0, part ignore index (primary)
where p_partkey=t0.a and p_size=1;
a p_partkey p_name p_mfgr p_brand p_type p_size p_container p_retailprice p_comment
2 2 blush rosy metallic lemon navajo Manufacturer#1 Brand#13 LARGE BRUSHED BRASS 1 LG CASE 902 final platelets hang f
@@ -381,17 +381,18 @@ INSERT INTO t2 VALUES
(10), (11), (12), (13), (14),
(15), (16), (17), (18), (19), (24);
EXPLAIN
-SELECT a FROM t1 AS t, t2
-WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
+SELECT a FROM t1 AS t, t2 as t2_out
+WHERE t2_out.c = t.a AND t.b IN (SELECT b FROM t1, t2 WHERE b = t.b);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t index a,b b 7 NULL 10 Using index
-1 PRIMARY t1 ref b b 3 test.t.b 2 Using index
-1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; FirstMatch(t)
-1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t.a 1 Using index
-SELECT a FROM t1 AS t, t2
-WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
+1 PRIMARY t1 index b b 7 NULL 10 Using index; Start temporary
+1 PRIMARY t ref a,b b 3 test.t1.b 2 Using index
+1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; End temporary; Using join buffer (flat, BNL join)
+1 PRIMARY t2_out eq_ref PRIMARY PRIMARY 4 test.t.a 1 Using index
+SELECT a FROM t1 AS t, t2 as t2_out
+WHERE t2_out.c = t.a AND t.b IN (SELECT b FROM t1, t2 WHERE b = t.b);
a
24
+Last_query_cost 0.119652
DROP TABLE t1,t2;
#
# LP Bug #923236: hash join + extended_keys = on
@@ -638,7 +639,7 @@ test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
explain select a from t1 where b is null order by a desc limit 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range b b 9 NULL 3 Using where; Using filesort
+1 SIMPLE t1 index b PRIMARY 8 NULL 2 Using where
select a from t1 where b is null order by a desc limit 2;
a
3
diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test
index f1cf6658f0b..4d96dd116dd 100644
--- a/mysql-test/main/innodb_ext_key.test
+++ b/mysql-test/main/innodb_ext_key.test
@@ -1,4 +1,5 @@
--source include/innodb_prefix_index_cluster_optimization.inc
+--source include/have_sequence.inc
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
@@ -151,14 +152,14 @@ show status like 'handler_read%';
--echo #
create table t0 (a int);
-insert into t0 values (1), (2), (3), (4), (5);
+insert into t0 select seq from seq_1_to_5;
create index i_p_size on part(p_size);
explain
-select * from t0, part ignore index (primary)
+select straight_join * from t0, part ignore index (primary)
where p_partkey=t0.a and p_size=1;
-select * from t0, part ignore index (primary)
+select straight_join * from t0, part ignore index (primary)
where p_partkey=t0.a and p_size=1;
drop table t0;
@@ -235,10 +236,11 @@ INSERT INTO t2 VALUES
(15), (16), (17), (18), (19), (24);
EXPLAIN
-SELECT a FROM t1 AS t, t2
- WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
-SELECT a FROM t1 AS t, t2
- WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
+SELECT a FROM t1 AS t, t2 as t2_out
+ WHERE t2_out.c = t.a AND t.b IN (SELECT b FROM t1, t2 WHERE b = t.b);
+SELECT a FROM t1 AS t, t2 as t2_out
+ WHERE t2_out.c = t.a AND t.b IN (SELECT b FROM t1, t2 WHERE b = t.b);
+--source include/last_query_cost.inc
DROP TABLE t1,t2;
diff --git a/mysql-test/main/innodb_mysql_lock2.test b/mysql-test/main/innodb_mysql_lock2.test
index 09298a900b1..e5bb4bd9565 100644
--- a/mysql-test/main/innodb_mysql_lock2.test
+++ b/mysql-test/main/innodb_mysql_lock2.test
@@ -833,6 +833,7 @@ insert into t1 values (1), (2), (3), (4), (5);
begin;
--echo # Acquire SR metadata lock on t1.
+--sorted_result
select * from t1;
connection con1;
diff --git a/mysql-test/main/invisible_field_debug.result b/mysql-test/main/invisible_field_debug.result
index 4cbdb31e155..4f49fd9dd1a 100644
--- a/mysql-test/main/invisible_field_debug.result
+++ b/mysql-test/main/invisible_field_debug.result
@@ -346,7 +346,7 @@ invisible a b
9 7 7
explain select * from t1 where invisible =9;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL invisible NULL NULL NULL 7 Using where
+1 SIMPLE t1 ref invisible invisible 5 const 7
alter table t1 add x int default 3;
select invisible, a ,b from t1;
invisible a b
@@ -368,11 +368,11 @@ drop index invisible on t1;
ERROR 42000: Can't DROP INDEX `invisible`; check that it exists
explain select * from t1 where invisible =9;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL invisible NULL NULL NULL 7 Using where
+1 SIMPLE t1 ref invisible invisible 5 const 7
create index invisible on t1(c);
explain select * from t1 where invisible =9;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL invisible_2 NULL NULL NULL 7 Using where
+1 SIMPLE t1 ref invisible_2 invisible_2 5 const 7
show indexes in t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
t1 1 b 1 b A NULL NULL NULL YES BTREE NO
diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result
index 2878214b70d..83884a51f17 100644
--- a/mysql-test/main/join_nested.result
+++ b/mysql-test/main/join_nested.result
@@ -855,8 +855,8 @@ ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b AND t2.a>0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t2 ref idx_b idx_b 5 test.t3.b 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t3`.`b` and `test`.`t2`.`b` = `test`.`t3`.`b` and `test`.`t2`.`a` > 0 and `test`.`t3`.`b` is not null) where 1
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
@@ -964,13 +964,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where
1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where
1 SIMPLE t8 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t4`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`a` > 0)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t8`.`b` = `test`.`t9`.`b` or `test`.`t8`.`c` is null)
INSERT INTO t8 VALUES (-3,12,0), (-1,14,0), (-5,15,0), (-1,11,0), (-4,13,0);
@@ -1062,7 +1062,7 @@ t0.b=t1.b AND
(t8.b=t9.b OR t8.c IS NULL) AND
(t9.a=1);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t0 ALL idx_a NULL NULL NULL 3 66.67 Using where
+1 SIMPLE t0 ref idx_a idx_a 5 const 2 100.00 Using where
1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 2 100.00
1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
@@ -1284,8 +1284,8 @@ NULL 2 2
DELETE FROM t3;
EXPLAIN SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 const c NULL NULL NULL 1 Impossible ON condition
-1 SIMPLE t2 const b NULL NULL NULL 1 Impossible ON condition
+1 SIMPLE t3 const c NULL NULL NULL 0 Impossible ON condition
+1 SIMPLE t2 const b NULL NULL NULL 0 Impossible ON condition
1 SIMPLE t1 index NULL a 5 NULL 21 Using index
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
a b c
diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result
index 60eda4e006c..4a2868ee02b 100644
--- a/mysql-test/main/join_outer.result
+++ b/mysql-test/main/join_outer.result
@@ -2276,7 +2276,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1 left join t2 on t2.c is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 9
-1 SIMPLE t2 ref c c 5 const 312 Using where
+1 SIMPLE t2 ALL c NULL NULL NULL 1000 Using where
drop table t1,t2;
#
# MDEV-10006: optimizer doesn't convert outer join to inner on views with WHERE clause
diff --git a/mysql-test/main/key.result b/mysql-test/main/key.result
index 8cc0ce204cb..005e0ea3350 100644
--- a/mysql-test/main/key.result
+++ b/mysql-test/main/key.result
@@ -632,19 +632,19 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
SHOW STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 8.506592
+Last_query_cost 0.014749
EXPLAIN SELECT a, SUM( b ) FROM t1 USE INDEX( a ) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
SHOW STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 8.506592
+Last_query_cost 0.014749
EXPLAIN SELECT a, SUM( b ) FROM t1 FORCE INDEX( a ) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL 6
SHOW STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 8.506592
+Last_query_cost 0.014749
DROP TABLE t1;
#
# MDEV-21480: Unique key using ref access though eq_ref access can be used
diff --git a/mysql-test/main/key_cache.result b/mysql-test/main/key_cache.result
index 3edbac8c9ae..4ec0d6ab7d7 100644
--- a/mysql-test/main/key_cache.result
+++ b/mysql-test/main/key_cache.result
@@ -434,7 +434,7 @@ p i a
3 1 yyyy
4 3 zzzz
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused';
VARIABLE_NAME VARIABLE_VALUE
KEY_BLOCKS_NOT_FLUSHED 0
@@ -482,7 +482,7 @@ p i a
3 1 yyyy
4 3 zzzz
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused';
VARIABLE_NAME VARIABLE_VALUE
KEY_BLOCKS_NOT_FLUSHED 0
@@ -527,7 +527,7 @@ p i a
3 1 yyyy
4 3 zzzz
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused';
VARIABLE_NAME VARIABLE_VALUE
KEY_BLOCKS_NOT_FLUSHED 0
@@ -583,7 +583,7 @@ p i a
3 1 yyyy
4 3 zzzz
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.key_caches where segment_number is null;
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 4 # 0 21 0 26 6
@@ -627,10 +627,14 @@ select * from information_schema.key_caches where segment_number is null;
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 6749 # 3684 103
small NULL NULL 1048576 1024 # # 0 0 # 0 0
+analyze table t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
flush tables;
flush status;
update t1 set a='zzzz' where a='qqqq';
-update t2 set i=1 where i=2;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=1 where i=2;
select * from information_schema.key_caches where segment_number is null;
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3076 18 1552 18
@@ -699,7 +703,7 @@ update t2 set p=p+3000, i=2 where a='qqqq';
select * from information_schema.key_caches where key_cache_name like "key%"
and segment_number is null;
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
-keycache1 7 NULL 262143 2048 25 # 0 2114 25 1071 19
+keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19
set global keycache2.key_buffer_size=1024*1024;
cache index t2 in keycache2;
Table Op Msg_type Msg_text
@@ -712,7 +716,7 @@ keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3
select * from information_schema.key_caches where key_cache_name like "key%"
and segment_number is null;
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
-keycache1 7 NULL 262143 2048 25 # 0 2114 25 1071 19
+keycache1 7 NULL 262143 2048 25 # 0 2082 25 1071 19
keycache2 NULL NULL 1048576 1024 6 # 0 6 6 3 3
cache index t2 in keycache1;
Table Op Msg_type Msg_text
@@ -753,7 +757,7 @@ select * from information_schema.key_caches where segment_number is null;
KEY_CACHE_NAME SEGMENTS SEGMENT_NUMBER FULL_SIZE BLOCK_SIZE USED_BLOCKS UNUSED_BLOCKS DIRTY_BLOCKS READ_REQUESTS READS WRITE_REQUESTS WRITES
default 2 NULL 32768 1024 # # 0 3172 24 1552 18
small NULL NULL 1048576 1024 # # 0 0 0 0 0
-keycache1 7 NULL 262143 2048 # # 0 3277 43 1594 30
+keycache1 7 NULL 262143 2048 # # 0 3229 43 1594 30
keycache2 NULL NULL 1048576 1024 # # 0 6 6 3 3
set global keycache1.key_cache_block_size=2*1024;
insert into t2 values (7000, 3, 'yyyy');
diff --git a/mysql-test/main/key_cache.test b/mysql-test/main/key_cache.test
index 9bd57f017f0..baca5c07fec 100644
--- a/mysql-test/main/key_cache.test
+++ b/mysql-test/main/key_cache.test
@@ -299,7 +299,7 @@ insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
select * from t1;
select * from t2;
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused';
select variable_value into @key_blocks_unused from information_schema.session_status where variable_name = 'Key_blocks_unused';
@@ -331,8 +331,7 @@ insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
select * from t1;
select * from t2;
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
-
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused';
select variable_value < @key_blocks_unused from information_schema.session_status where variable_name = 'Key_blocks_unused';
@@ -357,7 +356,7 @@ insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
select * from t1;
select * from t2;
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused';
select variable_value = @key_blocks_unused from information_schema.session_status where variable_name = 'Key_blocks_unused';
@@ -389,7 +388,7 @@ insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
select * from t1;
select * from t2;
update t1 set p=3 where p=1;
-update t2 set i=2 where i=1;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=2 where i=1;
--replace_column 7 #
select * from information_schema.key_caches where segment_number is null;
@@ -422,9 +421,10 @@ select * from t2 where p between 1010 and 1020 ;
--replace_column 6 # 7 # 10 #
select * from information_schema.key_caches where segment_number is null;
+analyze table t2;
flush tables; flush status;
update t1 set a='zzzz' where a='qqqq';
-update t2 set i=1 where i=2;
+set statement optimizer_scan_setup_cost=0 for update t2 set i=1 where i=2;
--replace_column 6 # 7 #
select * from information_schema.key_caches where segment_number is null;
diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result
index ff2ea680138..f073d5fe16c 100644
--- a/mysql-test/main/myisam.result
+++ b/mysql-test/main/myisam.result
@@ -349,11 +349,11 @@ t1 1 c_2 2 a A 5 NULL NULL BTREE NO
explain select * from t1,t2 where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 2
-1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ref a a 4 test.t2.a 3
explain select * from t1,t2 force index(a) where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 2
-1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ref a a 4 test.t2.a 3
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 2
@@ -389,10 +389,10 @@ t1 1 c_2 2 a A 5 NULL NULL BTREE NO
explain select * from t1,t2 force index(c) where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ref a a 4 test.t2.a 3
explain select * from t1 where a=0 or a=2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
+1 SIMPLE t1 range a a 4 NULL 5 Using index condition
explain select * from t1 force index (a) where a=0 or a=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 4 NULL 5 Using index condition
@@ -641,7 +641,7 @@ create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,'');
explain select count(*) from t1 where a is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL idx NULL NULL NULL 2 Using where
+1 SIMPLE t1 ref idx idx 4 const 2 Using where
select count(*) from t1 where a is null;
count(*)
2
@@ -649,6 +649,9 @@ insert into t1 values (1,''), (2,'');
explain select count(*) from t1 where a is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref idx idx 4 const 2 Using where
+set statement optimizer_scan_setup_cost= 0 for explain select count(*) from t1 where a is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL idx NULL NULL NULL 4 Using where
drop table t1;
create table t1 (c1 int, c2 varchar(4) not null default '',
key(c2(3))) default charset=utf8;
diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test
index 096be265cb4..488cc1c0048 100644
--- a/mysql-test/main/myisam.test
+++ b/mysql-test/main/myisam.test
@@ -597,6 +597,7 @@ explain select count(*) from t1 where a is null;
select count(*) from t1 where a is null;
insert into t1 values (1,''), (2,'');
explain select count(*) from t1 where a is null;
+set statement optimizer_scan_setup_cost= 0 for explain select count(*) from t1 where a is null;
drop table t1;
#
diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result
index d8f4c1cdc5e..9745c5b8ce7 100644
--- a/mysql-test/main/mysqld--help.result
+++ b/mysql-test/main/mysqld--help.result
@@ -693,11 +693,15 @@ The following specify which files/extra groups are read (specified before remain
max_connections*5 or max_connections + table_cache*2
(whichever is larger) number of file descriptors
(Automatically configured unless set explicitly)
- --optimizer-cache-hit-ratio=#
- Expected hit rate of the row and index cache in storage
- engines. The value should be an integer between 0 and 99,
- where 0 means cache is empty and 99 means that value is
- almost always in the cache.
+ --optimizer-disk-read-cost=#
+ Cost of reading a block of IO_SIZE (4096) from a disk (in
+ usec).
+ --optimizer-disk-read-ratio=#
+ Chance that we have to do a disk read to find a row or
+ index entry from the engine cache
+ (cache_misses/total_cache_requests). 0.0 means that
+ everything is cached and 1.0 means that nothing is
+ expected to be in the engine cache.
--optimizer-index-block-copy-cost=#
Cost of copying a key block from the cache to intern
storage as part of an index scan.
@@ -706,6 +710,8 @@ The following specify which files/extra groups are read (specified before remain
--optimizer-key-copy-cost=#
Cost of finding the next key in the engine and copying it
to the SQL layer.
+ --optimizer-key-lookup-cost=#
+ Cost for finding a key based on a key value
--optimizer-key-next-find-cost=#
Cost of finding the next key and rowid when using
filters.
@@ -721,6 +727,14 @@ The following specify which files/extra groups are read (specified before remain
--optimizer-row-copy-cost=#
Cost of copying a row from the engine or the join cache
to the SQL layer.
+ --optimizer-row-lookup-cost=#
+ Cost of finding a row based on a rowid or a clustered
+ key.
+ --optimizer-row-next-find-cost=#
+ Cost of finding the next row when scanning the table.
+ --optimizer-scan-setup-cost=#
+ Extra cost added to TABLE and INDEX scans to get
+ optimizer to prefer index lookups.
--optimizer-search-depth=#
Maximum depth of search performed by the query optimizer.
Values larger than the number of relations in a query
@@ -775,6 +789,8 @@ The following specify which files/extra groups are read (specified before remain
record samples
--optimizer-where-cost=#
Cost of checking the row against the WHERE clause.
+ Increasing this will have the optimizer to prefer plans
+ with less row combinations.
--performance-schema
Enable the performance schema.
--performance-schema-accounts-size=#
@@ -1675,21 +1691,26 @@ old-alter-table DEFAULT
old-mode UTF8_IS_UTF8MB3
old-passwords FALSE
old-style-user-limits FALSE
-optimizer-cache-hit-ratio 50
-optimizer-index-block-copy-cost 0.2
-optimizer-key-compare-cost 0.05
-optimizer-key-copy-cost 0.025
-optimizer-key-next-find-cost 0.0125
+optimizer-disk-read-cost 0.01024
+optimizer-disk-read-ratio 0.02
+optimizer-index-block-copy-cost 3.56e-05
+optimizer-key-compare-cost 1.1361e-05
+optimizer-key-copy-cost 1.5685e-05
+optimizer-key-lookup-cost 0.000435777
+optimizer-key-next-find-cost 8.2347e-05
optimizer-max-sel-arg-weight 32000
optimizer-prune-level 1
-optimizer-row-copy-cost 0.05
+optimizer-row-copy-cost 6.0866e-05
+optimizer-row-lookup-cost 0.000130839
+optimizer-row-next-find-cost 4.5916e-05
+optimizer-scan-setup-cost 0.01
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
optimizer-trace
optimizer-trace-max-mem-size 1048576
optimizer-use-condition-selectivity 4
-optimizer-where-cost 0.2
+optimizer-where-cost 3.2e-05
performance-schema FALSE
performance-schema-accounts-size -1
performance-schema-consumer-events-stages-current FALSE
diff --git a/mysql-test/main/named_pipe.result b/mysql-test/main/named_pipe.result
index 2baa3471ec9..a0738cdad34 100644
--- a/mysql-test/main/named_pipe.result
+++ b/mysql-test/main/named_pipe.result
@@ -1,5 +1,6 @@
connect pipe_con,localhost,root,,,,,PIPE;
drop table if exists t1,t2,t3,t4;
+set @@default_storage_engine="aria";
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -600,6 +601,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
+#
+# Some test with ORDER BY and limit
+#
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
@@ -1289,7 +1293,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
PRIMARY KEY (companynr),
UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
+) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
companynr companyname
00 Unknown
@@ -1379,6 +1383,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
+#
+# Test left join optimization
+#
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
@@ -1393,15 +1400,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1417,11 +1424,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result
index a32e392f8f7..837662adab6 100644
--- a/mysql-test/main/opt_trace.result
+++ b/mysql-test/main/opt_trace.result
@@ -118,8 +118,8 @@ select * from v1 {
"table": "t1",
"table_scan": {
"rows": 2,
- "read_cost": 1.002197266,
- "read_and_compare_cost": 1.502197266
+ "read_cost": 0.01024881,
+ "read_and_compare_cost": 0.01031281
}
}
]
@@ -137,30 +137,30 @@ select * from v1 {
{
"access_type": "scan",
"rows": 2,
- "rows_after_scan": 1,
"rows_after_filter": 1,
- "cost": 1.502197266,
+ "rows_out": 1,
+ "cost": 0.01031281,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 1,
- "records_out": 1,
- "cost": 1.502197266,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.01031281,
"uses_join_buffering": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 1.502197266
+ "cost_for_plan": 0.01031281
}
]
},
{
"best_join_order": ["t1"],
"rows": 1,
- "cost": 1.502197266
+ "cost": 0.01031281
},
{
"substitute_best_equal": {
@@ -278,8 +278,8 @@ select * from (select * from t1 where t1.a=1)q {
"table": "t1",
"table_scan": {
"rows": 2,
- "read_cost": 1.002197266,
- "read_and_compare_cost": 1.502197266
+ "read_cost": 0.01024881,
+ "read_and_compare_cost": 0.01031281
}
}
]
@@ -297,30 +297,30 @@ select * from (select * from t1 where t1.a=1)q {
{
"access_type": "scan",
"rows": 2,
- "rows_after_scan": 1,
"rows_after_filter": 1,
- "cost": 1.502197266,
+ "rows_out": 1,
+ "cost": 0.01031281,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 1,
- "records_out": 1,
- "cost": 1.502197266,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.01031281,
"uses_join_buffering": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 1.502197266
+ "cost_for_plan": 0.01031281
}
]
},
{
"best_join_order": ["t1"],
"rows": 1,
- "cost": 1.502197266
+ "cost": 0.01031281
},
{
"substitute_best_equal": {
@@ -443,8 +443,8 @@ select * from v2 {
"table": "t1",
"table_scan": {
"rows": 2,
- "read_cost": 1.002197266,
- "read_and_compare_cost": 1.502197266
+ "read_cost": 0.01024881,
+ "read_and_compare_cost": 0.01031281
}
}
]
@@ -462,9 +462,9 @@ select * from v2 {
{
"access_type": "scan",
"rows": 2,
- "rows_after_scan": 1,
"rows_after_filter": 1,
- "cost": 1.502197266,
+ "rows_out": 1,
+ "cost": 0.01031281,
"index_only": false,
"chosen": true,
"use_tmp_table": true
@@ -472,22 +472,22 @@ select * from v2 {
],
"chosen_access_method": {
"type": "scan",
- "records_read": 1,
- "records_out": 1,
- "cost": 1.502197266,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.01031281,
"uses_join_buffering": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 1.502197266,
- "cost_for_sorting": 1
+ "cost_for_plan": 0.01031281,
+ "cost_for_sorting": 6.301866e-4
}
]
},
{
"best_join_order": ["t1"],
"rows": 1,
- "cost": 2.502197266
+ "cost": 0.010942997
},
{
"substitute_best_equal": {
@@ -525,8 +525,8 @@ select * from v2 {
"table": "<derived2>",
"table_scan": {
"rows": 2,
- "read_cost": 2,
- "read_and_compare_cost": 2.5
+ "read_cost": 0.012350033,
+ "read_and_compare_cost": 0.012418701
}
}
]
@@ -544,30 +544,30 @@ select * from v2 {
{
"access_type": "scan",
"rows": 2,
- "rows_after_scan": 2,
"rows_after_filter": 2,
- "cost": 2.5,
+ "rows_out": 2,
+ "cost": 0.012418701,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 2,
- "records_out": 2,
- "cost": 2.5,
+ "rows_read": 2,
+ "rows_out": 2,
+ "cost": 0.012418701,
"uses_join_buffering": false
}
},
"rows_for_plan": 2,
- "cost_for_plan": 2.5
+ "cost_for_plan": 0.012418701
}
]
},
{
"best_join_order": ["<derived2>"],
"rows": 2,
- "cost": 2.5
+ "cost": 0.012418701
},
{
"attaching_conditions_to_tables": {
@@ -671,8 +671,8 @@ explain select * from v2 {
"table": "t2",
"table_scan": {
"rows": 10,
- "read_cost": 1.010986328,
- "read_and_compare_cost": 3.510986328
+ "read_cost": 0.01124405,
+ "read_and_compare_cost": 0.01156405
}
}
]
@@ -690,30 +690,30 @@ explain select * from v2 {
{
"access_type": "scan",
"rows": 10,
- "rows_after_scan": 10,
"rows_after_filter": 10,
- "cost": 3.510986328,
+ "rows_out": 10,
+ "cost": 0.01156405,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 3.510986328,
+ "rows_read": 10,
+ "rows_out": 10,
+ "cost": 0.01156405,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 3.510986328
+ "cost_for_plan": 0.01156405
}
]
},
{
"best_join_order": ["t2"],
"rows": 10,
- "cost": 3.510986328
+ "cost": 0.01156405
},
{
"attaching_conditions_to_tables": {
@@ -796,8 +796,8 @@ explain select * from v1 {
"table": "t1",
"table_scan": {
"rows": 10,
- "read_cost": 1.010986328,
- "read_and_compare_cost": 3.510986328
+ "read_cost": 0.01124405,
+ "read_and_compare_cost": 0.01156405
}
}
]
@@ -815,9 +815,9 @@ explain select * from v1 {
{
"access_type": "scan",
"rows": 10,
- "rows_after_scan": 10,
"rows_after_filter": 10,
- "cost": 3.510986328,
+ "rows_out": 10,
+ "cost": 0.01156405,
"index_only": false,
"chosen": true,
"use_tmp_table": true
@@ -825,22 +825,22 @@ explain select * from v1 {
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 3.510986328,
+ "rows_read": 10,
+ "rows_out": 10,
+ "cost": 0.01156405,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 3.510986328,
- "cost_for_sorting": 10
+ "cost_for_plan": 0.01156405,
+ "cost_for_sorting": 0.006368384
}
]
},
{
"best_join_order": ["t1"],
"rows": 10,
- "cost": 13.51098633
+ "cost": 0.017932434
},
{
"attaching_conditions_to_tables": {
@@ -872,8 +872,8 @@ explain select * from v1 {
"table": "<derived2>",
"table_scan": {
"rows": 10,
- "read_cost": 10,
- "read_and_compare_cost": 12.5
+ "read_cost": 0.012414166,
+ "read_and_compare_cost": 0.012757506
}
}
]
@@ -891,30 +891,30 @@ explain select * from v1 {
{
"access_type": "scan",
"rows": 10,
- "rows_after_scan": 10,
"rows_after_filter": 10,
- "cost": 12.5,
+ "rows_out": 10,
+ "cost": 0.012757506,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 12.5,
+ "rows_read": 10,
+ "rows_out": 10,
+ "cost": 0.012757506,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 12.5
+ "cost_for_plan": 0.012757506
}
]
},
{
"best_join_order": ["<derived2>"],
"rows": 10,
- "cost": 12.5
+ "cost": 0.012757506
},
{
"attaching_conditions_to_tables": {
@@ -1044,16 +1044,16 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"table": "t1",
"table_scan": {
"rows": 100,
- "read_cost": 1.158691406,
- "read_and_compare_cost": 26.15869141
+ "read_cost": 0.0224405,
+ "read_and_compare_cost": 0.0256405
}
},
{
"table": "t2",
"table_scan": {
"rows": 100,
- "read_cost": 1.158691406,
- "read_and_compare_cost": 26.15869141
+ "read_cost": 0.0224405,
+ "read_and_compare_cost": 0.0256405
}
}
]
@@ -1071,23 +1071,23 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
{
"access_type": "scan",
"rows": 100,
- "rows_after_scan": 100,
"rows_after_filter": 100,
- "cost": 26.15869141,
+ "rows_out": 100,
+ "cost": 0.0256405,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 100,
- "records_out": 100,
- "cost": 26.15869141,
+ "rows_read": 100,
+ "rows_out": 100,
+ "cost": 0.0256405,
"uses_join_buffering": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 26.15869141,
+ "cost_for_plan": 0.0256405,
"rest_of_plan": [
{
"plan_prefix": ["t1"],
@@ -1103,30 +1103,29 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"used_range_estimates": false,
"cause": "not available",
"rows": 1,
- "cost": 125.0585794,
+ "cost": 0.1731074,
"chosen": true
},
{
"access_type": "scan_with_join_cache",
"rows": 100,
- "rows_after_scan": 75,
- "rows_after_filter": 75,
- "cost": 1807.408691,
+ "rows_after_filter": 100,
+ "rows_out": 1,
+ "cost": 0.9603871,
"index_only": false,
"chosen": false
}
],
"chosen_access_method": {
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 125.0585794,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.1731074,
"uses_join_buffering": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 151.2172709,
- "pruned_by_hanging_leaf": true
+ "cost_for_plan": 0.1987479
}
]
},
@@ -1141,23 +1140,23 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
{
"access_type": "scan",
"rows": 100,
- "rows_after_scan": 100,
"rows_after_filter": 100,
- "cost": 26.15869141,
+ "rows_out": 100,
+ "cost": 0.0256405,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 100,
- "records_out": 100,
- "cost": 26.15869141,
+ "rows_read": 100,
+ "rows_out": 100,
+ "cost": 0.0256405,
"uses_join_buffering": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 26.15869141,
+ "cost_for_plan": 0.0256405,
"rest_of_plan": [
{
"plan_prefix": ["t2"],
@@ -1173,29 +1172,29 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"used_range_estimates": false,
"cause": "not available",
"rows": 1,
- "cost": 125.0585794,
+ "cost": 0.1731074,
"chosen": true
},
{
"access_type": "scan_with_join_cache",
"rows": 100,
- "rows_after_scan": 75,
- "rows_after_filter": 75,
- "cost": 1807.408691,
+ "rows_after_filter": 100,
+ "rows_out": 1,
+ "cost": 0.9603871,
"index_only": false,
"chosen": false
}
],
"chosen_access_method": {
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 125.0585794,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.1731074,
"uses_join_buffering": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 151.2172709,
+ "cost_for_plan": 0.1987479,
"pruned_by_cost": true
}
]
@@ -1205,7 +1204,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
{
"best_join_order": ["t1", "t2"],
"rows": 100,
- "cost": 151.2172709
+ "cost": 0.1987479
},
{
"substitute_best_equal": {
@@ -1244,10 +1243,11 @@ drop table t1,t2,t0;
# group_by min max optimization
#
CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, KEY(a));
+insert into t1 select seq, mod(seq,4)+1 from seq_1_to_65536;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
-test.t1 analyze status OK
+test.t1 analyze status Table is already up to date
EXPLAIN SELECT DISTINCT a FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL a 4 NULL 5 Using index for group-by
@@ -1286,7 +1286,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"range_analysis": {
"table_scan": {
"rows": 65536,
- "cost": 16457
+ "cost": 10.29477568
},
"potential_range_indexes": [
{
@@ -1302,7 +1302,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 14898.29141,
+ "cost": 9.123706862,
"chosen": true
},
"group_index_range": {
@@ -1312,7 +1312,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"index": "a",
"covering": true,
"rows": 5,
- "cost": 6.5
+ "cost": 0.004191135
}
]
},
@@ -1324,7 +1324,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 5,
- "cost": 6.5,
+ "cost": 0.004191135,
"key_parts_used_for_access": ["a"],
"ranges": [],
"chosen": true
@@ -1338,12 +1338,12 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 5,
- "cost": 6.5,
+ "cost": 0.004191135,
"key_parts_used_for_access": ["a"],
"ranges": []
},
"rows_for_plan": 5,
- "cost_for_plan": 6.5,
+ "cost_for_plan": 0.004191135,
"chosen": true
}
}
@@ -1363,29 +1363,29 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
{
"access_type": "index_merge",
"rows": 5,
- "rows_after_scan": 5,
"rows_after_filter": 5,
- "cost": 6.5,
+ "rows_out": 5,
+ "cost": 0.004191135,
"chosen": true
}
],
"chosen_access_method": {
"type": "index_merge",
- "records_read": 5,
- "records_out": 5,
- "cost": 6.5,
+ "rows_read": 5,
+ "rows_out": 5,
+ "cost": 0.004191135,
"uses_join_buffering": false
}
},
"rows_for_plan": 5,
- "cost_for_plan": 6.5
+ "cost_for_plan": 0.004191135
}
]
},
{
"best_join_order": ["t1"],
"rows": 5,
- "cost": 6.5
+ "cost": 0.004191135
},
{
"attaching_conditions_to_tables": {
@@ -1421,10 +1421,13 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a;
id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 20 NULL 7 Using where; Using index for group-by
+set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a;
+id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 20 NULL 7 Using where; Using index
select * from information_schema.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
-EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
+set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"steps": [
{
"join_preparation": {
@@ -1480,7 +1483,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"range_analysis": {
"table_scan": {
"rows": 7,
- "cost": 2.764526367
+ "cost": 0.001094835
},
"potential_range_indexes": [
{
@@ -1491,8 +1494,9 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 2.084226263,
- "chosen": true
+ "cost": 0.001758432,
+ "chosen": false,
+ "cause": "cost"
},
"setup_range_conditions": [],
"analyzing_range_alternatives": {
@@ -1509,7 +1513,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"covering": true,
"ranges": ["(2,3) <= (b,c) <= (2,3)"],
"rows": 7,
- "cost": 2.75
+ "cost": 0.004425189
}
]
},
@@ -1521,7 +1525,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 7,
- "cost": 2.75,
+ "cost": 0.004425189,
"key_parts_used_for_access": ["a", "b", "c"],
"ranges": ["(2,3) <= (b,c) <= (2,3)"],
"chosen": false,
@@ -1560,9 +1564,9 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
{
"access_type": "scan",
"rows": 7,
- "rows_after_scan": 1,
"rows_after_filter": 1,
- "cost": 2.084226263,
+ "rows_out": 0.584899902,
+ "cost": 0.001758432,
"index_only": true,
"chosen": true,
"use_tmp_table": true
@@ -1570,22 +1574,22 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
],
"chosen_access_method": {
"type": "scan",
- "records_read": 1,
- "records_out": 0.584899902,
- "cost": 2.084226263,
+ "rows_read": 1,
+ "rows_out": 0.584899902,
+ "cost": 0.001758432,
"uses_join_buffering": false
}
},
- "rows_for_plan": 1,
- "cost_for_plan": 2.084226263,
- "cost_for_sorting": 1
+ "rows_for_plan": 0.584899902,
+ "cost_for_plan": 0.001758432,
+ "cost_for_sorting": 3.670142e-4
}
]
},
{
"best_join_order": ["t1"],
- "rows": 1,
- "cost": 3.084226263
+ "rows": 0.584899902,
+ "cost": 0.002125446
},
{
"substitute_best_equal": {
@@ -1609,8 +1613,8 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"clause": "GROUP BY",
"table": "t1",
"rows_estimation": 1,
- "read_cost": 2.147624763,
- "filesort_cost": 0.0633985,
+ "read_cost": 0.001804223,
+ "filesort_cost": 4.579083e-5,
"filesort_type": "priority_queue with addon fields",
"fanout": 1,
"possible_keys": [
@@ -1619,7 +1623,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"can_resolve_order": true,
"rows_to_examine": 7,
"range_scan": false,
- "scan_cost": 2.084226263,
+ "scan_cost": 0.001667847,
"chosen": true
}
]
@@ -1708,7 +1712,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"range_analysis": {
"table_scan": {
"rows": 16,
- "cost": 5.015625
+ "cost": 0.01250248
},
"potential_range_indexes": [
{
@@ -1719,7 +1723,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
],
"best_covering_index_scan": {
"index": "id",
- "cost": 4.11171589,
+ "cost": 0.008002862,
"chosen": true
},
"setup_range_conditions": [],
@@ -1737,7 +1741,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"covering": true,
"ranges": ["(2001-01-04) <= (a)"],
"rows": 9,
- "cost": 3.25
+ "cost": 0.005620843
}
]
},
@@ -1749,7 +1753,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"max_aggregate": true,
"distinct_aggregate": false,
"rows": 9,
- "cost": 3.25,
+ "cost": 0.005620843,
"key_parts_used_for_access": ["id"],
"ranges": ["(2001-01-04) <= (a)"],
"chosen": true
@@ -1763,12 +1767,12 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"max_aggregate": true,
"distinct_aggregate": false,
"rows": 9,
- "cost": 3.25,
+ "cost": 0.005620843,
"key_parts_used_for_access": ["id"],
"ranges": ["(2001-01-04) <= (a)"]
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25,
+ "cost_for_plan": 0.005620843,
"chosen": true
}
}
@@ -1788,31 +1792,31 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
{
"access_type": "index_merge",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25,
+ "rows_out": 9,
+ "cost": 0.005620843,
"chosen": true,
"use_tmp_table": true
}
],
"chosen_access_method": {
"type": "index_merge",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.005620843,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25,
- "cost_for_sorting": 9
+ "cost_for_plan": 0.005620843,
+ "cost_for_sorting": 0.005728198
}
]
},
{
"best_join_order": ["t1"],
"rows": 9,
- "cost": 12.25
+ "cost": 0.011349041
},
{
"substitute_best_equal": {
@@ -1903,7 +1907,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"range_analysis": {
"table_scan": {
"rows": 16,
- "cost": 5.015625
+ "cost": 0.01250248
},
"potential_range_indexes": [
{
@@ -1914,7 +1918,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
],
"best_covering_index_scan": {
"index": "id",
- "cost": 4.11171589,
+ "cost": 0.008002862,
"chosen": true
},
"setup_range_conditions": [],
@@ -1932,7 +1936,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"covering": true,
"ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"],
"rows": 9,
- "cost": 3.25
+ "cost": 0.005620843
}
]
},
@@ -1944,7 +1948,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 9,
- "cost": 3.25,
+ "cost": 0.005620843,
"key_parts_used_for_access": ["id", "a"],
"ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"],
"chosen": true
@@ -1958,12 +1962,12 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 9,
- "cost": 3.25,
+ "cost": 0.005620843,
"key_parts_used_for_access": ["id", "a"],
"ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"]
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25,
+ "cost_for_plan": 0.005620843,
"chosen": true
}
}
@@ -1983,31 +1987,31 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
{
"access_type": "index_merge",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25,
+ "rows_out": 9,
+ "cost": 0.005620843,
"chosen": true,
"use_tmp_table": true
}
],
"chosen_access_method": {
"type": "index_merge",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.005620843,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25,
- "cost_for_sorting": 9
+ "cost_for_plan": 0.005620843,
+ "cost_for_sorting": 0.005728198
}
]
},
{
"best_join_order": ["t1"],
"rows": 9,
- "cost": 12.25
+ "cost": 0.011349041
},
{
"substitute_best_equal": {
@@ -2041,10 +2045,6 @@ drop table t1;
#
# Late ORDER BY optimization
#
-create table ten(a int);
-insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table one_k(a int primary key);
-insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
create table t1 (
pk int not null,
a int,
@@ -2055,19 +2055,18 @@ KEY c(c),
KEY a_c(a,c),
KEY a_b(a,b)
);
-insert into t1
-select a, a,a,a, 'filler-dataaa' from test.one_k;
+insert into t1 select seq, seq,seq,seq, 'filler-dataaa' from seq_0_to_999;
update t1 set a=1 where pk between 0 and 180;
update t1 set b=2 where pk between 0 and 20;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
-set optimizer_trace='enabled=on';
explain select * from t1 where a=1 and b=2 order by c limit 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a_c,a_b a_b 10 const,const 21 Using where; Using filesort
update t1 set b=2 where pk between 20 and 40;
+set optimizer_trace='enabled=on';
explain select * from t1 where a=1 and b=2 order by c limit 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a_c,a_b a_c 5 NULL 180 Using where
@@ -2148,7 +2147,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"range_analysis": {
"table_scan": {
"rows": 1000,
- "cost": 265.2822266
+ "cost": 0.1731362
},
"potential_range_indexes": [
{
@@ -2177,8 +2176,9 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"using_mrr": false,
"index_only": false,
"rows": 180,
- "cost": 135.6693776,
- "chosen": true
+ "cost": 0.223346519,
+ "chosen": false,
+ "cause": "cost"
},
{
"index": "a_b",
@@ -2187,7 +2187,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"using_mrr": false,
"index_only": false,
"rows": 41,
- "cost": 31.3040249,
+ "cost": 0.051838728,
"chosen": true
}
],
@@ -2208,7 +2208,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"ranges": ["(1,2) <= (a,b) <= (1,2)"]
},
"rows_for_plan": 41,
- "cost_for_plan": 31.3040249,
+ "cost_for_plan": 0.051838728,
"chosen": true
}
}
@@ -2218,12 +2218,12 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"rowid_filters": [
{
"key": "a_b",
- "build_cost": 1.752281351,
+ "build_cost": 0.006243462,
"rows": 41
},
{
"key": "a_c",
- "build_cost": 6.264109827,
+ "build_cost": 0.026549953,
"rows": 180
}
]
@@ -2266,7 +2266,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"index": "a_c",
"used_range_estimates": true,
"rows": 180,
- "cost": 135.6493776,
+ "cost": 0.222796377,
"chosen": true
},
{
@@ -2274,7 +2274,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"index": "a_b",
"used_range_estimates": true,
"rows": 41,
- "cost": 31.2840249,
+ "cost": 0.051288586,
"chosen": true
},
{
@@ -2285,21 +2285,21 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
],
"chosen_access_method": {
"type": "ref",
- "records_read": 41,
- "records_out": 41,
- "cost": 31.2840249,
+ "rows_read": 41,
+ "rows_out": 41,
+ "cost": 0.051288586,
"uses_join_buffering": false
}
},
"rows_for_plan": 41,
- "cost_for_plan": 31.2840249
+ "cost_for_plan": 0.051288586
}
]
},
{
"best_join_order": ["t1"],
"rows": 41,
- "cost": 31.2840249
+ "cost": 0.051288586
},
{
"substitute_best_equal": {
@@ -2323,8 +2323,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"clause": "ORDER BY",
"table": "t1",
"rows_estimation": 41,
- "read_cost": 32.58369415,
- "filesort_cost": 1.299669251,
+ "read_cost": 0.052227298,
+ "filesort_cost": 9.387121e-4,
"filesort_type": "priority_queue with addon fields",
"fanout": 1,
"possible_keys": [
@@ -2333,7 +2333,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"can_resolve_order": true,
"rows_to_examine": 24,
"range_scan": false,
- "scan_cost": 18.51405907,
+ "scan_cost": 0.030312813,
"chosen": true
},
{
@@ -2341,7 +2341,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"can_resolve_order": true,
"rows_to_examine": 4,
"range_scan": true,
- "scan_cost": 10.5218905,
+ "scan_cost": 0.021302281,
"chosen": true
},
{
@@ -2355,10 +2355,6 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
{
"table": "t1",
"range_analysis": {
- "table_scan": {
- "rows": 1000,
- "cost": 1.79769e308
- },
"potential_range_indexes": [
{
"index": "c",
@@ -2386,7 +2382,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"using_mrr": false,
"index_only": false,
"rows": 180,
- "cost": 135.6693776,
+ "cost": 0.223346519,
+ "cost_with_limit": 0.002483968,
"chosen": true
}
],
@@ -2407,7 +2404,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"ranges": ["(1) <= (a) <= (1)"]
},
"rows_for_plan": 180,
- "cost_for_plan": 135.6693776,
+ "cost_for_plan": 0.223346519,
"chosen": true
}
}
@@ -2423,7 +2420,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
}
]
} 0 0
-drop table t1,ten,one_k;
+drop table t1;
#
# TABLE ELIMINATION
#
@@ -2513,8 +2510,8 @@ select t1.a from t1 left join t2 on t1.a=t2.a {
"table": "t1",
"table_scan": {
"rows": 4,
- "read_cost": 1.003417969,
- "read_and_compare_cost": 2.003417969
+ "read_cost": 0.01049762,
+ "read_and_compare_cost": 0.01062562
}
},
{
@@ -2538,30 +2535,30 @@ select t1.a from t1 left join t2 on t1.a=t2.a {
{
"access_type": "scan",
"rows": 4,
- "rows_after_scan": 4,
"rows_after_filter": 4,
- "cost": 2.003417969,
+ "rows_out": 4,
+ "cost": 0.01062562,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 4,
- "records_out": 4,
- "cost": 2.003417969,
+ "rows_read": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"uses_join_buffering": false
}
},
"rows_for_plan": 4,
- "cost_for_plan": 2.003417969
+ "cost_for_plan": 0.01062562
}
]
},
{
"best_join_order": ["t2", "t1"],
"rows": 4,
- "cost": 2.003417969
+ "cost": 0.01062562
},
{
"substitute_best_equal": {
@@ -2660,16 +2657,16 @@ explain select * from t1 left join t2 on t2.a=t1.a {
"table": "t1",
"table_scan": {
"rows": 4,
- "read_cost": 1.003417969,
- "read_and_compare_cost": 2.003417969
+ "read_cost": 0.01049762,
+ "read_and_compare_cost": 0.01062562
}
},
{
"table": "t2",
"table_scan": {
"rows": 2,
- "read_cost": 1.002197266,
- "read_and_compare_cost": 1.502197266
+ "read_cost": 0.01024881,
+ "read_and_compare_cost": 0.01031281
}
}
]
@@ -2687,23 +2684,23 @@ explain select * from t1 left join t2 on t2.a=t1.a {
{
"access_type": "scan",
"rows": 4,
- "rows_after_scan": 4,
"rows_after_filter": 4,
- "cost": 2.003417969,
+ "rows_out": 4,
+ "cost": 0.01062562,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 4,
- "records_out": 4,
- "cost": 2.003417969,
+ "rows_read": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"uses_join_buffering": false
}
},
"rows_for_plan": 4,
- "cost_for_plan": 2.003417969,
+ "cost_for_plan": 0.01062562,
"rest_of_plan": [
{
"plan_prefix": ["t1"],
@@ -2717,30 +2714,25 @@ explain select * from t1 left join t2 on t2.a=t1.a {
"access_type": "eq_ref",
"index": "PRIMARY",
"rows": 1,
- "cost": 5.002147913,
+ "cost": 0.007120904,
"chosen": true
},
{
- "access_type": "scan",
- "rows": 2,
- "rows_after_scan": 1.5,
- "rows_after_filter": 1.5,
- "cost": 6.008789062,
- "index_only": false,
- "chosen": false
+ "type": "scan",
+ "chosen": false,
+ "cause": "cost"
}
],
"chosen_access_method": {
"type": "eq_ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 5.002147913,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.007120904,
"uses_join_buffering": false
}
},
"rows_for_plan": 4,
- "cost_for_plan": 7.005565882,
- "pruned_by_hanging_leaf": true
+ "cost_for_plan": 0.017746524
}
]
}
@@ -2749,7 +2741,7 @@ explain select * from t1 left join t2 on t2.a=t1.a {
{
"best_join_order": ["t1", "t2"],
"rows": 4,
- "cost": 7.005565882
+ "cost": 0.017746524
},
{
"substitute_best_equal": {
@@ -2882,8 +2874,8 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and
"table": "t1",
"table_scan": {
"rows": 4,
- "read_cost": 1.003417969,
- "read_and_compare_cost": 2.003417969
+ "read_cost": 0.01049762,
+ "read_and_compare_cost": 0.01062562
}
},
{
@@ -2913,30 +2905,30 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and
{
"access_type": "scan",
"rows": 4,
- "rows_after_scan": 4,
"rows_after_filter": 4,
- "cost": 2.003417969,
+ "rows_out": 4,
+ "cost": 0.01062562,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 4,
- "records_out": 4,
- "cost": 2.003417969,
+ "rows_read": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"uses_join_buffering": false
}
},
"rows_for_plan": 4,
- "cost_for_plan": 2.003417969
+ "cost_for_plan": 0.01062562
}
]
},
{
"best_join_order": ["t3", "t2", "t1"],
"rows": 4,
- "cost": 2.003417969
+ "cost": 0.01062562
},
{
"substitute_best_equal": {
@@ -2974,33 +2966,27 @@ drop table t0, t1, t2, t3;
#
# IN subquery to sem-join is traced
#
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(a int, b int);
-insert into t1 values (0,0),(1,1),(2,2);
-create table t2 as select * from t1;
-create table t11(a int, b int);
-create table t10 (pk int, a int);
-insert into t10 select a,a from t0;
-create table t12 like t10;
-insert into t12 select * from t10;
-analyze table t1,t10;
-Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
-test.t1 analyze status OK
-test.t10 analyze status Engine-independent statistics collected
-test.t10 analyze status OK
+insert into t1 select seq,seq from seq_0_to_3;
+create table t2 (p int, a int);
+insert into t2 select seq,seq from seq_1_to_10;
set optimizer_trace='enabled=on';
-explain extended select * from t1 where a in (select pk from t10);
+explain extended select * from t1 where a in (select p from t2);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`p` = `test`.`t1`.`a`
+insert into t2 select seq,seq from seq_10_to_100;
+explain extended select * from t1 where a in (select p from t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
-2 MATERIALIZED t10 ALL NULL NULL NULL NULL 10 100.00
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00
+1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t10`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`p` = `test`.`t1`.`a`
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
-explain extended select * from t1 where a in (select pk from t10) {
+explain extended select * from t1 where a in (select p from t2) {
"steps": [
{
"join_preparation": {
@@ -3028,13 +3014,13 @@ explain extended select * from t1 where a in (select pk from t10) {
}
},
{
- "expanded_query": "/* select#2 */ select t10.pk from t10"
+ "expanded_query": "/* select#2 */ select t2.p from t2"
}
]
}
},
{
- "expanded_query": "/* select#1 */ select t1.a AS a,t1.b AS b from t1 where t1.a in (/* select#2 */ select t10.pk from t10)"
+ "expanded_query": "/* select#1 */ select t1.a AS a,t1.b AS b from t1 where t1.a in (/* select#2 */ select t2.p from t2)"
}
]
}
@@ -3054,19 +3040,19 @@ explain extended select * from t1 where a in (select pk from t10) {
{
"condition_processing": {
"condition": "WHERE",
- "original_condition": "1 and t1.a = t10.pk",
+ "original_condition": "1 and t1.a = t2.p",
"steps": [
{
"transformation": "equality_propagation",
- "resulting_condition": "1 and multiple equal(t1.a, t10.pk)"
+ "resulting_condition": "1 and multiple equal(t1.a, t2.p)"
},
{
"transformation": "constant_propagation",
- "resulting_condition": "1 and multiple equal(t1.a, t10.pk)"
+ "resulting_condition": "1 and multiple equal(t1.a, t2.p)"
},
{
"transformation": "trivial_condition_removal",
- "resulting_condition": "multiple equal(t1.a, t10.pk)"
+ "resulting_condition": "multiple equal(t1.a, t2.p)"
}
]
}
@@ -3080,7 +3066,7 @@ explain extended select * from t1 where a in (select pk from t10) {
"depends_on_map_bits": []
},
{
- "table": "t10",
+ "table": "t2",
"row_may_be_null": false,
"map_bit": 1,
"depends_on_map_bits": []
@@ -3095,17 +3081,17 @@ explain extended select * from t1 where a in (select pk from t10) {
{
"table": "t1",
"table_scan": {
- "rows": 3,
- "read_cost": 1.003295898,
- "read_and_compare_cost": 1.753295898
+ "rows": 4,
+ "read_cost": 0.01049762,
+ "read_and_compare_cost": 0.01062562
}
},
{
- "table": "t10",
+ "table": "t2",
"table_scan": {
- "rows": 10,
- "read_cost": 1.010986328,
- "read_and_compare_cost": 3.510986328
+ "rows": 101,
+ "read_cost": 0.022564905,
+ "read_and_compare_cost": 0.025796905
}
}
]
@@ -3122,7 +3108,7 @@ explain extended select * from t1 where a in (select pk from t10) {
"considered_execution_plans": [
{
"plan_prefix": [],
- "table": "t10",
+ "table": "t2",
"best_access_path": {
"plan_details": {
"record_count": 1
@@ -3130,24 +3116,24 @@ explain extended select * from t1 where a in (select pk from t10) {
"considered_access_paths": [
{
"access_type": "scan",
- "rows": 10,
- "rows_after_scan": 10,
- "rows_after_filter": 10,
- "cost": 3.510986328,
+ "rows": 101,
+ "rows_after_filter": 101,
+ "rows_out": 101,
+ "cost": 0.025796905,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 3.510986328,
+ "rows_read": 101,
+ "rows_out": 101,
+ "cost": 0.025796905,
"uses_join_buffering": false
}
},
- "rows_for_plan": 10,
- "cost_for_plan": 3.510986328
+ "rows_for_plan": 101,
+ "cost_for_plan": 0.025796905
}
]
}
@@ -3166,83 +3152,88 @@ explain extended select * from t1 where a in (select pk from t10) {
"considered_access_paths": [
{
"access_type": "scan",
- "rows": 3,
- "rows_after_scan": 3,
- "rows_after_filter": 3,
- "cost": 1.753295898,
+ "rows": 4,
+ "rows_after_filter": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.753295898,
+ "rows_read": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"uses_join_buffering": false
}
},
- "rows_for_plan": 3,
- "cost_for_plan": 1.753295898,
+ "rows_for_plan": 4,
+ "cost_for_plan": 0.01062562,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
"plan_prefix": ["t1"],
- "table": "t10",
+ "table": "t2",
"best_access_path": {
"plan_details": {
- "record_count": 3
+ "record_count": 4
},
"considered_access_paths": [
{
"access_type": "scan_with_join_cache",
- "rows": 10,
- "rows_after_scan": 10,
- "rows_after_filter": 10,
- "cost": 10.63598633,
+ "rows": 101,
+ "rows_after_filter": 101,
+ "rows_out": 101,
+ "cost": 0.063558233,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 10.63598633,
+ "rows_read": 101,
+ "rows_out": 101,
+ "cost": 0.063558233,
"uses_join_buffering": true
}
},
- "rows_for_plan": 30,
- "cost_for_plan": 12.38928223,
+ "rows_for_plan": 404,
+ "cost_for_plan": 0.074183853,
"semijoin_strategy_choice": [
{
"strategy": "FirstMatch",
- "records": 3,
- "cost": 12.38928223
+ "rows": 4,
+ "cost": 0.074183853
},
{
"strategy": "SJ-Materialization",
- "records": 3,
- "cost": 8.664282227
+ "rows": 4,
+ "cost": 0.078697445
},
{
"strategy": "DuplicateWeedout",
- "records": 3,
- "dups_cost": 12.38928223,
- "write_cost": 2.5,
- "full_lookup_cost": 15,
- "total_cost": 29.88928223
+ "prefix_record_count": 4,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 101,
+ "rows": 4,
+ "dups_cost": 0.074183853,
+ "write_cost": 0.02564388,
+ "full_lookup_cost": 0.06503188,
+ "total_cost": 0.164859613
},
{
- "chosen_strategy": "SJ-Materialization"
+ "chosen_strategy": "FirstMatch"
}
- ]
+ ],
+ "rows_out": 1,
+ "rows_for_plan": 4
}
]
},
{
"plan_prefix": [],
- "table": "t10",
+ "table": "t2",
"best_access_path": {
"plan_details": {
"record_count": 1
@@ -3250,24 +3241,24 @@ explain extended select * from t1 where a in (select pk from t10) {
"considered_access_paths": [
{
"access_type": "scan",
- "rows": 10,
- "rows_after_scan": 10,
- "rows_after_filter": 10,
- "cost": 3.510986328,
+ "rows": 101,
+ "rows_after_filter": 101,
+ "rows_out": 101,
+ "cost": 0.025796905,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 3.510986328,
+ "rows_read": 101,
+ "rows_out": 101,
+ "cost": 0.025796905,
"uses_join_buffering": false
}
},
- "rows_for_plan": 10,
- "cost_for_plan": 3.510986328,
+ "rows_for_plan": 101,
+ "cost_for_plan": 0.025796905,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -3276,31 +3267,50 @@ explain extended select * from t1 where a in (select pk from t10) {
{
"fix_semijoin_strategies_for_picked_join_order": [
{
- "semi_join_strategy": "SJ-Materialization",
+ "semi_join_strategy": "FirstMatch",
"join_order": [
{
- "table": "t10"
+ "table": "t2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 4
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan",
+ "rows": 101,
+ "rows_after_filter": 101,
+ "rows_out": 101,
+ "cost": 0.10318762,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 101,
+ "rows_out": 101,
+ "cost": 0.10318762,
+ "uses_join_buffering": false
+ }
+ }
}
]
}
]
},
{
- "best_join_order": ["t1", "<subquery2>"],
- "rows": 3,
- "cost": 8.664282227
+ "best_join_order": ["t1", "t2"],
+ "rows": 4,
+ "cost": 0.074183853
},
{
"substitute_best_equal": {
"condition": "WHERE",
- "resulting_condition": "1"
+ "resulting_condition": "t2.p = t1.a"
}
},
{
- "condition_on_constant_tables": "1",
- "computing_condition": []
- },
- {
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
@@ -3309,12 +3319,8 @@ explain extended select * from t1 where a in (select pk from t10) {
"attached": null
},
{
- "table": "t10",
- "attached": null
- },
- {
- "table": "<subquery2>",
- "attached": null
+ "table": "t2",
+ "attached": "t2.p = t1.a"
}
]
}
@@ -3330,12 +3336,10 @@ explain extended select * from t1 where a in (select pk from t10) {
}
]
} 0 0
-drop table t0,t1,t11,t10,t12,t2;
+drop table t1,t2;
#
# Selectivities for columns and indexes.
#
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (
pk int,
a int,
@@ -3343,7 +3347,7 @@ b int,
key pk(pk),
key pk_a(pk,a),
key pk_a_b(pk,a,b));
-insert into t1 select a,a,a from t0;
+insert into t1 select seq,seq,seq from seq_0_to_9;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS (a,b) INDEXES ();
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -3451,7 +3455,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 3.515869141
+ "cost": 0.01156405
},
"potential_range_indexes": [
{
@@ -3472,7 +3476,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
],
"best_covering_index_scan": {
"index": "pk_a_b",
- "cost": 2.760739566,
+ "cost": 0.007173242,
"chosen": true
},
"setup_range_conditions": [],
@@ -3485,7 +3489,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270585794,
+ "cost": 0.002483968,
"chosen": true
},
{
@@ -3495,7 +3499,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270829876,
+ "cost": 0.002483968,
"chosen": false,
"cause": "cost"
},
@@ -3506,7 +3510,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 0.746073957,
+ "cost": 0.001388369,
"chosen": true
}
],
@@ -3514,10 +3518,10 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"intersecting_indexes": [
{
"index": "pk",
- "index_scan_cost": 0.525585794,
- "cumulated_index_scan_cost": 0.525585794,
- "disk_sweep_cost": 0.75,
- "cumulative_total_cost": 1.275585794,
+ "index_scan_cost": 0.000806227,
+ "cumulated_index_scan_cost": 0.000806227,
+ "disk_sweep_cost": 0.001143284,
+ "cumulative_total_cost": 0.001949511,
"usable": true,
"matching_rows_now": 1,
"intersect_covering_with_this_index": false,
@@ -3555,7 +3559,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"ranges": ["(2,5,1) <= (pk,a,b) <= (2,5,1)"]
},
"rows_for_plan": 1,
- "cost_for_plan": 0.746073957,
+ "cost_for_plan": 0.001388369,
"chosen": true
}
}
@@ -3565,17 +3569,17 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"rowid_filters": [
{
"key": "pk",
- "build_cost": 0.526585794,
+ "build_cost": 8.140695e-4,
"rows": 1
},
{
"key": "pk_a",
- "build_cost": 0.526829876,
+ "build_cost": 8.140695e-4,
"rows": 1
},
{
"key": "pk_a_b",
- "build_cost": 0.527073957,
+ "build_cost": 8.140695e-4,
"rows": 1
}
]
@@ -3618,7 +3622,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"index": "pk",
"used_range_estimates": true,
"rows": 1,
- "cost": 1.250585794,
+ "cost": 0.001933826,
"chosen": true
},
{
@@ -3626,7 +3630,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"index": "pk_a",
"used_range_estimates": true,
"rows": 1,
- "cost": 1.250829876,
+ "cost": 0.001933826,
"chosen": false,
"cause": "cost"
},
@@ -3635,7 +3639,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"index": "pk_a_b",
"used_range_estimates": true,
"rows": 1,
- "cost": 0.726073957,
+ "cost": 0.000838227,
"chosen": true
},
{
@@ -3646,22 +3650,21 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
],
"chosen_access_method": {
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 0.726073957,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.000838227,
"uses_join_buffering": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 0.726073957,
- "pruned_by_hanging_leaf": true
+ "cost_for_plan": 0.000838227
}
]
},
{
"best_join_order": ["t1"],
"rows": 1,
- "cost": 0.726073957
+ "cost": 0.000838227
},
{
"substitute_best_equal": {
@@ -3693,7 +3696,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
} 0 0
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set @@use_stat_tables= @save_use_stat_tables;
-drop table t0,t1;
+drop table t1;
set optimizer_trace="enabled=off";
#
# Tests added to show that sub-statements are not traced
@@ -3757,8 +3760,8 @@ select f1(a) from t1 {
"table": "t1",
"table_scan": {
"rows": 4,
- "read_cost": 1.003417969,
- "read_and_compare_cost": 2.003417969
+ "read_cost": 0.01049762,
+ "read_and_compare_cost": 0.01062562
}
}
]
@@ -3776,30 +3779,30 @@ select f1(a) from t1 {
{
"access_type": "scan",
"rows": 4,
- "rows_after_scan": 4,
"rows_after_filter": 4,
- "cost": 2.003417969,
+ "rows_out": 4,
+ "cost": 0.01062562,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 4,
- "records_out": 4,
- "cost": 2.003417969,
+ "rows_read": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"uses_join_buffering": false
}
},
"rows_for_plan": 4,
- "cost_for_plan": 2.003417969
+ "cost_for_plan": 0.01062562
}
]
},
{
"best_join_order": ["t1"],
"rows": 4,
- "cost": 2.003417969
+ "cost": 0.01062562
},
{
"attaching_conditions_to_tables": {
@@ -3863,8 +3866,8 @@ select f2(a) from t1 {
"table": "t1",
"table_scan": {
"rows": 4,
- "read_cost": 1.003417969,
- "read_and_compare_cost": 2.003417969
+ "read_cost": 0.01049762,
+ "read_and_compare_cost": 0.01062562
}
}
]
@@ -3882,30 +3885,30 @@ select f2(a) from t1 {
{
"access_type": "scan",
"rows": 4,
- "rows_after_scan": 4,
"rows_after_filter": 4,
- "cost": 2.003417969,
+ "rows_out": 4,
+ "cost": 0.01062562,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 4,
- "records_out": 4,
- "cost": 2.003417969,
+ "rows_read": 4,
+ "rows_out": 4,
+ "cost": 0.01062562,
"uses_join_buffering": false
}
},
"rows_for_plan": 4,
- "cost_for_plan": 2.003417969
+ "cost_for_plan": 0.01062562
}
]
},
{
"best_join_order": ["t1"],
"rows": 4,
- "cost": 2.003417969
+ "cost": 0.01062562
},
{
"attaching_conditions_to_tables": {
@@ -3946,7 +3949,7 @@ a
2
select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
length(trace)
-2470
+2451
set optimizer_trace_max_mem_size=100;
select * from t1;
a
@@ -3960,7 +3963,7 @@ select * from t1 {
"join_preparation": {
"select_id": 1,
"steps": [
- 2370 0
+ 2351 0
set optimizer_trace_max_mem_size=0;
select * from t1;
a
@@ -3968,7 +3971,7 @@ a
2
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
-select * from t1 2470 0
+select * from t1 2451 0
drop table t1;
set optimizer_trace='enabled=off';
set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size;
@@ -3993,7 +3996,7 @@ explain delete from t0 where t0.a<3 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 3.510986328
+ "cost": 0.01156405
},
"potential_range_indexes": [
{
@@ -4012,7 +4015,7 @@ explain delete from t0 where t0.a<3 {
"using_mrr": false,
"index_only": false,
"rows": 3,
- "cost": 2.771757383,
+ "cost": 0.004951706,
"chosen": true
}
],
@@ -4030,7 +4033,7 @@ explain delete from t0 where t0.a<3 {
"ranges": ["(NULL) < (a) < (3)"]
},
"rows_for_plan": 3,
- "cost_for_plan": 2.771757383,
+ "cost_for_plan": 0.004951706,
"chosen": true
}
}
@@ -4131,7 +4134,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 3.510986328
+ "cost": 0.01156405
},
"potential_range_indexes": [
{
@@ -4142,7 +4145,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 2.755857945,
+ "cost": 0.007173242,
"chosen": true
},
"setup_range_conditions": [],
@@ -4155,7 +4158,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"using_mrr": false,
"index_only": true,
"rows": 3,
- "cost": 1.196757383,
+ "cost": 0.001664909,
"chosen": true
}
],
@@ -4176,7 +4179,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"ranges": ["(NULL) < (a) < (3)"]
},
"rows_for_plan": 3,
- "cost_for_plan": 1.196757383,
+ "cost_for_plan": 0.001664909,
"chosen": true
}
}
@@ -4196,7 +4199,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 3.510986328
+ "cost": 0.01156405
},
"potential_range_indexes": [
{
@@ -4207,7 +4210,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 2.755857945,
+ "cost": 0.007173242,
"chosen": true
},
"setup_range_conditions": [],
@@ -4220,7 +4223,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"using_mrr": false,
"index_only": true,
"rows": 3,
- "cost": 1.196757383,
+ "cost": 0.001664909,
"chosen": true
}
],
@@ -4241,7 +4244,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"ranges": ["(NULL) < (a) < (3)"]
},
"rows_for_plan": 3,
- "cost_for_plan": 1.196757383,
+ "cost_for_plan": 0.001664909,
"chosen": true
}
}
@@ -4271,22 +4274,22 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
{
"access_type": "range",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.196757383,
+ "rows_out": 3,
+ "cost": 0.001664909,
"chosen": true
}
],
"chosen_access_method": {
"type": "range",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.196757383,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.001664909,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.196757383,
+ "cost_for_plan": 0.001664909,
"rest_of_plan": [
{
"plan_prefix": ["t0"],
@@ -4302,7 +4305,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"used_range_estimates": false,
"cause": "not better than ref estimates",
"rows": 1,
- "cost": 2.176757383,
+ "cost": 0.002105081,
"chosen": true
},
{
@@ -4313,15 +4316,14 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
],
"chosen_access_method": {
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 2.176757383,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.002105081,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 3.373514767,
- "pruned_by_hanging_leaf": true
+ "cost_for_plan": 0.00376999
}
]
},
@@ -4336,22 +4338,22 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
{
"access_type": "range",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.196757383,
+ "rows_out": 3,
+ "cost": 0.001664909,
"chosen": true
}
],
"chosen_access_method": {
"type": "range",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.196757383,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.001664909,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.196757383,
+ "cost_for_plan": 0.001664909,
"rest_of_plan": [
{
"plan_prefix": ["t1"],
@@ -4368,7 +4370,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"used_range_estimates": false,
"cause": "not better than ref estimates",
"rows": 2,
- "cost": 2.853514767,
+ "cost": 0.002519891,
"chosen": true
},
{
@@ -4379,14 +4381,14 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
],
"chosen_access_method": {
"type": "ref",
- "records_read": 2,
- "records_out": 1.166666667,
- "cost": 2.853514767,
+ "rows_read": 2,
+ "rows_out": 2,
+ "cost": 0.002519891,
"uses_join_buffering": false
}
},
"rows_for_plan": 6,
- "cost_for_plan": 4.05027215,
+ "cost_for_plan": 0.0041848,
"pruned_by_cost": true
}
]
@@ -4396,7 +4398,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
{
"best_join_order": ["t0", "t1"],
"rows": 3,
- "cost": 3.373514767
+ "cost": 0.00376999
},
{
"substitute_best_equal": {
@@ -4505,8 +4507,8 @@ explain select * from (select rand() from t1)q {
"table": "t1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
}
]
@@ -4524,30 +4526,30 @@ explain select * from (select rand() from t1)q {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477
+ "cost_for_plan": 0.010469215
}
]
},
{
"best_join_order": ["t1"],
"rows": 3,
- "cost": 1.752563477
+ "cost": 0.010469215
},
{
"attaching_conditions_to_tables": {
@@ -4579,8 +4581,8 @@ explain select * from (select rand() from t1)q {
"table": "<derived2>",
"table_scan": {
"rows": 3,
- "read_cost": 3,
- "read_and_compare_cost": 3.75
+ "read_cost": 0.01235805,
+ "read_and_compare_cost": 0.012461052
}
}
]
@@ -4598,30 +4600,30 @@ explain select * from (select rand() from t1)q {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.75,
+ "rows_out": 3,
+ "cost": 0.012461052,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.75,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.012461052,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 3.75
+ "cost_for_plan": 0.012461052
}
]
},
{
"best_join_order": ["<derived2>"],
"rows": 3,
- "cost": 3.75
+ "cost": 0.012461052
},
{
"attaching_conditions_to_tables": {
@@ -4773,24 +4775,24 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"table": "t1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
"table": "t_inner_1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
"table": "t_inner_2",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
}
]
@@ -4816,23 +4818,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"rest_of_plan": [
{
"plan_prefix": ["t_inner_1"],
@@ -4845,23 +4847,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953
+ "cost_for_plan": 0.021956822
}
]
},
@@ -4876,23 +4878,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"pruned_by_heuristic": true
}
]
@@ -4913,23 +4915,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -4943,23 +4945,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953,
+ "cost_for_plan": 0.021956822,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -4973,46 +4975,51 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 9.177563477,
+ "rows_out": 3,
+ "cost": 0.015167773,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 9.177563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.015167773,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 14.82019043,
+ "cost_for_plan": 0.037124595,
"semijoin_strategy_choice": [
{
"strategy": "FirstMatch",
- "records": 3,
- "cost": 22.7833252
+ "rows": 3,
+ "cost": 0.136099795
},
{
"strategy": "SJ-Materialization",
- "records": 3,
- "cost": 10.64519043
+ "rows": 3,
+ "cost": 0.059481685
},
{
"strategy": "DuplicateWeedout",
- "records": 3,
- "dups_cost": 14.82019043,
- "write_cost": 1.45,
- "full_lookup_cost": 4.05,
- "total_cost": 20.32019043
+ "prefix_record_count": 3,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 9,
+ "rows": 3,
+ "dups_cost": 0.037124595,
+ "write_cost": 0.02548291,
+ "full_lookup_cost": 0.00434619,
+ "total_cost": 0.066953695
},
{
"chosen_strategy": "SJ-Materialization"
}
- ]
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 3
}
]
},
@@ -5027,23 +5034,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953,
+ "cost_for_plan": 0.021956822,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -5060,23 +5067,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -5091,23 +5098,23 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -5131,7 +5138,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
{
"best_join_order": ["t1", "<subquery2>"],
"rows": 3,
- "cost": 10.64519043
+ "cost": 0.059481685
},
{
"substitute_best_equal": {
@@ -5183,11 +5190,11 @@ explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_
t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t_outer_1 ALL NULL NULL NULL NULL 3
-1 PRIMARY t_inner_1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 PRIMARY t_inner_2 ALL NULL NULL NULL NULL 9 FirstMatch(t_outer_1); Using join buffer (incremental, BNL join)
+1 PRIMARY t_inner_1 ALL NULL NULL NULL NULL 3 Using where; Start temporary; Using join buffer (flat, BNL join)
+1 PRIMARY t_inner_2 ALL NULL NULL NULL NULL 9 End temporary; Using join buffer (incremental, BNL join)
+1 PRIMARY t_inner_4 ALL NULL NULL NULL NULL 3 Start temporary; Using join buffer (incremental, BNL join)
1 PRIMARY t_outer_2 ALL NULL NULL NULL NULL 9 Using join buffer (incremental, BNL join)
-1 PRIMARY t_inner_4 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join)
-1 PRIMARY t_inner_3 ALL NULL NULL NULL NULL 9 Using where; FirstMatch(t_outer_2); Using join buffer (incremental, BNL join)
+1 PRIMARY t_inner_3 ALL NULL NULL NULL NULL 9 Using where; End temporary; Using join buffer (incremental, BNL join)
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
explain select * from t1 t_outer_1,t2 t_outer_2 where t_outer_1.a in (select t_inner_1.a from t2 t_inner_2, t1 t_inner_1) and
@@ -5346,48 +5353,48 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"table": "t_outer_1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
"table": "t_outer_2",
"table_scan": {
"rows": 9,
- "read_cost": 1.00769043,
- "read_and_compare_cost": 3.25769043
+ "read_cost": 0.011119645,
+ "read_and_compare_cost": 0.011407645
}
},
{
"table": "t_inner_2",
"table_scan": {
"rows": 9,
- "read_cost": 1.00769043,
- "read_and_compare_cost": 3.25769043
+ "read_cost": 0.011119645,
+ "read_and_compare_cost": 0.011407645
}
},
{
"table": "t_inner_1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
"table": "t_inner_3",
"table_scan": {
"rows": 9,
- "read_cost": 1.00769043,
- "read_and_compare_cost": 3.25769043
+ "read_cost": 0.011119645,
+ "read_and_compare_cost": 0.011407645
}
},
{
"table": "t_inner_4",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
}
]
@@ -5420,23 +5427,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5450,23 +5457,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953,
+ "cost_for_plan": 0.021956822,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5480,41 +5487,46 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 25.53269043,
+ "rows_out": 9,
+ "cost": 0.024407731,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 25.53269043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.024407731,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 31.17531738,
+ "cost_for_plan": 0.046364553,
"semijoin_strategy_choice": [
{
"strategy": "FirstMatch",
- "records": 3,
- "cost": 36.32946777
+ "rows": 3,
+ "cost": 0.144545665
},
{
"strategy": "DuplicateWeedout",
- "records": 3,
- "dups_cost": 31.17531738,
- "write_cost": 1.45,
- "full_lookup_cost": 12.15,
- "total_cost": 44.77531738
+ "prefix_record_count": 3,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 27,
+ "rows": 3,
+ "dups_cost": 0.046364553,
+ "write_cost": 0.02548291,
+ "full_lookup_cost": 0.01303857,
+ "total_cost": 0.084886033
},
{
- "chosen_strategy": "FirstMatch"
+ "chosen_strategy": "DuplicateWeedout"
}
],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 3,
"rest_of_plan": [
{
"plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"],
@@ -5527,23 +5539,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 11.69519043,
+ "rows_out": 9,
+ "cost": 0.017384389,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 11.69519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.017384389,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 48.0246582,
+ "cost_for_plan": 0.102270422,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5562,23 +5574,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 30.10256348,
+ "rows_out": 3,
+ "cost": 0.034425181,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 30.10256348,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.034425181,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 78.12722168,
+ "cost_for_plan": 0.136695603,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5598,41 +5610,46 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 285.7451904,
+ "rows_out": 9,
+ "cost": 0.261522361,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 285.7451904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 363.8724121,
+ "cost_for_plan": 0.398217964,
"semijoin_strategy_choice": [
{
"strategy": "FirstMatch",
- "records": 27,
- "cost": 359.2167969
+ "rows": 27,
+ "cost": 1.308958472
},
{
"strategy": "DuplicateWeedout",
- "records": 27,
- "dups_cost": 363.8724121,
- "write_cost": 5.05,
- "full_lookup_cost": 109.35,
- "total_cost": 478.2724121
+ "prefix_record_count": 27,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.398217964,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.544911284
},
{
- "chosen_strategy": "FirstMatch"
+ "chosen_strategy": "DuplicateWeedout"
}
- ]
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27
}
]
},
@@ -5652,23 +5669,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 88.30769043,
+ "rows_out": 9,
+ "cost": 0.079988779,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 88.30769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.079988779,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 136.3323486,
+ "cost_for_plan": 0.182259201,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -5685,23 +5702,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 4.565063477,
+ "rows_out": 3,
+ "cost": 0.012583195,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 4.565063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.012583195,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 40.89453125,
+ "cost_for_plan": 0.097469228,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5720,23 +5737,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 31.60769043,
+ "rows_out": 9,
+ "cost": 0.034268023,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 31.60769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.034268023,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 72.50222168,
+ "cost_for_plan": 0.131737251,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5756,37 +5773,41 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 285.7451904,
+ "rows_out": 9,
+ "cost": 0.261522361,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 285.7451904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 358.2474121,
+ "cost_for_plan": 0.393259612,
"semijoin_strategy_choice": [
{
"strategy": "DuplicateWeedout",
- "records": 27,
- "dups_cost": 358.2474121,
- "write_cost": 5.05,
- "full_lookup_cost": 109.35,
- "total_cost": 472.6474121
+ "prefix_record_count": 3,
+ "tmp_table_records": 9,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.393259612,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.539952932
},
{
"chosen_strategy": "DuplicateWeedout"
}
],
- "pruned_by_cost": true
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27
}
]
},
@@ -5806,23 +5827,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 31.60769043,
+ "rows_out": 9,
+ "cost": 0.034268023,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 31.60769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.034268023,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 72.50222168,
+ "cost_for_plan": 0.131737251,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -5839,23 +5860,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 11.69519043,
+ "rows_out": 9,
+ "cost": 0.017384389,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 11.69519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.017384389,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 48.0246582,
+ "cost_for_plan": 0.102270422,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -5872,23 +5893,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 25.53269043,
+ "rows_out": 9,
+ "cost": 0.024407731,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 25.53269043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.024407731,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 31.17531738,
+ "cost_for_plan": 0.046364553,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5902,37 +5923,175 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 231.0701904,
+ "rows_out": 9,
+ "cost": 0.172779733,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 231.0701904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 262.2455078,
+ "cost_for_plan": 0.219144286,
"semijoin_strategy_choice": [
{
"strategy": "DuplicateWeedout",
- "records": 27,
- "dups_cost": 262.2455078,
- "write_cost": 5.05,
- "full_lookup_cost": 109.35,
- "total_cost": 376.6455078
+ "prefix_record_count": 3,
+ "tmp_table_records": 9,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.219144286,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.365837606
},
{
"chosen_strategy": "DuplicateWeedout"
}
],
- "pruned_by_cost": true
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27,
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_2"
+ ],
+ "table": "t_inner_4",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 27
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 3,
+ "rows_after_filter": 3,
+ "rows_out": 3,
+ "cost": 0.034425181,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.034425181,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 81,
+ "cost_for_plan": 0.400262787,
+ "semijoin_strategy_choice": [],
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_2",
+ "t_inner_4"
+ ],
+ "table": "t_inner_3",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 729,
+ "cost_for_plan": 0.661785148,
+ "semijoin_strategy_choice": [
+ {
+ "strategy": "FirstMatch",
+ "rows": 27,
+ "cost": 1.572525656
+ },
+ {
+ "strategy": "DuplicateWeedout",
+ "prefix_record_count": 27,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.661785148,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.808478468
+ },
+ {
+ "chosen_strategy": "DuplicateWeedout"
+ }
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27,
+ "pruned_by_cost": true
+ }
+ ]
+ },
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_2"
+ ],
+ "table": "t_inner_3",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 27
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.079988779,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.079988779,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 243,
+ "cost_for_plan": 0.445826385,
+ "semijoin_strategy_choice": [],
+ "pruned_by_heuristic": true
+ }
+ ]
},
{
"plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"],
@@ -5945,23 +6104,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 77.69006348,
+ "rows_out": 3,
+ "cost": 0.067546675,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 77.69006348,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.067546675,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 108.8653809,
+ "cost_for_plan": 0.113911228,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -5980,23 +6139,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 768.7076904,
+ "rows_out": 9,
+ "cost": 0.628637851,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 768.7076904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 877.5730713,
+ "cost_for_plan": 0.742549079,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
},
@@ -6016,23 +6175,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 768.7076904,
+ "rows_out": 9,
+ "cost": 0.628637851,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 768.7076904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 877.5730713,
+ "cost_for_plan": 0.742549079,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
}
@@ -6049,25 +6208,98 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 231.0701904,
+ "rows_out": 9,
+ "cost": 0.172779733,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 231.0701904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 262.2455078,
+ "cost_for_plan": 0.219144286,
"semijoin_strategy_choice": [],
- "pruned_by_heuristic": true
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_3"
+ ],
+ "table": "t_inner_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 729
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 1.863098263,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 1.863098263,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 6561,
+ "cost_for_plan": 2.082242549,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_3"
+ ],
+ "table": "t_inner_4",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 729
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 3,
+ "rows_after_filter": 3,
+ "rows_out": 3,
+ "cost": 0.657280297,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.657280297,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.876424583,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ }
+ ]
}
]
},
@@ -6082,23 +6314,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 9.177563477,
+ "rows_out": 3,
+ "cost": 0.015167773,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 9.177563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.015167773,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 14.82019043,
+ "cost_for_plan": 0.037124595,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -6112,23 +6344,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 79.19519043,
+ "rows_out": 9,
+ "cost": 0.065198341,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 79.19519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.065198341,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 94.01538086,
+ "cost_for_plan": 0.102322936,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -6147,23 +6379,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 768.7076904,
+ "rows_out": 9,
+ "cost": 0.628637851,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 768.7076904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 862.7230713,
+ "cost_for_plan": 0.730960787,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
},
@@ -6183,23 +6415,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 768.7076904,
+ "rows_out": 9,
+ "cost": 0.628637851,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 768.7076904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 862.7230713,
+ "cost_for_plan": 0.730960787,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
}
@@ -6216,23 +6448,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 79.19519043,
+ "rows_out": 9,
+ "cost": 0.065198341,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 79.19519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.065198341,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 94.01538086,
+ "cost_for_plan": 0.102322936,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6247,23 +6479,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 79.19519043,
+ "rows_out": 9,
+ "cost": 0.065198341,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 79.19519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.065198341,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 94.01538086,
+ "cost_for_plan": 0.102322936,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -6280,23 +6512,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 25.53269043,
+ "rows_out": 9,
+ "cost": 0.024407731,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 25.53269043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.024407731,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 31.17531738,
+ "cost_for_plan": 0.046364553,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -6310,23 +6542,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 231.0701904,
+ "rows_out": 9,
+ "cost": 0.172779733,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 231.0701904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 262.2455078,
+ "cost_for_plan": 0.219144286,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -6345,23 +6577,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 2299.60769,
+ "rows_out": 9,
+ "cost": 1.863098263,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 2299.60769,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 1.863098263,
"uses_join_buffering": true
}
},
"rows_for_plan": 6561,
- "cost_for_plan": 2561.853198,
+ "cost_for_plan": 2.082242549,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
},
@@ -6381,23 +6613,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 767.2025635,
+ "rows_out": 3,
+ "cost": 0.657280297,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 767.2025635,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.657280297,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 1029.448071,
+ "cost_for_plan": 0.876424583,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
}
@@ -6414,23 +6646,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 231.0701904,
+ "rows_out": 9,
+ "cost": 0.172779733,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 231.0701904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 262.2455078,
+ "cost_for_plan": 0.219144286,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6445,23 +6677,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 77.69006348,
+ "rows_out": 3,
+ "cost": 0.067546675,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 77.69006348,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.067546675,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 108.8653809,
+ "cost_for_plan": 0.113911228,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -6480,23 +6712,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 768.7076904,
+ "rows_out": 9,
+ "cost": 0.628637851,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 768.7076904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 877.5730713,
+ "cost_for_plan": 0.742549079,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
},
@@ -6516,23 +6748,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 768.7076904,
+ "rows_out": 9,
+ "cost": 0.628637851,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 768.7076904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
"uses_join_buffering": true
}
},
"rows_for_plan": 2187,
- "cost_for_plan": 877.5730713,
+ "cost_for_plan": 0.742549079,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
}
@@ -6553,23 +6785,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391,
+ "cost_for_plan": 0.02456684,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6584,23 +6816,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391,
+ "cost_for_plan": 0.02456684,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6615,23 +6847,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953,
+ "cost_for_plan": 0.021956822,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6646,23 +6878,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391,
+ "cost_for_plan": 0.02456684,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -6679,23 +6911,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6710,23 +6942,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6741,23 +6973,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6772,23 +7004,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -6803,23 +7035,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -6828,118 +7060,10 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"fix_semijoin_strategies_for_picked_join_order": [
{
- "semi_join_strategy": "FirstMatch",
- "join_order": [
- {
- "table": "t_inner_4",
- "best_access_path": {
- "plan_details": {
- "record_count": 27
- },
- "considered_access_paths": [
- {
- "access_type": "scan",
- "rows": 3,
- "rows_after_scan": 3,
- "rows_after_filter": 3,
- "cost": 47.31921387,
- "index_only": false,
- "chosen": true
- }
- ],
- "chosen_access_method": {
- "type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 47.31921387,
- "uses_join_buffering": false
- }
- }
- },
- {
- "table": "t_inner_3",
- "best_access_path": {
- "plan_details": {
- "record_count": 81
- },
- "considered_access_paths": [
- {
- "access_type": "scan",
- "rows": 9,
- "rows_after_scan": 9,
- "rows_after_filter": 9,
- "cost": 263.8729248,
- "index_only": false,
- "chosen": true
- }
- ],
- "chosen_access_method": {
- "type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 263.8729248,
- "uses_join_buffering": false
- }
- }
- }
- ]
+ "semi_join_strategy": "DuplicateWeedout"
},
{
- "semi_join_strategy": "FirstMatch",
- "join_order": [
- {
- "table": "t_inner_1",
- "best_access_path": {
- "plan_details": {
- "record_count": 3
- },
- "considered_access_paths": [
- {
- "access_type": "scan",
- "rows": 3,
- "rows_after_scan": 3,
- "rows_after_filter": 3,
- "cost": 5.25769043,
- "index_only": false,
- "chosen": true
- }
- ],
- "chosen_access_method": {
- "type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 5.25769043,
- "uses_join_buffering": false
- }
- }
- },
- {
- "table": "t_inner_2",
- "best_access_path": {
- "plan_details": {
- "record_count": 9
- },
- "considered_access_paths": [
- {
- "access_type": "scan",
- "rows": 9,
- "rows_after_scan": 9,
- "rows_after_filter": 9,
- "cost": 29.31921387,
- "index_only": false,
- "chosen": true
- }
- ],
- "chosen_access_method": {
- "type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 29.31921387,
- "uses_join_buffering": false
- }
- }
- }
- ]
+ "semi_join_strategy": "DuplicateWeedout"
}
]
},
@@ -6948,12 +7072,12 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"t_outer_1",
"t_inner_1",
"t_inner_2",
- "t_outer_2",
"t_inner_4",
+ "t_outer_2",
"t_inner_3"
],
"rows": 27,
- "cost": 359.2167969
+ "cost": 0.539952932
},
{
"substitute_best_equal": {
@@ -6978,11 +7102,11 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"attached": null
},
{
- "table": "t_outer_2",
+ "table": "t_inner_4",
"attached": null
},
{
- "table": "t_inner_4",
+ "table": "t_outer_2",
"attached": null
},
{
@@ -7173,48 +7297,48 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"table": "t_outer_1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
"table": "t_outer_2",
"table_scan": {
"rows": 9,
- "read_cost": 1.00769043,
- "read_and_compare_cost": 3.25769043
+ "read_cost": 0.011119645,
+ "read_and_compare_cost": 0.011407645
}
},
{
"table": "t_inner_2",
"table_scan": {
"rows": 9,
- "read_cost": 1.00769043,
- "read_and_compare_cost": 3.25769043
+ "read_cost": 0.011119645,
+ "read_and_compare_cost": 0.011407645
}
},
{
"table": "t_inner_1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
"table": "t_inner_3",
"table_scan": {
"rows": 9,
- "read_cost": 1.00769043,
- "read_and_compare_cost": 3.25769043
+ "read_cost": 0.011119645,
+ "read_and_compare_cost": 0.011407645
}
},
{
"table": "t_inner_4",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
}
]
@@ -7245,23 +7369,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"rest_of_plan": [
{
"plan_prefix": ["t_inner_1"],
@@ -7274,23 +7398,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391
+ "cost_for_plan": 0.02456684
}
]
},
@@ -7305,23 +7429,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"pruned_by_heuristic": true
}
]
@@ -7339,23 +7463,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"rest_of_plan": [
{
"plan_prefix": ["t_inner_4"],
@@ -7368,23 +7492,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391
+ "cost_for_plan": 0.02456684
}
]
},
@@ -7399,23 +7523,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"pruned_by_heuristic": true
}
]
@@ -7436,23 +7560,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7466,23 +7590,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953,
+ "cost_for_plan": 0.021956822,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7496,46 +7620,51 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 25.53269043,
+ "rows_out": 9,
+ "cost": 0.024407731,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 25.53269043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.024407731,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 31.17531738,
+ "cost_for_plan": 0.046364553,
"semijoin_strategy_choice": [
{
"strategy": "FirstMatch",
- "records": 3,
- "cost": 36.32946777
+ "rows": 3,
+ "cost": 0.144545665
},
{
"strategy": "SJ-Materialization",
- "records": 3,
- "cost": 19.12531738
+ "rows": 3,
+ "cost": 0.065031175
},
{
"strategy": "DuplicateWeedout",
- "records": 3,
- "dups_cost": 31.17531738,
- "write_cost": 1.45,
- "full_lookup_cost": 12.15,
- "total_cost": 44.77531738
+ "prefix_record_count": 3,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 27,
+ "rows": 3,
+ "dups_cost": 0.046364553,
+ "write_cost": 0.02548291,
+ "full_lookup_cost": 0.01303857,
+ "total_cost": 0.084886033
},
{
"chosen_strategy": "SJ-Materialization"
}
],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 3,
"rest_of_plan": [
{
"plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_2"],
@@ -7548,23 +7677,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 11.69519043,
+ "rows_out": 9,
+ "cost": 0.017384389,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 11.69519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.017384389,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 30.82050781,
+ "cost_for_plan": 0.082415564,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7583,23 +7712,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 30.10256348,
+ "rows_out": 3,
+ "cost": 0.034425181,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 30.10256348,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.034425181,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 60.92307129,
+ "cost_for_plan": 0.116840745,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7619,46 +7748,51 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 285.7451904,
+ "rows_out": 9,
+ "cost": 0.261522361,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 285.7451904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 346.6682617,
+ "cost_for_plan": 0.378363106,
"semijoin_strategy_choice": [
{
"strategy": "FirstMatch",
- "records": 27,
- "cost": 342.0126465
+ "rows": 27,
+ "cost": 1.289103614
},
{
"strategy": "SJ-Materialization",
- "records": 27,
- "cost": 55.39326172
+ "rows": 27,
+ "cost": 0.14166482
},
{
"strategy": "DuplicateWeedout",
- "records": 27,
- "dups_cost": 346.6682617,
- "write_cost": 5.05,
- "full_lookup_cost": 109.35,
- "total_cost": 461.0682617
+ "prefix_record_count": 27,
+ "tmp_table_records": 1,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.378363106,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.525056426
},
{
"chosen_strategy": "SJ-Materialization"
}
- ]
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27
}
]
},
@@ -7678,23 +7812,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 88.30769043,
+ "rows_out": 9,
+ "cost": 0.079988779,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 88.30769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.079988779,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 119.1281982,
+ "cost_for_plan": 0.162404343,
"semijoin_strategy_choice": [],
"pruned_by_cost": true
}
@@ -7711,23 +7845,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 4.565063477,
+ "rows_out": 3,
+ "cost": 0.012583195,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 4.565063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.012583195,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 23.69038086,
+ "cost_for_plan": 0.07761437,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7746,23 +7880,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 31.60769043,
+ "rows_out": 9,
+ "cost": 0.034268023,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 31.60769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.034268023,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 55.29807129,
+ "cost_for_plan": 0.111882393,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7782,36 +7916,41 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 285.7451904,
+ "rows_out": 9,
+ "cost": 0.261522361,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 285.7451904,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
"uses_join_buffering": true
}
},
"rows_for_plan": 729,
- "cost_for_plan": 341.0432617,
+ "cost_for_plan": 0.373404754,
"semijoin_strategy_choice": [
{
"strategy": "DuplicateWeedout",
- "records": 27,
- "dups_cost": 341.0432617,
- "write_cost": 5.05,
- "full_lookup_cost": 109.35,
- "total_cost": 455.4432617
+ "prefix_record_count": 3,
+ "tmp_table_records": 9,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.373404754,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.520098074
},
{
"chosen_strategy": "DuplicateWeedout"
}
],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27,
"pruned_by_cost": true
}
]
@@ -7832,23 +7971,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 31.60769043,
+ "rows_out": 9,
+ "cost": 0.034268023,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 31.60769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.034268023,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 55.29807129,
+ "cost_for_plan": 0.111882393,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -7865,23 +8004,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 11.69519043,
+ "rows_out": 9,
+ "cost": 0.017384389,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 11.69519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.017384389,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 30.82050781,
+ "cost_for_plan": 0.082415564,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -7898,25 +8037,275 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 25.53269043,
+ "rows_out": 9,
+ "cost": 0.024407731,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 25.53269043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.024407731,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 31.17531738,
+ "cost_for_plan": 0.046364553,
"semijoin_strategy_choice": [],
- "pruned_by_heuristic": true
+ "rest_of_plan": [
+ {
+ "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"],
+ "table": "t_inner_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 729,
+ "cost_for_plan": 0.219144286,
+ "semijoin_strategy_choice": [
+ {
+ "strategy": "DuplicateWeedout",
+ "prefix_record_count": 3,
+ "tmp_table_records": 9,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 0.219144286,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 0.365837606
+ },
+ {
+ "chosen_strategy": "DuplicateWeedout"
+ }
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27,
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"],
+ "table": "t_inner_4",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 3,
+ "rows_after_filter": 3,
+ "rows_out": 3,
+ "cost": 0.067546675,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.067546675,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 243,
+ "cost_for_plan": 0.113911228,
+ "semijoin_strategy_choice": [],
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_4"
+ ],
+ "table": "t_inner_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 243
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.742549079,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_4"
+ ],
+ "table": "t_inner_3",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 243
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.742549079,
+ "semijoin_strategy_choice": [
+ {
+ "strategy": "SJ-Materialization",
+ "rows": 81,
+ "cost": 0.116160225
+ },
+ {
+ "chosen_strategy": "SJ-Materialization"
+ }
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 81,
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_outer_2",
+ "t_inner_4",
+ "t_inner_3"
+ ],
+ "table": "t_inner_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.261522361,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 729,
+ "cost_for_plan": 0.377682586,
+ "semijoin_strategy_choice": [
+ {
+ "strategy": "DuplicateWeedout",
+ "prefix_record_count": 3,
+ "tmp_table_records": 9,
+ "sj_inner_fanout": 27,
+ "rows": 27,
+ "dups_cost": 1.00407144,
+ "write_cost": 0.02934619,
+ "full_lookup_cost": 0.11734713,
+ "total_cost": 1.15076476
+ },
+ {
+ "chosen_strategy": "DuplicateWeedout"
+ }
+ ],
+ "rows_out": 0.333333333,
+ "rows_for_plan": 27,
+ "pruned_by_cost": true
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "plan_prefix": ["t_outer_1", "t_inner_1", "t_outer_2"],
+ "table": "t_inner_3",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 729,
+ "cost_for_plan": 0.219144286,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ }
+ ]
},
{
"plan_prefix": ["t_outer_1", "t_inner_1"],
@@ -7929,23 +8318,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 9.177563477,
+ "rows_out": 3,
+ "cost": 0.015167773,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 9.177563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.015167773,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 14.82019043,
+ "cost_for_plan": 0.037124595,
"semijoin_strategy_choice": [],
"rest_of_plan": [
{
@@ -7959,25 +8348,98 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 79.19519043,
+ "rows_out": 9,
+ "cost": 0.065198341,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 79.19519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.065198341,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 94.01538086,
+ "cost_for_plan": 0.102322936,
"semijoin_strategy_choice": [],
- "pruned_by_cost": true
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_inner_4",
+ "t_inner_2"
+ ],
+ "table": "t_outer_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 243
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.730960787,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_inner_4",
+ "t_inner_2"
+ ],
+ "table": "t_inner_3",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 243
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.730960787,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ }
+ ]
},
{
"plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"],
@@ -7990,25 +8452,25 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 79.19519043,
+ "rows_out": 9,
+ "cost": 0.065198341,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 79.19519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.065198341,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 94.01538086,
+ "cost_for_plan": 0.102322936,
"semijoin_strategy_choice": [],
- "pruned_by_cost": true
+ "pruned_by_heuristic": true
},
{
"plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_4"],
@@ -8021,25 +8483,25 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 79.19519043,
+ "rows_out": 9,
+ "cost": 0.065198341,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 79.19519043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.065198341,
"uses_join_buffering": true
}
},
"rows_for_plan": 243,
- "cost_for_plan": 94.01538086,
+ "cost_for_plan": 0.102322936,
"semijoin_strategy_choice": [],
- "pruned_by_cost": true
+ "pruned_by_heuristic": true
}
]
},
@@ -8054,25 +8516,203 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 25.53269043,
+ "rows_out": 9,
+ "cost": 0.024407731,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 25.53269043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.024407731,
"uses_join_buffering": true
}
},
"rows_for_plan": 81,
- "cost_for_plan": 31.17531738,
+ "cost_for_plan": 0.046364553,
"semijoin_strategy_choice": [],
- "pruned_by_heuristic": true
+ "rest_of_plan": [
+ {
+ "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_3"],
+ "table": "t_inner_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 729,
+ "cost_for_plan": 0.219144286,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_3"],
+ "table": "t_outer_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.172779733,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 729,
+ "cost_for_plan": 0.219144286,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": ["t_outer_1", "t_inner_1", "t_inner_3"],
+ "table": "t_inner_4",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 81
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 3,
+ "rows_after_filter": 3,
+ "rows_out": 3,
+ "cost": 0.067546675,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.067546675,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 243,
+ "cost_for_plan": 0.113911228,
+ "semijoin_strategy_choice": [],
+ "rest_of_plan": [
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_inner_3",
+ "t_inner_4"
+ ],
+ "table": "t_inner_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 243
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.742549079,
+ "semijoin_strategy_choice": [],
+ "pruned_by_cost": true
+ },
+ {
+ "plan_prefix": [
+ "t_outer_1",
+ "t_inner_1",
+ "t_inner_3",
+ "t_inner_4"
+ ],
+ "table": "t_outer_2",
+ "best_access_path": {
+ "plan_details": {
+ "record_count": 243
+ },
+ "considered_access_paths": [
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 9,
+ "rows_after_filter": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method": {
+ "type": "scan",
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.628637851,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 2187,
+ "cost_for_plan": 0.742549079,
+ "semijoin_strategy_choice": [
+ {
+ "strategy": "SJ-Materialization-Scan",
+ "rows": 729,
+ "cost": 0.388014063
+ },
+ {
+ "chosen_strategy": "SJ-Materialization-Scan"
+ }
+ ],
+ "rows_out": 3,
+ "rows_for_plan": 729,
+ "pruned_by_cost": true
+ }
+ ]
+ }
+ ]
}
]
},
@@ -8087,23 +8727,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391,
+ "cost_for_plan": 0.02456684,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8118,23 +8758,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391,
+ "cost_for_plan": 0.02456684,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8149,23 +8789,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 3.890063477,
+ "rows_out": 3,
+ "cost": 0.011487607,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 3.890063477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.011487607,
"uses_join_buffering": true
}
},
"rows_for_plan": 9,
- "cost_for_plan": 5.642626953,
+ "cost_for_plan": 0.021956822,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8180,23 +8820,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan_with_join_cache",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 9.67019043,
+ "rows_out": 9,
+ "cost": 0.014097625,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 9.67019043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.014097625,
"uses_join_buffering": true
}
},
"rows_for_plan": 27,
- "cost_for_plan": 11.42275391,
+ "cost_for_plan": 0.02456684,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -8213,23 +8853,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8244,23 +8884,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8275,23 +8915,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8306,23 +8946,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
},
@@ -8337,23 +8977,23 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
{
"access_type": "scan",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 9,
- "cost": 3.25769043,
+ "rows_out": 9,
+ "cost": 0.011407645,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 9,
- "records_out": 9,
- "cost": 3.25769043,
+ "rows_read": 9,
+ "rows_out": 9,
+ "cost": 0.011407645,
"uses_join_buffering": false
}
},
"rows_for_plan": 9,
- "cost_for_plan": 3.25769043,
+ "cost_for_plan": 0.011407645,
"semijoin_strategy_choice": [],
"pruned_by_heuristic": true
}
@@ -8393,7 +9033,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"<subquery3>"
],
"rows": 27,
- "cost": 55.39326172
+ "cost": 0.14166482
},
{
"substitute_best_equal": {
@@ -8501,7 +9141,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 0.745829876,
+ "cost": 0.001388369,
"chosen": true
}
],
@@ -8535,7 +9175,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 107,
- "cost": 24.68379668,
+ "cost": 0.016044989,
"chosen": true
}
],
@@ -8572,7 +9212,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1000,
- "cost": 756.2522431,
+ "cost": 1.235599899,
"chosen": true
}
],
@@ -8617,7 +9257,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 4,
- "cost": 3.523710032,
+ "cost": 0.006185575,
"chosen": true
}
],
@@ -8656,7 +9296,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.271171589,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8690,7 +9330,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.271171589,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8732,7 +9372,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270927508,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8767,7 +9407,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270878692,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8802,7 +9442,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270927508,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8840,7 +9480,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270878692,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8881,7 +9521,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.319255553,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -8901,7 +9541,7 @@ INSERT INTO t1 VALUES (2, 'ab\n');
set optimizer_trace=1;
EXPLAIN SELECT * FROM t1 WHERE b='ab\n';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL i_b NULL NULL NULL 2 Using where
+1 SIMPLE t1 ref i_b i_b 13 const 2 Using index condition
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
[
@@ -8920,9 +9560,8 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2,
- "cost": 2.021855016,
- "chosen": false,
- "cause": "cost"
+ "cost": 0.003717837,
+ "chosen": true
}
],
"analyzing_roworder_intersect":
@@ -8977,7 +9616,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1000,
- "cost": 756.2522431,
+ "cost": 1.235599899,
"chosen": true
}
],
@@ -9046,9 +9685,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 10,
- "rows_after_scan": 5.9375,
"rows_after_filter": 5.9375,
- "cost": 3.508544922,
+ "rows_out": 5.9375,
+ "cost": 0.01156405,
"index_only": false,
"chosen": true
}
@@ -9056,14 +9695,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 5.9375,
- "records_out": 5.9375,
- "cost": 3.508544922,
+ "rows_read": 5.9375,
+ "rows_out": 5.9375,
+ "cost": 0.01156405,
"uses_join_buffering": false
}
},
"rows_for_plan": 5.9375,
- "cost_for_plan": 3.508544922,
+ "cost_for_plan": 0.01156405,
"rest_of_plan":
[
@@ -9085,9 +9724,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 1000,
- "rows_after_scan": 804.6875,
"rows_after_filter": 804.6875,
- "cost": 1496.835632,
+ "rows_out": 804.6875,
+ "cost": 0.990884438,
"index_only": false,
"chosen": true
}
@@ -9095,14 +9734,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 804.6875,
- "records_out": 804.6875,
- "cost": 1496.835632,
+ "rows_read": 804.6875,
+ "rows_out": 804.6875,
+ "cost": 0.990884438,
"uses_join_buffering": false
}
},
"rows_for_plan": 4777.832031,
- "cost_for_plan": 1500.344177
+ "cost_for_plan": 1.002448488
}
]
},
@@ -9124,9 +9763,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 1000,
- "rows_after_scan": 804.6875,
"rows_after_filter": 804.6875,
- "cost": 252.0986328,
+ "rows_out": 804.6875,
+ "cost": 0.1668858,
"index_only": false,
"chosen": true
}
@@ -9134,14 +9773,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 804.6875,
- "records_out": 804.6875,
- "cost": 252.0986328,
+ "rows_read": 804.6875,
+ "rows_out": 804.6875,
+ "cost": 0.1668858,
"uses_join_buffering": false
}
},
"rows_for_plan": 804.6875,
- "cost_for_plan": 252.0986328,
+ "cost_for_plan": 0.1668858,
"pruned_by_heuristic": true
}
]
@@ -9175,9 +9814,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 10,
- "rows_after_scan": 10,
"rows_after_filter": 10,
- "cost": 3.508544922,
+ "rows_out": 10,
+ "cost": 0.01156405,
"index_only": false,
"chosen": true
}
@@ -9185,14 +9824,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 3.508544922,
+ "rows_read": 10,
+ "rows_out": 10,
+ "cost": 0.01156405,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 3.508544922,
+ "cost_for_plan": 0.01156405,
"rest_of_plan":
[
@@ -9217,31 +9856,27 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"used_range_estimates": false,
"cause": "not available",
"rows": 1,
- "cost": 12.50585794,
+ "cost": 0.01810946,
"chosen": true
},
{
- "access_type": "scan_with_join_cache",
- "rows": 1000,
- "rows_after_scan": 603.515625,
- "rows_after_filter": 603.515625,
- "cost": 1685.448242,
- "index_only": false,
- "chosen": false
+ "type": "scan",
+ "chosen": false,
+ "cause": "cost"
}
],
"chosen_access_method":
{
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 12.50585794,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.01810946,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 16.01440287,
+ "cost_for_plan": 0.02967351,
"selectivity": 0.8046875,
"estimated_join_cardinality": 8.046875
}
@@ -9265,9 +9900,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 1000,
- "rows_after_scan": 804.6875,
"rows_after_filter": 804.6875,
- "cost": 252.0986328,
+ "rows_out": 804.6875,
+ "cost": 0.1668858,
"index_only": false,
"chosen": true
}
@@ -9275,14 +9910,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 804.6875,
- "records_out": 804.6875,
- "cost": 252.0986328,
+ "rows_read": 804.6875,
+ "rows_out": 804.6875,
+ "cost": 0.1668858,
"uses_join_buffering": false
}
},
"rows_for_plan": 804.6875,
- "cost_for_plan": 252.0986328,
+ "cost_for_plan": 0.1668858,
"pruned_by_cost": true
}
]
@@ -9316,7 +9951,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.282887479,
+ "cost": 0.002483968,
"chosen": true
}
],
@@ -9342,9 +9977,9 @@ insert into t3 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
explain
select * from t3 where (a,a) in (select t1.a, t2.a from t1, t2 where t1.b=t2.b);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 5
-1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
-1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 Using where
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.semijoin_table_pullout')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
JSON_DETAILED(JSON_EXTRACT(trace, '$**.semijoin_table_pullout'))
[
@@ -9382,7 +10017,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 0.745829876,
+ "cost": 0.001388369,
"chosen": true
}
]
@@ -9423,9 +10058,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 10,
- "rows_after_scan": 10,
"rows_after_filter": 10,
- "cost": 3.510986328,
+ "rows_out": 10,
+ "cost": 0.01156405,
"index_only": false,
"chosen": true
}
@@ -9433,14 +10068,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 10,
- "records_out": 10,
- "cost": 3.510986328,
+ "rows_read": 10,
+ "rows_out": 10,
+ "cost": 0.01156405,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 3.510986328,
+ "cost_for_plan": 0.01156405,
"rest_of_plan":
[
@@ -9465,33 +10100,28 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"used_range_estimates": false,
"cause": "not available",
"rows": 1,
- "cost": 12.50585794,
+ "cost": 0.01749506,
"chosen": true
},
{
- "access_type": "scan_with_join_cache",
- "rows": 100,
- "rows_after_scan": 75,
- "rows_after_filter": 75,
- "cost": 204.2348633,
- "index_only": false,
- "chosen": false
+ "type": "scan",
+ "chosen": false,
+ "cause": "cost"
}
],
"chosen_access_method":
{
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 12.50585794,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.01749506,
"uses_join_buffering": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 16.01684427,
- "cost_for_sorting": 10,
- "pruned_by_hanging_leaf": true
+ "cost_for_plan": 0.02905911,
+ "cost_for_sorting": 0.006368384
}
]
},
@@ -9513,9 +10143,9 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "scan",
"rows": 100,
- "rows_after_scan": 100,
"rows_after_filter": 100,
- "cost": 26.10986328,
+ "rows_out": 100,
+ "cost": 0.0256405,
"index_only": false,
"chosen": true,
"use_tmp_table": true
@@ -9524,15 +10154,66 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "scan",
- "records_read": 100,
- "records_out": 100,
- "cost": 26.10986328,
+ "rows_read": 100,
+ "rows_out": 100,
+ "cost": 0.0256405,
"uses_join_buffering": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 26.10986328,
- "pruned_by_cost": true
+ "cost_for_plan": 0.0256405,
+ "rest_of_plan":
+ [
+
+ {
+ "plan_prefix":
+ [
+ "t2"
+ ],
+ "table": "t1",
+ "best_access_path":
+ {
+ "plan_details":
+ {
+ "record_count": 100
+ },
+ "considered_access_paths":
+ [
+
+ {
+ "access_type": "ref",
+ "index": "a",
+ "used_range_estimates": false,
+ "cause": "not available",
+ "rows": 1,
+ "cost": 0.1731074,
+ "chosen": true
+ },
+
+ {
+ "access_type": "scan_with_join_cache",
+ "rows": 10,
+ "rows_after_filter": 10,
+ "rows_out": 1,
+ "cost": 0.11051665,
+ "index_only": false,
+ "chosen": true
+ }
+ ],
+ "chosen_access_method":
+ {
+ "type": "scan",
+ "rows_read": 10,
+ "rows_out": 1,
+ "cost": 0.11051665,
+ "uses_join_buffering": true
+ }
+ },
+ "rows_for_plan": 100,
+ "cost_for_plan": 0.13615715,
+ "pruned_by_cost": true
+ }
+ ]
}
]
]
@@ -9550,7 +10231,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
EXPLAIN EXTENDED SELECT * from t1 WHERE a between 1 and 5 and b <= 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 100 1.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 100 0.22 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` between 1 and 5 and `test`.`t1`.`b` <= 5
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.selectivity_for_columns')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
@@ -9647,7 +10328,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 0,
- "cost": 0.52,
+ "cost": 0.001340684,
"chosen": true
}
]
@@ -9749,8 +10430,8 @@ select count(*) from seq_1_to_10000000 {
"table": "seq_1_to_10000000",
"table_scan": {
"rows": 10000000,
- "read_cost": 5000000,
- "read_and_compare_cost": 7250000
+ "read_cost": 124.7880673,
+ "read_and_compare_cost": 444.7880673
}
}
]
@@ -9768,30 +10449,30 @@ select count(*) from seq_1_to_10000000 {
{
"access_type": "scan",
"rows": 10000000,
- "rows_after_scan": 10000000,
"rows_after_filter": 10000000,
- "cost": 7250000,
+ "rows_out": 10000000,
+ "cost": 444.7880673,
"index_only": true,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 10000000,
- "records_out": 10000000,
- "cost": 7250000,
+ "rows_read": 10000000,
+ "rows_out": 10000000,
+ "cost": 444.7880673,
"uses_join_buffering": false
}
},
"rows_for_plan": 10000000,
- "cost_for_plan": 7250000
+ "cost_for_plan": 444.7880673
}
]
},
{
"best_join_order": ["seq_1_to_10000000"],
"rows": 10000000,
- "cost": 7250000
+ "cost": 444.7880673
},
{
"attaching_conditions_to_tables": {
@@ -9830,7 +10511,7 @@ explain
select * from t1 left join (t2 join t3 on t3.pk=1000) on t2.a=t1.a and t2.pk is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 const PRIMARY NULL NULL NULL 1 Impossible ON condition
-1 SIMPLE t2 const PRIMARY NULL NULL NULL 1 Impossible ON condition
+1 SIMPLE t2 const PRIMARY NULL NULL NULL 0 Impossible ON condition
1 SIMPLE t1 ALL NULL NULL NULL NULL 10
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.mark_join_nest_as_const'))
from information_schema.optimizer_trace;
@@ -10183,7 +10864,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting'))
"used_range_estimates": false,
"cause": "not available",
"rows": 1.8367,
- "cost": 1.417925794,
+ "cost": 0.0019606,
"chosen": true
},
@@ -10196,27 +10877,33 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting'))
"chosen_access_method":
{
"type": "ref",
- "records_read": 1.8367,
- "records_out": 1.8367,
- "cost": 1.417925794,
+ "rows_read": 1.8367,
+ "rows_out": 1.8367,
+ "cost": 0.0019606,
"uses_join_buffering": false
}
},
"rows_for_plan": 1.8367,
- "cost_for_plan": 1.417925794,
- "cost_for_sorting": 1.8367
+ "cost_for_plan": 0.0019606,
+ "cost_for_sorting": 0.001155201
}
]
},
{
- "best_splitting":
+ "split_materialized":
{
"table": "t2",
"key": "idx_a",
- "record_count": 4,
- "cost": 4.157170953,
- "unsplit_cost": 60.1794762
+ "org_cost": 0.0019606,
+ "postjoin_cost": 0.001135418,
+ "one_splitting_cost": 0.003096018,
+ "unsplit_postjoin_cost": 0.036032575,
+ "unsplit_cost": 0.060589825,
+ "rows": 1.8367,
+ "outer_rows": 4,
+ "total_splitting_cost": 0.012384072,
+ "chosen": true
}
}
]
@@ -10226,14 +10913,7 @@ json_detailed(json_extract(trace, '$**.lateral_derived'))
from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.lateral_derived'))
-[
-
- {
- "startup_cost": 16.62868381,
- "splitting_cost": 4.157170953,
- "records": 1
- }
-]
+NULL
drop table t1,t2;
#
# Test table functions.
@@ -10290,7 +10970,6 @@ set @save_histogram_size= @@histogram_size;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set optimizer_switch='rowid_filter=on';
set use_stat_tables='preferably';
-set optimizer_use_condition_selectivity=4;
set histogram_size=127;
create table t1 (a int, b int, c int, key(a),key(b));
insert into t1 select seq, seq*2, seq/10 from seq_1_to_1000;
@@ -10358,7 +11037,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"range_analysis": {
"table_scan": {
"rows": 1000,
- "cost": 252.5869141
+ "cost": 0.1671262
},
"potential_range_indexes": [
{
@@ -10382,7 +11061,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"using_mrr": false,
"index_only": false,
"rows": 9,
- "cost": 7.27527215,
+ "cost": 0.01235492,
"chosen": true
},
{
@@ -10392,7 +11071,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"using_mrr": false,
"index_only": false,
"rows": 21,
- "cost": 16.28230168,
+ "cost": 0.027161348,
"chosen": false,
"cause": "cost"
}
@@ -10414,7 +11093,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"ranges": ["(NULL) < (a) < (10)"]
},
"rows_for_plan": 9,
- "cost_for_plan": 7.27527215,
+ "cost_for_plan": 0.01235492,
"chosen": true
}
}
@@ -10424,12 +11103,12 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"rowid_filters": [
{
"key": "a",
- "build_cost": 0.759047172,
+ "build_cost": 0.001839302,
"rows": 9
},
{
"key": "b",
- "build_cost": 1.122236655,
+ "build_cost": 0.003459502,
"rows": 21
}
]
@@ -10469,51 +11148,49 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
{
"filter": {
"rowid_filter_key": "b",
- "index_only_cost": 0.50527215,
- "filter_startup_cost": 1.122236655,
- "find_key_and_filter_lookup_cost": 0.386507019,
+ "index_only_cost": 0.001515222,
+ "filter_startup_cost": 0.003459502,
+ "find_key_and_filter_lookup_cost": 7.275007e-4,
"filter_selectivity": 0.021,
"orginal_rows": 9,
"new_rows": 0.189,
- "original_found_rows_cost": 5.45527215,
- "new_found_rows_cost": 1.381168455,
- "cost": 2.54120511,
+ "orginal_access_cost": 0.011516778,
+ "with_filter_access_cost": 0.002452755,
+ "original_found_rows_cost": 0.010001556,
+ "with_filter_found_rows_cost": 2.100327e-4,
+ "cost": 0.005918305,
"filter_used": true
},
"access_type": "range",
"rows": 9,
- "rows_after_scan": 9,
"rows_after_filter": 0.189,
- "cost": 2.54120511,
+ "rows_out": 0.020671875,
+ "cost": 0.005918305,
"chosen": true
}
],
"chosen_access_method": {
"type": "range",
- "records_read": 9,
- "records_out": 0.020671875,
- "cost": 2.54120511,
+ "rows_read": 0.189,
+ "rows_out": 0.020671875,
+ "cost": 0.005918305,
"uses_join_buffering": false,
"rowid_filter_key": "b"
}
},
- "rows_for_plan": 9,
- "cost_for_plan": 2.54120511
+ "rows_for_plan": 0.020671875,
+ "cost_for_plan": 0.005918305
}
]
},
{
"best_join_order": ["t1"],
- "rows": 9,
- "cost": 2.54120511
+ "rows": 0.020671875,
+ "cost": 0.005918305
},
{
"table": "t1",
"range_analysis": {
- "table_scan": {
- "rows": 1000,
- "cost": 1.79769e308
- },
"potential_range_indexes": [
{
"index": "a",
@@ -10536,7 +11213,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"using_mrr": false,
"index_only": true,
"rows": 21,
- "cost": 5.257301684,
+ "cost": 0.004153769,
"chosen": true
}
]
@@ -10549,7 +11226,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"ranges": ["(10) <= (b) <= (50)"]
},
"rows_for_plan": 21,
- "cost_for_plan": 5.257301684,
+ "cost_for_plan": 0.004153769,
"chosen": true
}
}
@@ -10591,6 +11268,7 @@ analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
+set optimizer_use_condition_selectivity=2;
explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000;
EXPLAIN
{
@@ -10600,28 +11278,49 @@ EXPLAIN
"table_name": "three",
"access_type": "ALL",
"rows": 3,
- "filtered": 100,
- "attached_condition": "three.a is not null"
+ "filtered": 100
},
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "possible_keys": ["a", "b"],
+ "rows": 10000,
+ "filtered": 4.311999798,
+ "attached_condition": "t1.b < 5000 and t1.c < 1000"
+ },
+ "buffer_type": "flat",
+ "buffer_size": "65",
+ "join_type": "BNL",
+ "attached_condition": "t1.a = three.a"
+ }
+ }
+}
+set optimizer_use_condition_selectivity=4;
+explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
"table": {
- "table_name": "t1",
- "access_type": "ref",
- "possible_keys": ["a", "b"],
- "key": "a",
- "key_length": "5",
- "used_key_parts": ["a"],
- "ref": ["test.three.a"],
- "rowid_filter": {
- "range": {
- "key": "b",
- "used_key_parts": ["b"]
- },
- "rows": 4312,
- "selectivity_pct": 43.12
+ "table_name": "three",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "possible_keys": ["a", "b"],
+ "rows": 10000,
+ "filtered": 4.311999798,
+ "attached_condition": "t1.b < 5000 and t1.c < 1000"
},
- "rows": 1000,
- "filtered": 4.716249943,
- "attached_condition": "t1.b < 5000 and t1.c < 1000"
+ "buffer_type": "flat",
+ "buffer_size": "65",
+ "join_type": "BNL",
+ "attached_condition": "t1.a = three.a"
}
}
}
@@ -10694,8 +11393,8 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"table": "three",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
},
{
@@ -10703,7 +11402,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"range_analysis": {
"table_scan": {
"rows": 10000,
- "cost": 2516.869141
+ "cost": 1.5815024
},
"potential_range_indexes": [
{
@@ -10727,7 +11426,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"using_mrr": false,
"index_only": false,
"rows": 4312,
- "cost": 3260.045946,
+ "cost": 5.325058827,
"chosen": false,
"cause": "cost"
}
@@ -10748,7 +11447,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"rowid_filters": [
{
"key": "b",
- "build_cost": 174.2257513,
+ "build_cost": 0.701115436,
"rows": 4312
}
]
@@ -10784,23 +11483,23 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477,
+ "cost_for_plan": 0.010469215,
"rest_of_plan": [
{
"plan_prefix": ["three"],
@@ -10817,44 +11516,43 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"cause": "not available",
"filter": {
"rowid_filter_key": "b",
- "index_only_cost": 2.585794484,
- "filter_startup_cost": 174.2257513,
- "find_key_and_filter_lookup_cost": 96.19157113,
+ "index_only_cost": 0.092006157,
+ "filter_startup_cost": 0.701115436,
+ "find_key_and_filter_lookup_cost": 0.111079997,
"filter_selectivity": 0.4312,
"orginal_rows": 1000,
"new_rows": 431.2,
- "original_found_rows_cost": 552.5857945,
- "new_found_rows_cost": 335.9373656,
- "cost": 1440.757848,
+ "orginal_access_cost": 1.203290157,
+ "with_filter_access_cost": 0.682271815,
+ "original_found_rows_cost": 1.111284,
+ "with_filter_found_rows_cost": 0.479185661,
+ "cost": 2.78932608,
"filter_used": true
},
"rows": 431.2,
- "cost": 1440.757848,
+ "cost": 2.78932608,
"chosen": true
},
{
"access_type": "scan_with_join_cache",
"rows": 10000,
- "rows_after_scan": 353.71875,
- "rows_after_filter": 353.71875,
- "cost": 2768.89375,
+ "rows_after_filter": 471.625,
+ "rows_out": 431.2,
+ "cost": 1.71307878,
"index_only": false,
- "chosen": false
+ "chosen": true
}
],
"chosen_access_method": {
- "type": "ref",
- "records_read": 1000,
- "records_out": 353.71875,
- "cost": 1440.757848,
- "uses_join_buffering": false,
- "rowid_filter_key": "b"
+ "type": "scan",
+ "rows_read": 471.625,
+ "rows_out": 431.2,
+ "cost": 1.71307878,
+ "uses_join_buffering": true
}
},
- "rows_for_plan": 3000,
- "cost_for_plan": 1442.510412,
- "selectivity": 0.0471625,
- "estimated_join_cardinality": 141.4875
+ "rows_for_plan": 1293.6,
+ "cost_for_plan": 1.723547995
}
]
},
@@ -10869,78 +11567,31 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
{
"access_type": "scan",
"rows": 10000,
- "rows_after_scan": 471.625,
"rows_after_filter": 471.625,
- "cost": 2516.869141,
+ "rows_out": 471.625,
+ "cost": 1.5815024,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 471.625,
- "records_out": 471.625,
- "cost": 2516.869141,
+ "rows_read": 471.625,
+ "rows_out": 471.625,
+ "cost": 1.5815024,
"uses_join_buffering": false
}
},
"rows_for_plan": 471.625,
- "cost_for_plan": 2516.869141,
- "pruned_by_cost": true
+ "cost_for_plan": 1.5815024,
+ "pruned_by_heuristic": true
}
]
},
{
"best_join_order": ["three", "t1"],
- "rows": 141.4875,
- "cost": 1442.510412
- },
- {
- "table": "t1",
- "range_analysis": {
- "table_scan": {
- "rows": 10000,
- "cost": 1.79769e308
- },
- "potential_range_indexes": [
- {
- "index": "a",
- "usable": false,
- "cause": "not applicable"
- },
- {
- "index": "b",
- "usable": true,
- "key_parts": ["b"]
- }
- ],
- "setup_range_conditions": [],
- "analyzing_range_alternatives": {
- "range_scan_alternatives": [
- {
- "index": "b",
- "ranges": ["(NULL) < (b) < (5000)"],
- "rowid_ordered": false,
- "using_mrr": false,
- "index_only": true,
- "rows": 4312,
- "cost": 996.2459458,
- "chosen": true
- }
- ]
- },
- "chosen_range_access_summary": {
- "range_access_plan": {
- "type": "range_scan",
- "index": "b",
- "rows": 4312,
- "ranges": ["(NULL) < (b) < (5000)"]
- },
- "rows_for_plan": 4312,
- "cost_for_plan": 996.2459458,
- "chosen": true
- }
- }
+ "rows": 1293.6,
+ "cost": 1.723547995
},
{
"substitute_best_equal": {
@@ -10950,15 +11601,64 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
},
{
"attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
+ "attached_conditions_computation": [
+ {
+ "table": "t1",
+ "range_analysis": {
+ "table_scan": {
+ "rows": 10000,
+ "cost": 1.5815024
+ },
+ "potential_range_indexes": [
+ {
+ "index": "a",
+ "usable": true,
+ "key_parts": ["a"]
+ },
+ {
+ "index": "b",
+ "usable": true,
+ "key_parts": ["b"]
+ }
+ ],
+ "setup_range_conditions": [],
+ "analyzing_range_alternatives": {
+ "range_scan_alternatives": [
+ {
+ "index": "a"
+ },
+ {
+ "index": "b",
+ "ranges": ["(NULL) < (b) < (5000)"],
+ "rowid_ordered": false,
+ "using_mrr": false,
+ "index_only": false,
+ "rows": 4312,
+ "cost": 5.325058827,
+ "chosen": false,
+ "cause": "cost"
+ }
+ ],
+ "analyzing_roworder_intersect": {
+ "cause": "too few roworder scans"
+ },
+ "analyzing_index_merge_union": []
+ },
+ "group_index_range": {
+ "chosen": false,
+ "cause": "not single_table"
+ }
+ }
+ }
+ ],
"attached_conditions_summary": [
{
"table": "three",
- "attached": "three.a is not null"
+ "attached": null
},
{
"table": "t1",
- "attached": "t1.b < 5000 and t1.c < 1000"
+ "attached": "t1.a = three.a and t1.b < 5000 and t1.c < 1000"
}
]
}
diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test
index 6d67925f2ed..ef740f4ca25 100644
--- a/mysql-test/main/opt_trace.test
+++ b/mysql-test/main/opt_trace.test
@@ -84,23 +84,7 @@ drop table t1,t2,t0;
--echo # group_by min max optimization
--echo #
CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, KEY(a));
---disable_query_log
-INSERT INTO t1(a) VALUES (1), (2), (3), (4);
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
-INSERT INTO t1(a) SELECT a FROM t1;
---enable_query_log
+insert into t1 select seq, mod(seq,4)+1 from seq_1_to_65536;
analyze table t1;
EXPLAIN SELECT DISTINCT a FROM t1;
@@ -114,6 +98,7 @@ CREATE TABLE t1 (a INT, b INT, c int, d int, KEY(a,b,c,d));
INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (1,0,1,1), (3,2,3,3), (4,5,4,4);
ANALYZE TABLE t1;
EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a;
+set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a;
select * from information_schema.OPTIMIZER_TRACE;
DROP TABLE t1;
@@ -137,10 +122,6 @@ drop table t1;
--echo # Late ORDER BY optimization
--echo #
-create table ten(a int);
-insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table one_k(a int primary key);
-insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
create table t1 (
pk int not null,
a int,
@@ -152,18 +133,16 @@ create table t1 (
KEY a_b(a,b)
);
-insert into t1
-select a, a,a,a, 'filler-dataaa' from test.one_k;
+insert into t1 select seq, seq,seq,seq, 'filler-dataaa' from seq_0_to_999;
update t1 set a=1 where pk between 0 and 180;
update t1 set b=2 where pk between 0 and 20;
analyze table t1;
-set optimizer_trace='enabled=on';
explain select * from t1 where a=1 and b=2 order by c limit 1;
-
update t1 set b=2 where pk between 20 and 40;
+set optimizer_trace='enabled=on';
explain select * from t1 where a=1 and b=2 order by c limit 1;
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
-drop table t1,ten,one_k;
+drop table t1;
--echo #
--echo # TABLE ELIMINATION
@@ -203,34 +182,23 @@ drop table t0, t1, t2, t3;
--echo # IN subquery to sem-join is traced
--echo #
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-
create table t1(a int, b int);
-insert into t1 values (0,0),(1,1),(2,2);
-create table t2 as select * from t1;
-
-create table t11(a int, b int);
+insert into t1 select seq,seq from seq_0_to_3;
-create table t10 (pk int, a int);
-insert into t10 select a,a from t0;
-create table t12 like t10;
-insert into t12 select * from t10;
-
-analyze table t1,t10;
+create table t2 (p int, a int);
+insert into t2 select seq,seq from seq_1_to_10;
set optimizer_trace='enabled=on';
-explain extended select * from t1 where a in (select pk from t10);
+explain extended select * from t1 where a in (select p from t2);
+insert into t2 select seq,seq from seq_10_to_100;
+explain extended select * from t1 where a in (select p from t2);
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
-drop table t0,t1,t11,t10,t12,t2;
+drop table t1,t2;
--echo #
--echo # Selectivities for columns and indexes.
--echo #
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-
create table t1 (
pk int,
a int,
@@ -238,7 +206,7 @@ b int,
key pk(pk),
key pk_a(pk,a),
key pk_a_b(pk,a,b));
-insert into t1 select a,a,a from t0;
+insert into t1 select seq,seq,seq from seq_0_to_9;
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS (a,b) INDEXES ();
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
@@ -250,7 +218,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1;
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set @@use_stat_tables= @save_use_stat_tables;
-drop table t0,t1;
+drop table t1;
set optimizer_trace="enabled=off";
--echo #
@@ -902,7 +870,6 @@ set @save_histogram_size= @@histogram_size;
set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
set optimizer_switch='rowid_filter=on';
set use_stat_tables='preferably';
-set optimizer_use_condition_selectivity=4;
set histogram_size=127;
create table t1 (a int, b int, c int, key(a),key(b));
insert into t1 select seq, seq*2, seq/10 from seq_1_to_1000;
@@ -917,8 +884,12 @@ create table t1 (a int, b int, c int, key(a),key(b));
insert into t1 select mod(seq,10), seq, seq from seq_1_to_10000;
analyze table t1;
+set optimizer_use_condition_selectivity=2;
+explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000;
+set optimizer_use_condition_selectivity=4;
--optimizer_trace
explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and t1.c<1000;
+
drop table three, t1;
set @@optimizer_switch= @save_optimizer_switch;
diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result
index f3fee8a4402..a6993caf04c 100644
--- a/mysql-test/main/opt_trace_index_merge.result
+++ b/mysql-test/main/opt_trace_index_merge.result
@@ -73,7 +73,7 @@ explain select * from t1 where a=1 or b=1 {
"range_analysis": {
"table_scan": {
"rows": 1000,
- "cost": 264.7939453
+ "cost": 0.1728958
},
"potential_range_indexes": [
{
@@ -111,12 +111,12 @@ explain select * from t1 where a=1 or b=1 {
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 0.745585794,
+ "cost": 0.001388369,
"chosen": true
}
],
"index_to_merge": "a",
- "cumulated_cost": 0.745585794
+ "cumulated_cost": 0.001388369
},
{
"range_scan_alternatives": [
@@ -127,15 +127,15 @@ explain select * from t1 where a=1 or b=1 {
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 0.745585794,
+ "cost": 0.001388369,
"chosen": true
}
],
"index_to_merge": "b",
- "cumulated_cost": 1.491171589
+ "cumulated_cost": 0.002776738
}
],
- "cost_of_reading_ranges": 1.491171589,
+ "cost_of_reading_ranges": 0.002776738,
"use_roworder_union": true,
"cause": "always cheaper than non roworder retrieval",
"analyzing_roworder_scans": [
@@ -158,7 +158,7 @@ explain select * from t1 where a=1 or b=1 {
}
}
],
- "index_roworder_union_cost": 2.601171589,
+ "index_roworder_union_cost": 0.005010667,
"members": 2,
"chosen": true
}
@@ -187,7 +187,7 @@ explain select * from t1 where a=1 or b=1 {
]
},
"rows_for_plan": 2,
- "cost_for_plan": 2.601171589,
+ "cost_for_plan": 0.005010667,
"chosen": true
}
}
@@ -216,29 +216,29 @@ explain select * from t1 where a=1 or b=1 {
{
"access_type": "index_merge",
"rows": 2,
- "rows_after_scan": 2,
"rows_after_filter": 2,
- "cost": 2.601171589,
+ "rows_out": 2,
+ "cost": 0.005010667,
"chosen": true
}
],
"chosen_access_method": {
"type": "index_merge",
- "records_read": 2,
- "records_out": 2,
- "cost": 2.601171589,
+ "rows_read": 2,
+ "rows_out": 2,
+ "cost": 0.005010667,
"uses_join_buffering": false
}
},
"rows_for_plan": 2,
- "cost_for_plan": 2.601171589
+ "cost_for_plan": 0.005010667
}
]
},
{
"best_join_order": ["t1"],
"rows": 2,
- "cost": 2.601171589
+ "cost": 0.005010667
},
{
"substitute_best_equal": {
@@ -338,7 +338,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2243,
- "cost": 1695.083937,
+ "cost": 2.770260666,
"chosen": true
},
@@ -352,7 +352,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2243,
- "cost": 1695.083937,
+ "cost": 2.770260666,
"chosen": false,
"cause": "cost"
},
@@ -367,7 +367,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2243,
- "cost": 1695.083937,
+ "cost": 2.770260666,
"chosen": false,
"cause": "cost"
}
@@ -379,10 +379,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key1",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 61.88893703,
- "disk_sweep_cost": 1682.25,
- "cumulative_total_cost": 1744.138937,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.240986767,
+ "disk_sweep_cost": 2.564386012,
+ "cumulative_total_cost": 2.805372779,
"usable": true,
"matching_rows_now": 2243,
"intersect_covering_with_this_index": false,
@@ -391,10 +391,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key2",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 123.7778741,
- "disk_sweep_cost": 57.75,
- "cumulative_total_cost": 181.5278741,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.481973534,
+ "disk_sweep_cost": 0.088032868,
+ "cumulative_total_cost": 0.570006402,
"usable": true,
"matching_rows_now": 77.6360508,
"intersect_covering_with_this_index": false,
@@ -403,10 +403,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key3",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 185.6668111,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.722960301,
"disk_sweep_cost": 0,
- "cumulative_total_cost": 185.6668111,
+ "cumulative_total_cost": 0.722960301,
"usable": true,
"matching_rows_now": 2.687185191,
"intersect_covering_with_this_index": true,
@@ -420,7 +420,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index"
},
"rows": 77,
- "cost": 197.0550842,
+ "cost": 0.572490756,
"covering": false,
"chosen": true
},
@@ -438,7 +438,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{
"type": "index_roworder_intersect",
"rows": 77,
- "cost": 197.0550842,
+ "cost": 0.572490756,
"covering": false,
"clustered_pk_scan": false,
"intersect_of":
@@ -466,7 +466,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
]
},
"rows_for_plan": 77,
- "cost_for_plan": 197.0550842,
+ "cost_for_plan": 0.572490756,
"chosen": true
}
]
@@ -507,7 +507,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 517.508937,
+ "cost": 0.312832109,
"chosen": true
},
@@ -521,13 +521,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 517.508937,
+ "cost": 0.312832109,
"chosen": false,
"cause": "cost"
}
],
"index_to_merge": "key1",
- "cumulated_cost": 517.508937
+ "cumulated_cost": 0.312832109
},
{
@@ -544,7 +544,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 517.508937,
+ "cost": 0.312832109,
"chosen": true
},
@@ -558,16 +558,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 517.508937,
+ "cost": 0.312832109,
"chosen": false,
"cause": "cost"
}
],
"index_to_merge": "key3",
- "cumulated_cost": 1035.017874
+ "cumulated_cost": 0.625664218
}
],
- "cost_of_reading_ranges": 1035.017874,
+ "cost_of_reading_ranges": 0.625664218,
"use_roworder_union": true,
"cause": "always cheaper than non roworder retrieval",
"analyzing_roworder_scans":
@@ -588,10 +588,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key1",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 61.88893703,
- "disk_sweep_cost": 1682.25,
- "cumulative_total_cost": 1744.138937,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.240986767,
+ "disk_sweep_cost": 2.564386012,
+ "cumulative_total_cost": 2.805372779,
"usable": true,
"matching_rows_now": 2243,
"intersect_covering_with_this_index": false,
@@ -600,10 +600,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key2",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 123.7778741,
- "disk_sweep_cost": 57.75,
- "cumulative_total_cost": 181.5278741,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.481973534,
+ "disk_sweep_cost": 0.088032868,
+ "cumulative_total_cost": 0.570006402,
"usable": true,
"matching_rows_now": 77.6360508,
"intersect_covering_with_this_index": false,
@@ -616,7 +616,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index"
},
"rows": 77,
- "cost": 197.0550842,
+ "cost": 0.572490756,
"covering": false,
"chosen": true
}
@@ -637,10 +637,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key3",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 61.88893703,
- "disk_sweep_cost": 1682.25,
- "cumulative_total_cost": 1744.138937,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.240986767,
+ "disk_sweep_cost": 2.564386012,
+ "cumulative_total_cost": 2.805372779,
"usable": true,
"matching_rows_now": 2243,
"intersect_covering_with_this_index": false,
@@ -649,10 +649,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key4",
- "index_scan_cost": 61.88893703,
- "cumulated_index_scan_cost": 123.7778741,
- "disk_sweep_cost": 57.75,
- "cumulative_total_cost": 181.5278741,
+ "index_scan_cost": 0.240986767,
+ "cumulated_index_scan_cost": 0.481973534,
+ "disk_sweep_cost": 0.088032868,
+ "cumulative_total_cost": 0.570006402,
"usable": true,
"matching_rows_now": 77.6360508,
"intersect_covering_with_this_index": false,
@@ -665,13 +665,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index"
},
"rows": 77,
- "cost": 197.0550842,
+ "cost": 0.572490756,
"covering": false,
"chosen": true
}
}
],
- "index_roworder_union_cost": 333.0257481,
+ "index_roworder_union_cost": 1.135959601,
"members": 2,
"chosen": true
}
@@ -692,7 +692,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{
"type": "index_roworder_intersect",
"rows": 77,
- "cost": 197.0550842,
+ "cost": 0.572490756,
"covering": false,
"clustered_pk_scan": false,
"intersect_of":
@@ -723,7 +723,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{
"type": "index_roworder_intersect",
"rows": 77,
- "cost": 197.0550842,
+ "cost": 0.572490756,
"covering": false,
"clustered_pk_scan": false,
"intersect_of":
@@ -753,7 +753,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
]
},
"rows_for_plan": 154,
- "cost_for_plan": 333.0257481,
+ "cost_for_plan": 1.135959601,
"chosen": true
}
]
diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result
index 2b449de0f0d..14ce3e2858f 100644
--- a/mysql-test/main/opt_trace_index_merge_innodb.result
+++ b/mysql-test/main/opt_trace_index_merge_innodb.result
@@ -88,7 +88,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"range_analysis": {
"table_scan": {
"rows": 1000,
- "cost": 253
+ "cost": 0.1764192
},
"potential_range_indexes": [
{
@@ -117,8 +117,9 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"using_mrr": false,
"index_only": false,
"rows": 1000,
- "cost": 252.02,
- "chosen": true
+ "cost": 0.19660976,
+ "chosen": false,
+ "cause": "cost"
},
{
"index": "key1",
@@ -127,7 +128,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 1.270146475,
+ "cost": 0.00415068,
"chosen": true
}
],
@@ -135,10 +136,10 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"intersecting_indexes": [
{
"index": "key1",
- "index_scan_cost": 0.525146475,
- "cumulated_index_scan_cost": 0.525146475,
- "disk_sweep_cost": 0.752076843,
- "cumulative_total_cost": 1.277223319,
+ "index_scan_cost": 0.001661605,
+ "cumulated_index_scan_cost": 0.001661605,
+ "disk_sweep_cost": 0.00171364,
+ "cumulative_total_cost": 0.003375245,
"usable": true,
"matching_rows_now": 1,
"intersect_covering_with_this_index": false,
@@ -150,7 +151,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"cause": "cost"
},
"chosen": false,
- "cause": "cost"
+ "cause": "too few indexes to merge"
},
"analyzing_index_merge_union": []
},
@@ -166,7 +167,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"ranges": ["(1) <= (key1) <= (1)"]
},
"rows_for_plan": 1,
- "cost_for_plan": 1.270146475,
+ "cost_for_plan": 0.00415068,
"chosen": true
}
}
@@ -176,7 +177,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"rowid_filters": [
{
"key": "key1",
- "build_cost": 0.526146475,
+ "build_cost": 0.001669448,
"rows": 1
}
]
@@ -212,7 +213,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"index": "key1",
"used_range_estimates": true,
"rows": 1,
- "cost": 1.250146475,
+ "cost": 0.00274516,
"chosen": true
},
{
@@ -223,22 +224,21 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
],
"chosen_access_method": {
"type": "ref",
- "records_read": 1,
- "records_out": 1,
- "cost": 1.250146475,
+ "rows_read": 1,
+ "rows_out": 1,
+ "cost": 0.00274516,
"uses_join_buffering": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 1.250146475,
- "pruned_by_hanging_leaf": true
+ "cost_for_plan": 0.00274516
}
]
},
{
"best_join_order": ["t1"],
"rows": 1,
- "cost": 1.250146475
+ "cost": 0.00274516
},
{
"substitute_best_equal": {
diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result
index c0404797105..b6bf862eff0 100644
--- a/mysql-test/main/opt_trace_security.result
+++ b/mysql-test/main/opt_trace_security.result
@@ -80,8 +80,8 @@ select * from db1.t1 {
"table": "t1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
}
]
@@ -99,30 +99,30 @@ select * from db1.t1 {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477
+ "cost_for_plan": 0.010469215
}
]
},
{
"best_join_order": ["t1"],
"rows": 3,
- "cost": 1.752563477
+ "cost": 0.010469215
},
{
"attaching_conditions_to_tables": {
@@ -211,8 +211,8 @@ select * from db1.v1 {
"table": "t1",
"table_scan": {
"rows": 3,
- "read_cost": 1.002563477,
- "read_and_compare_cost": 1.752563477
+ "read_cost": 0.010373215,
+ "read_and_compare_cost": 0.010469215
}
}
]
@@ -230,30 +230,30 @@ select * from db1.v1 {
{
"access_type": "scan",
"rows": 3,
- "rows_after_scan": 3,
"rows_after_filter": 3,
- "cost": 1.752563477,
+ "rows_out": 3,
+ "cost": 0.010469215,
"index_only": false,
"chosen": true
}
],
"chosen_access_method": {
"type": "scan",
- "records_read": 3,
- "records_out": 3,
- "cost": 1.752563477,
+ "rows_read": 3,
+ "rows_out": 3,
+ "cost": 0.010469215,
"uses_join_buffering": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 1.752563477
+ "cost_for_plan": 0.010469215
}
]
},
{
"best_join_order": ["t1"],
"rows": 3,
- "cost": 1.752563477
+ "cost": 0.010469215
},
{
"attaching_conditions_to_tables": {
diff --git a/mysql-test/main/opt_trace_selectivity.result b/mysql-test/main/opt_trace_selectivity.result
index b56a362feb9..e24cd857882 100644
--- a/mysql-test/main/opt_trace_selectivity.result
+++ b/mysql-test/main/opt_trace_selectivity.result
@@ -54,7 +54,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"index": "a",
"used_range_estimates": true,
"rows": 104,
- "cost": 78.54062004,
+ "cost": 0.057629638,
"chosen": true
},
@@ -63,7 +63,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"index": "b",
"used_range_estimates": true,
"rows": 340,
- "cost": 255.6327963,
+ "cost": 0.14153631,
"chosen": false,
"cause": "cost"
},
@@ -73,7 +73,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"index": "c",
"used_range_estimates": true,
"rows": 632,
- "cost": 475.2468449,
+ "cost": 0.241743894,
"chosen": false,
"cause": "cost"
},
@@ -81,23 +81,23 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"access_type": "index_merge",
"rows": 7,
- "rows_after_scan": 7,
"rows_after_filter": 7,
- "cost": 13.79559815,
+ "rows_out": 7,
+ "cost": 0.045367017,
"chosen": true
}
],
"chosen_access_method":
{
"type": "index_merge",
- "records_read": 7,
- "records_out": 7,
- "cost": 13.79559815,
+ "rows_read": 7,
+ "rows_out": 7,
+ "cost": 0.045367017,
"uses_join_buffering": false
}
},
"rows_for_plan": 7,
- "cost_for_plan": 13.79559815
+ "cost_for_plan": 0.045367017
}
]
]
@@ -150,7 +150,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"index": "a",
"used_range_estimates": true,
"rows": 6,
- "cost": 5.002343464,
+ "cost": 0.004077342,
"chosen": true
},
@@ -159,7 +159,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"index": "b",
"used_range_estimates": true,
"rows": 232,
- "cost": 174.5906139,
+ "cost": 0.104637894,
"chosen": false,
"cause": "cost"
},
@@ -169,7 +169,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"index": "c",
"used_range_estimates": true,
"rows": 293,
- "cost": 220.3644392,
+ "cost": 0.125478666,
"chosen": false,
"cause": "cost"
},
@@ -183,16 +183,14 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"chosen_access_method":
{
"type": "ref",
- "records_read": 6,
- "records_out": 0.6,
- "cost": 5.002343464,
+ "rows_read": 6,
+ "rows_out": 0.6,
+ "cost": 0.004077342,
"uses_join_buffering": false
}
},
- "rows_for_plan": 6,
- "cost_for_plan": 5.002343464,
- "selectivity": 0.1,
- "estimated_join_cardinality": 0.6
+ "rows_for_plan": 0.6,
+ "cost_for_plan": 0.004077342
}
]
]
diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result
index c4b36902bce..c3bdbded00c 100644
--- a/mysql-test/main/opt_trace_ucs2.result
+++ b/mysql-test/main/opt_trace_ucs2.result
@@ -38,7 +38,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2,
- "cost": 2.022733708,
+ "cost": 0.003717837,
"chosen": true
}
],
diff --git a/mysql-test/main/optimizer_costs.result b/mysql-test/main/optimizer_costs.result
new file mode 100644
index 00000000000..aa1ba005448
--- /dev/null
+++ b/mysql-test/main/optimizer_costs.result
@@ -0,0 +1,340 @@
+select table_name,engine from information_schema.tables where table_name="optimizer_costs";
+table_name engine
+OPTIMIZER_COSTS MEMORY
+show create table information_schema.optimizer_costs;
+Table Create Table
+OPTIMIZER_COSTS CREATE TEMPORARY TABLE `OPTIMIZER_COSTS` (
+ `ENGINE` varchar(192) NOT NULL,
+ `OPTIMIZER_DISK_READ_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_INDEX_BLOCK_COPY_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_KEY_COMPARE_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_KEY_COPY_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_KEY_LOOKUP_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_KEY_NEXT_FIND_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_DISK_READ_RATIO` decimal(9,6) NOT NULL,
+ `OPTIMIZER_ROW_COPY_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_ROW_LOOKUP_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_ROW_NEXT_FIND_COST` decimal(9,6) NOT NULL,
+ `OPTIMIZER_ROWID_COMPARE_COST` decimal(9,6) NOT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
+select * from information_schema.optimizer_costs where engine in
+("memory","innodb","aria","default") order by engine;
+ENGINE Aria
+OPTIMIZER_DISK_READ_COST 10.240000
+OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600
+OPTIMIZER_KEY_COMPARE_COST 0.011361
+OPTIMIZER_KEY_COPY_COST 0.015685
+OPTIMIZER_KEY_LOOKUP_COST 0.435777
+OPTIMIZER_KEY_NEXT_FIND_COST 0.082347
+OPTIMIZER_DISK_READ_RATIO 0.020000
+OPTIMIZER_ROW_COPY_COST 0.060866
+OPTIMIZER_ROW_LOOKUP_COST 0.130839
+OPTIMIZER_ROW_NEXT_FIND_COST 0.045916
+OPTIMIZER_ROWID_COMPARE_COST 0.005681
+ENGINE default
+OPTIMIZER_DISK_READ_COST 10.240000
+OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600
+OPTIMIZER_KEY_COMPARE_COST 0.011361
+OPTIMIZER_KEY_COPY_COST 0.015685
+OPTIMIZER_KEY_LOOKUP_COST 0.435777
+OPTIMIZER_KEY_NEXT_FIND_COST 0.082347
+OPTIMIZER_DISK_READ_RATIO 0.020000
+OPTIMIZER_ROW_COPY_COST 0.060866
+OPTIMIZER_ROW_LOOKUP_COST 0.130839
+OPTIMIZER_ROW_NEXT_FIND_COST 0.045916
+OPTIMIZER_ROWID_COMPARE_COST 0.005681
+ENGINE InnoDB
+OPTIMIZER_DISK_READ_COST 10.240000
+OPTIMIZER_INDEX_BLOCK_COPY_COST 0.035600
+OPTIMIZER_KEY_COMPARE_COST 0.011361
+OPTIMIZER_KEY_COPY_COST 0.015685
+OPTIMIZER_KEY_LOOKUP_COST 0.791120
+OPTIMIZER_KEY_NEXT_FIND_COST 0.099000
+OPTIMIZER_DISK_READ_RATIO 0.020000
+OPTIMIZER_ROW_COPY_COST 0.060870
+OPTIMIZER_ROW_LOOKUP_COST 0.765970
+OPTIMIZER_ROW_NEXT_FIND_COST 0.070130
+OPTIMIZER_ROWID_COMPARE_COST 0.005681
+ENGINE MEMORY
+OPTIMIZER_DISK_READ_COST 0.000000
+OPTIMIZER_INDEX_BLOCK_COPY_COST 0.000000
+OPTIMIZER_KEY_COMPARE_COST 0.011361
+OPTIMIZER_KEY_COPY_COST 0.000000
+OPTIMIZER_KEY_LOOKUP_COST 0.000000
+OPTIMIZER_KEY_NEXT_FIND_COST 0.000000
+OPTIMIZER_DISK_READ_RATIO 0.000000
+OPTIMIZER_ROW_COPY_COST 0.002334
+OPTIMIZER_ROW_LOOKUP_COST 0.000000
+OPTIMIZER_ROW_NEXT_FIND_COST 0.000000
+OPTIMIZER_ROWID_COMPARE_COST 0.005681
+show variables like "optimizer%cost";
+Variable_name Value
+optimizer_disk_read_cost 10.240000
+optimizer_index_block_copy_cost 0.035600
+optimizer_key_compare_cost 0.011361
+optimizer_key_copy_cost 0.015685
+optimizer_key_lookup_cost 0.435777
+optimizer_key_next_find_cost 0.082347
+optimizer_row_copy_cost 0.060866
+optimizer_row_lookup_cost 0.130839
+optimizer_row_next_find_cost 0.045916
+optimizer_scan_setup_cost 10.000000
+optimizer_where_cost 0.032000
+show variables like "optimizer_disk_read_ratio";
+Variable_name Value
+optimizer_disk_read_ratio 0.020000
+#
+# Test change some 'default' variables
+#
+SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost;
+@@optimizer_disk_read_ratio @@optimizer_index_block_copy_cost
+0.020000 0.035600
+SET global optimizer_disk_read_ratio=0.8;
+SET global optimizer_index_block_copy_cost=0.1;
+SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost;
+@@optimizer_disk_read_ratio @@optimizer_index_block_copy_cost
+0.800000 0.100000
+select optimizer_disk_read_ratio,optimizer_index_block_copy_cost from information_schema.optimizer_costs where engine='default';
+optimizer_disk_read_ratio optimizer_index_block_copy_cost
+0.800000 0.100000
+SET global optimizer_disk_read_ratio=default;
+SET global optimizer_index_block_copy_cost=default;
+SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost;
+@@optimizer_disk_read_ratio @@optimizer_index_block_copy_cost
+0.020000 0.035600
+#
+# Test change some 'engine' variables
+#
+select @@MEMORY.optimizer_row_lookup_cost;
+@@MEMORY.optimizer_row_lookup_cost
+0.000000
+set @tmp=@@MEMORY.optimizer_row_lookup_cost;
+set @@global.MEMORY.optimizer_row_lookup_cost=1;
+select @@MEMORY.optimizer_row_lookup_cost;
+@@MEMORY.optimizer_row_lookup_cost
+1.000000
+set @@global.MEMORY.optimizer_row_lookup_cost=default;
+select @@MEMORY.optimizer_row_lookup_cost;
+@@MEMORY.optimizer_row_lookup_cost
+0.130839
+set @@global.MEMORY.optimizer_row_lookup_cost=@tmp;
+select @@MEMORY.optimizer_row_lookup_cost;
+@@MEMORY.optimizer_row_lookup_cost
+0.000000
+#
+# Print variables with different syntaxes
+#
+SHOW VARIABLES like "optimizer_row_lookup_cost";
+Variable_name Value
+optimizer_row_lookup_cost 0.130839
+SELECT @@optimizer_row_lookup_cost;
+@@optimizer_row_lookup_cost
+0.130839
+SELECT @@global.default.optimizer_row_lookup_cost;
+@@global.default.optimizer_row_lookup_cost
+0.130839
+SELECT @@global.default.`optimizer_row_lookup_cost`;
+@@global.default.`optimizer_row_lookup_cost`
+0.130839
+SELECT @@MEMORY.optimizer_row_lookup_cost;
+@@MEMORY.optimizer_row_lookup_cost
+0.000000
+SELECT @@memory.optimizer_row_lookup_cost;
+@@memory.optimizer_row_lookup_cost
+0.000000
+SELECT @@InnoDB.optimizer_row_lookup_cost;
+@@InnoDB.optimizer_row_lookup_cost
+0.765970
+#
+# Accessing not existing cost
+#
+SELECT @@not_existing.optimizer_row_lookup_cost;
+@@not_existing.optimizer_row_lookup_cost
+0.130839
+SELECT @@NOT_existing.optimizer_row_lookup_cost;
+@@NOT_existing.optimizer_row_lookup_cost
+0.130839
+select engine from information_schema.optimizer_costs where engine like '%existing';
+engine
+#
+# Creating a new cost structure
+#
+SET global new_engine.optimizer_disk_read_cost=100;
+select * from information_schema.optimizer_costs where engine like 'new_engine';
+ENGINE OPTIMIZER_DISK_READ_COST OPTIMIZER_INDEX_BLOCK_COPY_COST OPTIMIZER_KEY_COMPARE_COST OPTIMIZER_KEY_COPY_COST OPTIMIZER_KEY_LOOKUP_COST OPTIMIZER_KEY_NEXT_FIND_COST OPTIMIZER_DISK_READ_RATIO OPTIMIZER_ROW_COPY_COST OPTIMIZER_ROW_LOOKUP_COST OPTIMIZER_ROW_NEXT_FIND_COST OPTIMIZER_ROWID_COMPARE_COST
+new_engine 100.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000
+select @@new_engine.optimizer_disk_read_cost, @@new_engine.optimizer_row_copy_cost;
+@@new_engine.optimizer_disk_read_cost @@new_engine.optimizer_row_copy_cost
+100.000000 -1.000000
+#
+# Errors
+#
+SELECT @@default.optimizer_disk_read_cost;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'default.optimizer_disk_read_cost' at line 1
+set global Aria.optimizer_disk_read_cost=NULL;
+ERROR 42000: Incorrect argument type to variable 'optimizer_disk_read_cost'
+set @tmp=@@Aria.optimizer_disk_read_cost;
+SET global Aria.optimizer_disk_read_cost=-1;
+Warnings:
+Warning 1292 Truncated incorrect optimizer_disk_read_cost value: '-1'
+select @@Aria.optimizer_disk_read_cost;
+@@Aria.optimizer_disk_read_cost
+0.000000
+SET global Aria.optimizer_disk_read_cost=200000;
+Warnings:
+Warning 1292 Truncated incorrect optimizer_disk_read_cost value: '200000'
+select @@Aria.optimizer_disk_read_cost;
+@@Aria.optimizer_disk_read_cost
+10000.000000
+set global Aria.optimizer_disk_read_cost=@tmp;
+select @@Aria.optimizer_disk_read_cost;
+@@Aria.optimizer_disk_read_cost
+10.240000
+#
+# Test of cost of ref compared to table scan + join_cache
+#
+create or replace table t1 (p int primary key, a char(10)) engine=myisam;
+create or replace table t2 (p int primary key, i int, a char(10), key k2(a)) engine=myisam;
+insert into t2 select seq,seq,'a' from seq_1_to_512;
+insert into t1 select seq,'a' from seq_1_to_4;
+explain select count(*) from t1, t2 where t1.p = t2.i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index
+1 SIMPLE t2 ALL NULL NULL NULL NULL 512 Using where; Using join buffer (flat, BNL join)
+insert into t1 select seq,'a' from seq_5_to_10;
+explain select count(*) from t1, t2 where t1.p = t2.i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 512 Using where
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.i 1 Using index
+drop table t1,t2;
+#
+# Test of optimizer_scan_setup_cost
+#
+create table t1 (p int primary key, a char(10)) engine=myisam;
+create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)) engine=myisam;
+insert into t1 values (2, 'qqqq'), (11, 'yyyy');
+insert into t2 values (1, 2, 'qqqq'), (2, 2, 'pppp'),
+(3, 2, 'yyyy'), (4, 3, 'zzzz');
+set @org_myisam_disk_read_ratio=@@myisam.optimizer_disk_read_ratio;
+set @@optimizer_scan_setup_cost=10,@@global.myisam.optimizer_disk_read_ratio=0.2;
+flush tables;
+explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2
+1 SIMPLE t2 ref k1 k1 5 test.t1.p 2
+set @@optimizer_scan_setup_cost=0.0, @@global.myisam.optimizer_disk_read_ratio=0.0;
+flush tables;
+explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2
+1 SIMPLE t2 ALL k1 NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
+set @@optimizer_scan_setup_cost=default,@@global.myisam.optimizer_disk_read_ratio=@org_myisam_disk_read_ratio;
+flush tables;
+drop table t1,t2;
+#
+# Test of group by optimization
+#
+set @@optimizer_scan_setup_cost=0;
+CREATE TABLE t1 (id INT NOT NULL, a DATE, KEY(id,a)) engine=myisam;
+INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'),
+(1,'2001-01-03'),(1,'2001-01-04'),
+(2,'2001-01-01'),(2,'2001-01-02'),
+(2,'2001-01-03'),(2,'2001-01-04'),
+(3,'2001-01-01'),(3,'2001-01-02'),
+(3,'2001-01-03'),(3,'2001-01-04'),
+(4,'2001-01-01'),(4,'2001-01-02'),
+(4,'2001-01-03'),(4,'2001-01-04');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL id 8 NULL 16 Using where; Using index
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL id 8 NULL 5 Using where; Using index for group-by
+drop table t1;
+set @@optimizer_scan_setup_cost=default;
+#
+# Test of straight join costs
+#
+create table t1 (l_orderkey int(11) NOT NULL,
+l_partkey int(11) DEFAULT NULL,
+l_suppkey int(11) DEFAULT NULL,
+PRIMARY KEY (l_orderkey)) engine=aria;
+insert into t1 select seq,seq,seq from seq_1_to_1000;
+explain select straight_join count(*) from seq_1_to_10000,t1 where seq=l_orderkey;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE seq_1_to_10000 index PRIMARY PRIMARY 8 NULL 10000 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.seq_1_to_10000.seq 1 Using where; Using index
+show status like "last_query_cost";
+Variable_name Value
+Last_query_cost 5.641229
+set @org_cost=@@aria.optimizer_key_next_find_cost;
+set global aria.optimizer_key_next_find_cost=1000;
+flush tables;
+explain select count(*) from seq_1_to_10000,t1 where seq=l_orderkey;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE seq_1_to_10000 index PRIMARY PRIMARY 8 NULL 10000 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.seq_1_to_10000.seq 1 Using where; Using index
+show status like "last_query_cost";
+Variable_name Value
+Last_query_cost 5.641229
+set global aria.optimizer_key_next_find_cost=@org_cost;
+drop table t1;
+#
+# Testing distinct group optimization
+#
+create table t1 (a int, b int, key(a,b));
+insert into t1 select seq,seq from seq_1_to_1000;
+explain select count(distinct a,b) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 1000 Using index for group-by (scanning)
+explain select count(distinct a,b) from t1 where a>100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 10 NULL 901 Using where; Using index for group-by (scanning)
+explain select count(distinct a,b) from t1 where a>800;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 206 Using where; Using index
+update t1 set a=mod(a,10);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select count(distinct a,b) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 1000 Using index for group-by (scanning)
+explain select count(distinct a,b) from t1 where a>1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 10 NULL 788 Using where; Using index for group-by (scanning)
+explain select count(distinct a,b) from t1 where a>8;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 109 Using where; Using index
+update t1 set b=mod(b,2);
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+explain select count(distinct a,b) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 10 NULL 11 Using index for group-by
+explain select count(distinct a,b) from t1 where a>1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 10 NULL 9 Using where; Using index for group-by
+explain select count(distinct a,b) from t1 where a>8;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 10 NULL 1 Using where; Using index for group-by
+drop table t1;
+#
+# cleanup
+#
+Start_engines: 9 End_engines: 10
diff --git a/mysql-test/main/optimizer_costs.test b/mysql-test/main/optimizer_costs.test
new file mode 100644
index 00000000000..13ce927fb26
--- /dev/null
+++ b/mysql-test/main/optimizer_costs.test
@@ -0,0 +1,187 @@
+#
+# Test of optimizer_costs
+#
+--source include/have_innodb.inc
+--source include/have_sequence.inc
+
+select table_name,engine from information_schema.tables where table_name="optimizer_costs";
+show create table information_schema.optimizer_costs;
+let $start_engines=`select count(*) from information_schema.optimizer_costs`;
+--vertical_results
+select * from information_schema.optimizer_costs where engine in
+("memory","innodb","aria","default") order by engine;
+--horizontal_results
+show variables like "optimizer%cost";
+show variables like "optimizer_disk_read_ratio";
+
+--echo #
+--echo # Test change some 'default' variables
+--echo #
+SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost;
+SET global optimizer_disk_read_ratio=0.8;
+SET global optimizer_index_block_copy_cost=0.1;
+SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost;
+select optimizer_disk_read_ratio,optimizer_index_block_copy_cost from information_schema.optimizer_costs where engine='default';
+SET global optimizer_disk_read_ratio=default;
+SET global optimizer_index_block_copy_cost=default;
+SELECT @@optimizer_disk_read_ratio,@@optimizer_index_block_copy_cost;
+
+--echo #
+--echo # Test change some 'engine' variables
+--echo #
+select @@MEMORY.optimizer_row_lookup_cost;
+set @tmp=@@MEMORY.optimizer_row_lookup_cost;
+set @@global.MEMORY.optimizer_row_lookup_cost=1;
+select @@MEMORY.optimizer_row_lookup_cost;
+set @@global.MEMORY.optimizer_row_lookup_cost=default;
+select @@MEMORY.optimizer_row_lookup_cost;
+set @@global.MEMORY.optimizer_row_lookup_cost=@tmp;
+select @@MEMORY.optimizer_row_lookup_cost;
+
+--echo #
+--echo # Print variables with different syntaxes
+--echo #
+SHOW VARIABLES like "optimizer_row_lookup_cost";
+SELECT @@optimizer_row_lookup_cost;
+SELECT @@global.default.optimizer_row_lookup_cost;
+SELECT @@global.default.`optimizer_row_lookup_cost`;
+SELECT @@MEMORY.optimizer_row_lookup_cost;
+SELECT @@memory.optimizer_row_lookup_cost;
+SELECT @@InnoDB.optimizer_row_lookup_cost;
+
+--echo #
+--echo # Accessing not existing cost
+--echo #
+SELECT @@not_existing.optimizer_row_lookup_cost;
+SELECT @@NOT_existing.optimizer_row_lookup_cost;
+select engine from information_schema.optimizer_costs where engine like '%existing';
+
+--echo #
+--echo # Creating a new cost structure
+--echo #
+SET global new_engine.optimizer_disk_read_cost=100;
+select * from information_schema.optimizer_costs where engine like 'new_engine';
+select @@new_engine.optimizer_disk_read_cost, @@new_engine.optimizer_row_copy_cost;
+
+--echo #
+--echo # Errors
+--echo #
+--error ER_PARSE_ERROR
+SELECT @@default.optimizer_disk_read_cost;
+--error ER_WRONG_TYPE_FOR_VAR
+set global Aria.optimizer_disk_read_cost=NULL;
+
+set @tmp=@@Aria.optimizer_disk_read_cost;
+SET global Aria.optimizer_disk_read_cost=-1;
+select @@Aria.optimizer_disk_read_cost;
+SET global Aria.optimizer_disk_read_cost=200000;
+select @@Aria.optimizer_disk_read_cost;
+set global Aria.optimizer_disk_read_cost=@tmp;
+select @@Aria.optimizer_disk_read_cost;
+
+--echo #
+--echo # Test of cost of ref compared to table scan + join_cache
+--echo #
+
+create or replace table t1 (p int primary key, a char(10)) engine=myisam;
+create or replace table t2 (p int primary key, i int, a char(10), key k2(a)) engine=myisam;
+insert into t2 select seq,seq,'a' from seq_1_to_512;
+
+insert into t1 select seq,'a' from seq_1_to_4;
+explain select count(*) from t1, t2 where t1.p = t2.i;
+insert into t1 select seq,'a' from seq_5_to_10;
+explain select count(*) from t1, t2 where t1.p = t2.i;
+
+drop table t1,t2;
+
+--echo #
+--echo # Test of optimizer_scan_setup_cost
+--echo #
+
+create table t1 (p int primary key, a char(10)) engine=myisam;
+create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)) engine=myisam;
+insert into t1 values (2, 'qqqq'), (11, 'yyyy');
+insert into t2 values (1, 2, 'qqqq'), (2, 2, 'pppp'),
+ (3, 2, 'yyyy'), (4, 3, 'zzzz');
+set @org_myisam_disk_read_ratio=@@myisam.optimizer_disk_read_ratio;
+set @@optimizer_scan_setup_cost=10,@@global.myisam.optimizer_disk_read_ratio=0.2;
+flush tables;
+explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i;
+set @@optimizer_scan_setup_cost=0.0, @@global.myisam.optimizer_disk_read_ratio=0.0;
+flush tables;
+explain select sum(t2.p+length(t1.a)) from t1, t2 where t1.p = t2.i;
+set @@optimizer_scan_setup_cost=default,@@global.myisam.optimizer_disk_read_ratio=@org_myisam_disk_read_ratio;
+flush tables;
+drop table t1,t2;
+
+--echo #
+--echo # Test of group by optimization
+--echo #
+
+set @@optimizer_scan_setup_cost=0;
+CREATE TABLE t1 (id INT NOT NULL, a DATE, KEY(id,a)) engine=myisam;
+INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'),
+(1,'2001-01-03'),(1,'2001-01-04'),
+(2,'2001-01-01'),(2,'2001-01-02'),
+(2,'2001-01-03'),(2,'2001-01-04'),
+(3,'2001-01-01'),(3,'2001-01-02'),
+(3,'2001-01-03'),(3,'2001-01-04'),
+(4,'2001-01-01'),(4,'2001-01-02'),
+(4,'2001-01-03'),(4,'2001-01-04');
+analyze table t1;
+EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+insert into t1 values (3,'2001-01-03'),(3,'2001-01-04');
+analyze table t1;
+EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id;
+drop table t1;
+set @@optimizer_scan_setup_cost=default;
+
+--echo #
+--echo # Test of straight join costs
+--echo #
+create table t1 (l_orderkey int(11) NOT NULL,
+ l_partkey int(11) DEFAULT NULL,
+ l_suppkey int(11) DEFAULT NULL,
+ PRIMARY KEY (l_orderkey)) engine=aria;
+insert into t1 select seq,seq,seq from seq_1_to_1000;
+explain select straight_join count(*) from seq_1_to_10000,t1 where seq=l_orderkey;
+show status like "last_query_cost";
+set @org_cost=@@aria.optimizer_key_next_find_cost;
+# Set cost for t1 high so that we cannot use it for index scans
+set global aria.optimizer_key_next_find_cost=1000;
+flush tables;
+explain select count(*) from seq_1_to_10000,t1 where seq=l_orderkey;
+show status like "last_query_cost";
+set global aria.optimizer_key_next_find_cost=@org_cost;
+drop table t1;
+
+--echo #
+--echo # Testing distinct group optimization
+--echo #
+
+create table t1 (a int, b int, key(a,b));
+insert into t1 select seq,seq from seq_1_to_1000;
+explain select count(distinct a,b) from t1;
+explain select count(distinct a,b) from t1 where a>100;
+explain select count(distinct a,b) from t1 where a>800;
+update t1 set a=mod(a,10);
+analyze table t1;
+explain select count(distinct a,b) from t1;
+explain select count(distinct a,b) from t1 where a>1;
+explain select count(distinct a,b) from t1 where a>8;
+update t1 set b=mod(b,2);
+analyze table t1;
+explain select count(distinct a,b) from t1;
+explain select count(distinct a,b) from t1 where a>1;
+explain select count(distinct a,b) from t1 where a>8;
+drop table t1;
+
+--echo #
+--echo # cleanup
+--echo #
+
+let $end_engines=`select count(*) from information_schema.optimizer_costs`;
+--echo Start_engines: $start_engines End_engines: $end_engines
diff --git a/mysql-test/main/optimizer_costs2-master.opt b/mysql-test/main/optimizer_costs2-master.opt
new file mode 100644
index 00000000000..718ccafc05e
--- /dev/null
+++ b/mysql-test/main/optimizer_costs2-master.opt
@@ -0,0 +1 @@
+--optimizer_disk_read_ratio=0.9 --MEMORY.optimizer_disk_read_ratio=0.1 --memory.optimizer_disk_read_ratio=0.3 --memory.optimizer_row_lookup_cost=0.8
diff --git a/mysql-test/main/optimizer_costs2.result b/mysql-test/main/optimizer_costs2.result
new file mode 100644
index 00000000000..688dcb51110
--- /dev/null
+++ b/mysql-test/main/optimizer_costs2.result
@@ -0,0 +1,8 @@
+select engine,optimizer_disk_read_ratio from information_schema.optimizer_costs where engine in ("memory","aria","default");
+engine optimizer_disk_read_ratio
+default 0.900000
+MEMORY 0.300000
+Aria 0.900000
+select @@memory.optimizer_row_lookup_cost;
+@@memory.optimizer_row_lookup_cost
+0.800000
diff --git a/mysql-test/main/optimizer_costs2.test b/mysql-test/main/optimizer_costs2.test
new file mode 100644
index 00000000000..0445ce523cd
--- /dev/null
+++ b/mysql-test/main/optimizer_costs2.test
@@ -0,0 +1,6 @@
+#
+# Check default optimizer_cost_arguments
+#
+
+select engine,optimizer_disk_read_ratio from information_schema.optimizer_costs where engine in ("memory","aria","default");
+select @@memory.optimizer_row_lookup_cost;
diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result
index 529221dcfb6..6586400bdbe 100644
--- a/mysql-test/main/order_by.result
+++ b/mysql-test/main/order_by.result
@@ -1193,7 +1193,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index k2 k3 5 NULL 111 Using where
EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 4000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref k2 k2 5 const 7341 Using where; Using filesort
+1 SIMPLE t2 range k2 k2 5 NULL 7341 Using index condition; Using filesort
+EXPLAIN SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 6000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL k2 NULL NULL NULL 40960 Using where; Using filesort
EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 10 AND 12 ORDER BY c3 LIMIT 20;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index k2 k3 5 NULL 73 Using where
@@ -1573,19 +1576,20 @@ ANALYZE
"r_sort_mode": "sort_key,addon_fields",
"table": {
"table_name": "t1",
- "access_type": "index",
+ "access_type": "ref_or_null",
"possible_keys": ["a_c", "a"],
"key": "a_c",
"key_length": "10",
"used_key_parts": ["a", "c"],
+ "ref": ["const", "const"],
"r_loops": 1,
"rows": 2,
- "r_rows": 2,
+ "r_rows": 1,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 50,
- "r_filtered": 50,
- "attached_condition": "t1.a = 2 and (t1.c = 10 or t1.c is null)",
+ "r_filtered": 100,
+ "attached_condition": "t1.c = 10 or t1.c is null",
"using_index": true
}
}
@@ -1595,26 +1599,11 @@ ANALYZE
EXPLAIN
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a_c,a a_c 10 NULL 2 Using where; Using index; Using filesort
+1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 2 Using where; Using index; Using filesort
# Must return 1 row
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
col
1
-# With more rows "filesort" is removed
-INSERT INTO t1 select seq,seq from seq_1_to_2;
-EXPLAIN
-SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a_c,a a_c 10 NULL 2 Using where; Using index
-SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
-col
-1
-# With more rows "range" changes to "ref_or_null"
-INSERT INTO t1 select seq,seq from seq_3_to_10;
-EXPLAIN
-SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref_or_null a_c,a a_c 10 const,const 2 Using where; Using index; Using filesort
# Must use ref-or-null on the a_c index
EXPLAIN
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c DESC;
@@ -3124,7 +3113,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY t3a ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary
-1 PRIMARY t3b ref f3_key f3_key 6 test.t3a.f3 1 100.00 Using where; End temporary
+1 PRIMARY t3b ref f3_key f3_key 6 test.t3a.f3 1 50.00 Using where; End temporary
Warnings:
Note 1003 select concat('foo',`test`.`t2`.`f2`) AS `field` from `test`.`t2` semi join ((`test`.`t3` `t3a` join `test`.`t3` `t3b`)) where `test`.`t3a`.`f3` < 'foo' or `test`.`t3b`.`f3` <> 'foo' order by concat('foo',`test`.`t2`.`f2`)
DROP TABLE t1,t2,t3;
@@ -3178,7 +3167,7 @@ id select_type table type possible_keys key key_len ref rows Extra
# See above query
EXPLAIN SELECT id1 FROM t2 WHERE id2=1 AND id3=1 ORDER BY date DESC LIMIT 0,4;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range id_23_date,id_234_date id_23_date 2 NULL 8 Using where
+1 SIMPLE t2 ref id_23_date,id_234_date id_23_date 2 const,const 8 Using where
drop table t1,t2;
#
# MDEV-8989: ORDER BY optimizer ignores equality propagation
@@ -3552,8 +3541,8 @@ WHERE books.library_id = 8663 AND
books.scheduled_for_removal=0 )
ORDER BY wings.id;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY wings ALL PRIMARY NULL NULL NULL 2 100.00 Using temporary; Using filesort
-1 PRIMARY books ALL library_idx NULL NULL NULL 2 100.00 Using where; FirstMatch(wings); Using join buffer (flat, BNL join)
+1 PRIMARY wings ALL PRIMARY NULL NULL NULL 2 100.00 Using filesort
+1 PRIMARY books ref library_idx library_idx 4 const 2 50.00 Using where; FirstMatch(wings)
Warnings:
Note 1003 select `test`.`wings`.`id` AS `wing_id`,`test`.`wings`.`department_id` AS `department_id` from `test`.`wings` semi join (`test`.`books`) where `test`.`books`.`library_id` = 8663 and `test`.`books`.`scheduled_for_removal` = 0 and `test`.`books`.`wings_id` = `test`.`wings`.`id` order by `test`.`wings`.`id`
set optimizer_switch= @save_optimizer_switch;
@@ -3687,8 +3676,8 @@ WHERE
t2.key1 = t1.a and t2.key1 IS NOT NULL
ORDER BY
t2.key2 ASC
-LIMIT 1)
-from t1;
+LIMIT 1) as "con"
+ from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10
2 DEPENDENT SUBQUERY t2 ref key1 key1 5 test.t1.a 10 Using index condition; Using where; Using filesort
@@ -3699,15 +3688,9 @@ WHERE
t2.key1 = t1.a and t2.key1 IS NOT NULL
ORDER BY
t2.key2 ASC
-LIMIT 1)
-from t1;
-(SELECT concat(id, '-', key1, '-', col1)
-FROM t2
-WHERE
-t2.key1 = t1.a and t2.key1 IS NOT NULL
-ORDER BY
-t2.key2 ASC
-LIMIT 1)
+LIMIT 1) as "con"
+ from t1;
+con
100-0-123456
101-1-123456
102-2-123456
@@ -4404,7 +4387,8 @@ CREATE TABLE t1 (a INT, b int, primary key(a));
CREATE TABLE t2 (a INT, b INT);
INSERT INTO t1 (a,b) VALUES (58,1),(96,2),(273,3),(23,4),(231,5),(525,6),
(2354,7),(321421,3),(535,2),(4535,3);
-INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000);
+INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000),(3000,3000);
+INSERT INTO t2 select seq,seq from seq_10_to_30;
# Join order should have the SJM scan table as the first table for both
# the queries with GROUP BY and ORDER BY clause.
EXPLAIN SELECT t1.a
@@ -4412,9 +4396,9 @@ FROM t1
WHERE t1.a IN (SELECT a FROM t2 WHERE b=3)
ORDER BY t1.a DESC;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 5 Using filesort
-1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1 Using index
-2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 10 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 27 Using where
EXPLAIN FORMAT=JSON SELECT t1.a
FROM t1
WHERE t1.a IN (SELECT a FROM t2 WHERE b=3)
@@ -4423,42 +4407,40 @@ EXPLAIN
{
"query_block": {
"select_id": 1,
- "read_sorted_file": {
- "filesort": {
- "sort_key": "t1.a desc",
- "table": {
- "table_name": "<subquery2>",
- "access_type": "ALL",
- "possible_keys": ["distinct_key"],
- "rows": 5,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t2.b = 3 and t2.a is not null"
- }
- }
- }
- }
- }
- },
"table": {
"table_name": "t1",
- "access_type": "eq_ref",
+ "access_type": "index",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["a"],
- "ref": ["test.t2.a"],
- "rows": 1,
+ "rows": 10,
"filtered": 100,
"using_index": true
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "4",
+ "used_key_parts": ["a"],
+ "ref": ["func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 27,
+ "filtered": 100,
+ "attached_condition": "t2.b = 3"
+ }
+ }
+ }
}
}
}
@@ -4475,9 +4457,9 @@ FROM t1
WHERE t1.a IN (SELECT a FROM t2 WHERE b=3)
GROUP BY t1.a DESC;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 5 Using filesort
-1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1
-2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 10 Using filesort
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 27 Using where
EXPLAIN FORMAT=JSON SELECT t1.a, group_concat(t1.b)
FROM t1
WHERE t1.a IN (SELECT a FROM t2 WHERE b=3)
@@ -4490,37 +4472,37 @@ EXPLAIN
"filesort": {
"sort_key": "t1.a desc",
"table": {
- "table_name": "<subquery2>",
+ "table_name": "t1",
"access_type": "ALL",
- "possible_keys": ["distinct_key"],
- "rows": 5,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t2.b = 3 and t2.a is not null"
- }
- }
- }
+ "possible_keys": ["PRIMARY"],
+ "rows": 10,
+ "filtered": 100
}
}
},
"table": {
- "table_name": "t1",
+ "table_name": "<subquery2>",
"access_type": "eq_ref",
- "possible_keys": ["PRIMARY"],
- "key": "PRIMARY",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
"key_length": "4",
"used_key_parts": ["a"],
- "ref": ["test.t2.a"],
+ "ref": ["func"],
"rows": 1,
- "filtered": 100
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 27,
+ "filtered": 100,
+ "attached_condition": "t2.b = 3"
+ }
+ }
+ }
}
}
}
diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test
index 9f251b15ea8..5bc1e4ca82a 100644
--- a/mysql-test/main/order_by.test
+++ b/mysql-test/main/order_by.test
@@ -923,17 +923,6 @@ SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
--echo # Must return 1 row
SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
---echo # With more rows "filesort" is removed
-INSERT INTO t1 select seq,seq from seq_1_to_2;
-EXPLAIN
-SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
-SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
-
---echo # With more rows "range" changes to "ref_or_null"
-INSERT INTO t1 select seq,seq from seq_3_to_10;
-EXPLAIN
-SELECT 1 AS col FROM t1 WHERE a=2 AND (c=10 OR c IS NULL) ORDER BY c;
-
# part 2 of the problem : DESC test cases
--echo # Must use ref-or-null on the a_c index
--replace_column 1 x 2 x 3 x 6 x 7 x 8 x 9 x 10 x
@@ -2410,7 +2399,7 @@ let $query= select
t2.key1 = t1.a and t2.key1 IS NOT NULL
ORDER BY
t2.key2 ASC
- LIMIT 1)
+ LIMIT 1) as "con"
from t1;
--echo # here type should show ref not index
@@ -2693,8 +2682,8 @@ CREATE TABLE t2 (a INT, b INT);
INSERT INTO t1 (a,b) VALUES (58,1),(96,2),(273,3),(23,4),(231,5),(525,6),
(2354,7),(321421,3),(535,2),(4535,3);
-INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000);
-
+INSERT INTO t2 (a,b) VALUES (58,3),(96,3),(273,3),(1000,1000),(2000,2000),(3000,3000);
+INSERT INTO t2 select seq,seq from seq_10_to_30;
--echo # Join order should have the SJM scan table as the first table for both
--echo # the queries with GROUP BY and ORDER BY clause.
diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result
index 58d0464b86f..b2f82212026 100644
--- a/mysql-test/main/partition.result
+++ b/mysql-test/main/partition.result
@@ -2361,11 +2361,11 @@ b c
EXPLAIN
SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by
+1 SIMPLE t1 ref bc bc 5 const 23 Using where; Using index
EXPLAIN
SELECT b, c FROM t1 WHERE b = 1 or b=2 GROUP BY b, c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range bc bc 10 NULL 8 Using where; Using index for group-by
+1 SIMPLE t1 range bc bc 5 NULL 23 Using where; Using index
DROP TABLE t1;
#
# Bug #45807: crash accessing partitioned table and sql_mode
diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result
index dcc25892276..7f07a6c4257 100644
--- a/mysql-test/main/partition_pruning.result
+++ b/mysql-test/main/partition_pruning.result
@@ -18,7 +18,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
# # # # range # # # # 3 #
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
-# # # # range # # # # 8 #
+# # # # index # # # # 10 #
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
# # # # range # # # # 3 #
@@ -92,7 +92,7 @@ a
5
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a < 7;
a
-1
@@ -105,7 +105,7 @@ a
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 1;
a
-1
@@ -155,7 +155,7 @@ a
5
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a <= 6;
a
-1
@@ -168,7 +168,7 @@ a
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a <= 7;
a
-1
@@ -182,7 +182,7 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a = 1;
a
1
@@ -237,7 +237,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
+1 SIMPLE t1 p1,p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a >= 2;
a
2
@@ -424,7 +424,7 @@ a
5
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 1;
a
-1
@@ -474,7 +474,7 @@ a
5
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 5;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a <= 6;
a
-1
@@ -487,7 +487,7 @@ a
6
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a = 1;
a
1
@@ -2888,12 +2888,12 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
explain extended select * from t2 where b in (2,4,6);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 range b b 5 NULL 231 100.00 Using where
+1 SIMPLE t2 ALL b NULL NULL NULL 910 25.38 Using where
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` in (2,4,6)
explain partitions select * from t2 where b in (2,4,6);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 p0,p1,p2,p3,p4 range b b 5 NULL 231 Using where
+1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
explain extended select * from t2 where b in (7,8,9);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL b NULL NULL NULL 910 36.81 Using where
@@ -2912,12 +2912,12 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
explain extended select * from t2 where b > 5 and b < 8;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 range b b 5 NULL 202 100.00 Using where
+1 SIMPLE t2 ALL b NULL NULL NULL 910 22.20 Using where
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` where `test`.`t2`.`b` > 5 and `test`.`t2`.`b` < 8
explain partitions select * from t2 where b > 5 and b < 8;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 p0,p1,p2,p3,p4 range b b 5 NULL 202 Using where
+1 SIMPLE t2 p0,p1,p2,p3,p4 ALL b NULL NULL NULL 910 Using where
explain extended select * from t2 where b > 5 and b < 7;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 range b b 5 NULL 77 100.00 Using where
@@ -2946,10 +2946,10 @@ flush status;
update t2 set a = 111 where b in (5,6);
show status like 'Handler_read_rnd_next';
Variable_name Value
-Handler_read_rnd_next 0
+Handler_read_rnd_next 915
show status like 'Handler_read_key';
Variable_name Value
-Handler_read_key 10
+Handler_read_key 0
flush status;
update t2 set a = 222 where b = 7;
show status like 'Handler_read_rnd_next';
@@ -3378,7 +3378,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 const PRIMARY PRIMARY 8 const,const 1
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 >= 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p1,p2 ref PRIMARY PRIMARY 4 const 1 Using where
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
@@ -3387,7 +3387,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 range PRIMARY PRIMARY 8 NULL 2 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 1 AND c2 <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p1,p2 ref PRIMARY PRIMARY 4 const 1 Using where
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
@@ -3405,7 +3405,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 2 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 <= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p1,p2 ref PRIMARY PRIMARY 4 const 1 Using where
+1 SIMPLE t1 p1,p2 range PRIMARY PRIMARY 8 NULL 3 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE c1 = 2 AND c2 = 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 const PRIMARY PRIMARY 8 const,const 1
@@ -3465,7 +3465,7 @@ select * from t1
where company_id = 1000
and dept_id in (select dept_id from t2 where COMPANY_ID = 1000);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 p_1000 ALL PRIMARY NULL NULL NULL 6 Using where
+1 PRIMARY t1 p_1000 ref PRIMARY PRIMARY 8 const 6 Using where
1 PRIMARY t2 p_1000 eq_ref PRIMARY PRIMARY 16 const,test.t1.dept_id 1 Using index
drop table t1,t2;
#
diff --git a/mysql-test/main/partition_range.result b/mysql-test/main/partition_range.result
index 2c6b735560c..91ce2fcac18 100644
--- a/mysql-test/main/partition_range.result
+++ b/mysql-test/main/partition_range.result
@@ -19,11 +19,11 @@ insert into t1 (a,b) select seq,seq from seq_4001_to_4100;
insert into t1 (a,b) select seq,seq from seq_10001_to_10100;
EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index for group-by
alter table t1 partition by hash(a) partitions 1;
EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 3 Using where; Using index for group-by
DROP TABLE t1;
create table t1 (a DATETIME)
partition by range (TO_DAYS(a))
@@ -958,6 +958,11 @@ CREATE TABLE t1 (
a INT,
b INT,
KEY ( a, b )
+);
+CREATE TABLE t1_part (
+a INT,
+b INT,
+KEY ( a, b )
) PARTITION BY HASH (a) PARTITIONS 1;
CREATE TABLE t2 (
a INT,
@@ -969,36 +974,68 @@ INSERT INTO t1 SELECT a + 5, b + 5 FROM t1;
INSERT INTO t1 SELECT a + 10, b + 10 FROM t1;
INSERT INTO t1 SELECT a + 20, b + 20 FROM t1;
INSERT INTO t1 SELECT a + 40, b + 40 FROM t1;
+INSERT INTO t1 values(10,0),(10,1),(10,2),(100,0),(100,1);
+select count(*) from t1;
+count(*)
+85
+select count(*) from t1 where a=10;
+count(*)
+4
+select count(*) from t1 where a=100;
+count(*)
+2
+INSERT INTO t1_part SELECT * FROM t1;
INSERT INTO t2 SELECT * FROM t1;
-ANALYZE TABLE t1,t2;
+ANALYZE TABLE t1_part,t2;
Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
-test.t1 analyze status OK
+test.t1_part analyze status Engine-independent statistics collected
+test.t1_part analyze status OK
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status Table is already up to date
# plans should be identical
-EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a;
+EXPLAIN SELECT a, MAX(b) FROM t1_part WHERE a IN (10,100) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 2 Using where; Using index
+1 SIMPLE t1_part range a a 5 NULL 2 Using where; Using index for group-by
EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index
+1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by
FLUSH status;
-SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a;
+SELECT a, MAX(b) FROM t1_part WHERE a IN (10, 100) GROUP BY a;
a MAX(b)
10 10
-# Should be no more than 4 reads.
-SHOW status LIKE 'handler_read_key';
+100 1
+SHOW status LIKE 'handler_read%';
Variable_name Value
-Handler_read_key 2
+Handler_read_first 0
+Handler_read_key 6
+Handler_read_last 1
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
FLUSH status;
SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a;
a MAX(b)
10 10
-# Should be no more than 4 reads.
-SHOW status LIKE 'handler_read_key';
+100 1
+SHOW status LIKE 'handler_read%';
Variable_name Value
-Handler_read_key 2
+Handler_read_first 0
+Handler_read_key 6
+Handler_read_last 1
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+insert into t2 select 100,seq from seq_1_to_100;
+EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range a a 5 NULL 2 Using where; Using index for group-by
+DROP TABLE t1,t2;
#
# MDEV-18501 Partition pruning doesn't work for historical queries
#
@@ -1026,7 +1063,7 @@ d
select * from t1 partition (p1);
d
2000-01-01 00:00:01.000000
-DROP TABLE t1, t2;
+DROP TABLE t1;
#
# MDEV-21195 INSERT chooses wrong partition for RANGE partitioning by DECIMAL column
#
diff --git a/mysql-test/main/partition_range.test b/mysql-test/main/partition_range.test
index 740cbcd7d7b..8e91c7a6bbf 100644
--- a/mysql-test/main/partition_range.test
+++ b/mysql-test/main/partition_range.test
@@ -942,10 +942,17 @@ drop table t1, t2;
--echo # Bug#50939: Loose Index Scan unduly relies on engine to remember range
--echo # endpoints
--echo #
+
CREATE TABLE t1 (
a INT,
b INT,
KEY ( a, b )
+);
+
+CREATE TABLE t1_part (
+ a INT,
+ b INT,
+ KEY ( a, b )
) PARTITION BY HASH (a) PARTITIONS 1;
CREATE TABLE t2 (
@@ -960,24 +967,32 @@ INSERT INTO t1 SELECT a + 5, b + 5 FROM t1;
INSERT INTO t1 SELECT a + 10, b + 10 FROM t1;
INSERT INTO t1 SELECT a + 20, b + 20 FROM t1;
INSERT INTO t1 SELECT a + 40, b + 40 FROM t1;
+INSERT INTO t1 values(10,0),(10,1),(10,2),(100,0),(100,1);
+select count(*) from t1;
+select count(*) from t1 where a=10;
+select count(*) from t1 where a=100;
+INSERT INTO t1_part SELECT * FROM t1;
INSERT INTO t2 SELECT * FROM t1;
-ANALYZE TABLE t1,t2;
+ANALYZE TABLE t1_part,t2;
--echo # plans should be identical
-EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10,100) GROUP BY a;
+EXPLAIN SELECT a, MAX(b) FROM t1_part WHERE a IN (10,100) GROUP BY a;
EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
FLUSH status;
-SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100) GROUP BY a;
---echo # Should be no more than 4 reads.
-SHOW status LIKE 'handler_read_key';
+SELECT a, MAX(b) FROM t1_part WHERE a IN (10, 100) GROUP BY a;
+SHOW status LIKE 'handler_read%';
FLUSH status;
SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a;
---echo # Should be no more than 4 reads.
-SHOW status LIKE 'handler_read_key';
+SHOW status LIKE 'handler_read%';
+
+insert into t2 select 100,seq from seq_1_to_100;
+EXPLAIN SELECT a, MAX(b) FROM t2 WHERE a IN (10,100) GROUP BY a;
+
+DROP TABLE t1,t2;
--echo #
--echo # MDEV-18501 Partition pruning doesn't work for historical queries
@@ -1006,7 +1021,7 @@ insert into t1 values
select * from t1 partition (p0);
select * from t1 partition (p1);
-DROP TABLE t1, t2;
+DROP TABLE t1;
--echo #
--echo # MDEV-21195 INSERT chooses wrong partition for RANGE partitioning by DECIMAL column
diff --git a/mysql-test/main/pool_of_threads.result b/mysql-test/main/pool_of_threads.result
index 91ad7ab098f..718cb7dc8ce 100644
--- a/mysql-test/main/pool_of_threads.result
+++ b/mysql-test/main/pool_of_threads.result
@@ -1,5 +1,6 @@
SET optimizer_switch='outer_join_with_cache=off';
drop table if exists t1,t2,t3,t4;
+set @@default_storage_engine="aria";
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -600,6 +601,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
+#
+# Some test with ORDER BY and limit
+#
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
@@ -1289,7 +1293,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
PRIMARY KEY (companynr),
UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
+) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
companynr companyname
00 Unknown
@@ -1379,6 +1383,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
+#
+# Test left join optimization
+#
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
@@ -1393,15 +1400,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1417,11 +1424,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/main/range_vs_index_merge.result b/mysql-test/main/range_vs_index_merge.result
index 3babbc989b3..c69586ab3f2 100644
--- a/mysql-test/main/range_vs_index_merge.result
+++ b/mysql-test/main/range_vs_index_merge.result
@@ -333,7 +333,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City WHERE (ID < 600) OR (ID BETWEEN 900 AND 1500);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range PRIMARY PRIMARY 4 NULL 1200 Using index condition
+1 SIMPLE City ALL PRIMARY NULL NULL NULL 4079 Using where
EXPLAIN
SELECT * FROM City WHERE Country > 'A' AND Country < 'ARG';
id select_type table type possible_keys key key_len ref rows Extra
@@ -949,7 +949,7 @@ WHERE ((Population > 101000 AND Population < 11000) OR
ID BETWEEN 3500 AND 3800) AND Country='USA'
AND (Name LIKE 'P%' OR ID BETWEEN 4000 AND 4300);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range|filter PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName|PRIMARY 38|4 NULL 23 (7%) Using index condition; Using where; Using rowid filter
+1 SIMPLE City range PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName 38 NULL 23 Using index condition; Using where
EXPLAIN
SELECT * FROM City
WHERE ((Population > 101000 AND Population < 11000) OR
@@ -1750,6 +1750,9 @@ SELECT * FROM t1,t2,t3
WHERE (t2.f3 = 1 OR t3.f1=t2.f1) AND t3.f1 <> t2.f2 AND t3.f2 = t2.f4;
f1 f1 f2 f3 f4 f1 f2
DROP TABLE t1,t2,t3;
+#
+# LP bug #823301: index merge sort union with possible index scan
+#
CREATE TABLE t1 (
a int, b int, c int, d int,
PRIMARY KEY(b), INDEX idx1(d), INDEX idx2(d,b,c)
@@ -1766,7 +1769,7 @@ EXPLAIN
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where
+1 SIMPLE t1 range PRIMARY,idx1,idx2 idx1 5 NULL 5 Using index condition; Using where
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
a b c d
@@ -1780,7 +1783,7 @@ EXPLAIN
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY,idx1,idx2 NULL NULL NULL 9 Using where
+1 SIMPLE t1 range PRIMARY,idx1,idx2 idx1 5 NULL 5 Using index condition; Using where
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
a b c d
@@ -1894,7 +1897,7 @@ INDEX (Percentage)
DROP INDEX Country ON City;
CREATE INDEX CountryName ON City(Country,Name);
CREATE INDEX Name ON City(Name);
-select * from City
+explain select * from City
where
Country='FIN' AND Name IN ('Lahti','Imatra') OR
Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR
@@ -1906,26 +1909,9 @@ Country='FRA' AND Name IN ('Paris', 'Marcel') OR
Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR
Country='NOR' AND Name IN ('Oslo', 'Bergen') OR
Country='ITA' AND Name IN ('Napoli', 'Venezia');
-ID Name Country Population
-175 Antwerpen BEL 446525
-176 Gent BEL 224180
-3068 Berlin DEU 3386667
-3087 Bonn DEU 301048
-3242 Lahti FIN 96921
-2974 Paris FRA 2125246
-1466 Napoli ITA 1002619
-1474 Venezia ITA 277305
-2808 Bergen NOR 230948
-2807 Oslo NOR 508726
-2928 Warszawa POL 1615369
-2931 Wroclaw POL 636765
-2918 Braga PRT 90535
-2915 Porto PRT 273060
-3580 Moscow RUS 8389200
-3581 St Petersburg RUS 4694000
-3048 Stockholm SWE 750348
-3051 Uppsala SWE 189569
-explain select * from City
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE City range CountryName,Name CountryName 38 NULL 20 Using index condition
+select * from City
where
Country='FIN' AND Name IN ('Lahti','Imatra') OR
Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR
@@ -1937,7 +1923,24 @@ Country='FRA' AND Name IN ('Paris', 'Marcel') OR
Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR
Country='NOR' AND Name IN ('Oslo', 'Bergen') OR
Country='ITA' AND Name IN ('Napoli', 'Venezia');
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range CountryName,Name CountryName 38 NULL 20 Using index condition
+ID Name Country Population
+1466 Napoli ITA 1002619
+1474 Venezia ITA 277305
+175 Antwerpen BEL 446525
+176 Gent BEL 224180
+2807 Oslo NOR 508726
+2808 Bergen NOR 230948
+2915 Porto PRT 273060
+2918 Braga PRT 90535
+2928 Warszawa POL 1615369
+2931 Wroclaw POL 636765
+2974 Paris FRA 2125246
+3048 Stockholm SWE 750348
+3051 Uppsala SWE 189569
+3068 Berlin DEU 3386667
+3087 Bonn DEU 301048
+3242 Lahti FIN 96921
+3580 Moscow RUS 8389200
+3581 St Petersburg RUS 4694000
DROP DATABASE world;
set session optimizer_switch='index_merge_sort_intersection=default';
diff --git a/mysql-test/main/range_vs_index_merge.test b/mysql-test/main/range_vs_index_merge.test
index a8e86e44b9e..3f8427e7bf6 100644
--- a/mysql-test/main/range_vs_index_merge.test
+++ b/mysql-test/main/range_vs_index_merge.test
@@ -1172,9 +1172,9 @@ SELECT * FROM t1,t2,t3
DROP TABLE t1,t2,t3;
-#
-# LP bug #823301: index merge sort union with possible index scan
-#
+--echo #
+--echo # LP bug #823301: index merge sort union with possible index scan
+--echo #
CREATE TABLE t1 (
a int, b int, c int, d int,
@@ -1190,12 +1190,14 @@ SET SESSION optimizer_switch='index_merge_sort_union=off';
EXPLAIN
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
+--sorted_result
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
SET SESSION optimizer_switch='index_merge_sort_union=on';
EXPLAIN
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
+--sorted_result
SELECT * FROM t1
WHERE t1.b>7 AND t1.d>1 AND t1.d<>8 OR t1.d>=7 AND t1.d<8 OR t1.d>7;
SET SESSION optimizer_switch=DEFAULT;
@@ -1318,9 +1320,9 @@ where
Country='NOR' AND Name IN ('Oslo', 'Bergen') OR
Country='ITA' AND Name IN ('Napoli', 'Venezia');
-eval $q;
eval explain $q;
-
+--sorted_result
+eval $q;
DROP DATABASE world;
diff --git a/mysql-test/main/range_vs_index_merge_innodb.result b/mysql-test/main/range_vs_index_merge_innodb.result
index de345f66161..2b831f0a89f 100644
--- a/mysql-test/main/range_vs_index_merge_innodb.result
+++ b/mysql-test/main/range_vs_index_merge_innodb.result
@@ -73,7 +73,7 @@ EXPLAIN
SELECT * FROM City
WHERE (Population > 101000 AND Population < 115000);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Population Population 4 NULL 459 Using index condition
+1 SIMPLE City ALL Population NULL NULL NULL 4079 Using where
EXPLAIN
SELECT * FROM City
WHERE (Population > 101000 AND Population < 102000);
@@ -191,7 +191,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City WHERE (Name BETWEEN 'P' AND 'S');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Name Name 35 NULL 385 Using index condition
+1 SIMPLE City ALL Name NULL NULL NULL 4079 Using where
EXPLAIN
SELECT * FROM City WHERE (Population > 101000 AND Population < 110000);
id select_type table type possible_keys key key_len ref rows Extra
@@ -347,7 +347,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City WHERE Name LIKE 'H%' OR Name LIKE 'P%' ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Name Name 35 NULL 395 Using index condition
+1 SIMPLE City ALL Name NULL NULL NULL 4079 Using where
EXPLAIN
SELECT * FROM City WHERE Name LIKE 'Ha%' OR Name LIKE 'Pa%' ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -365,7 +365,7 @@ WHERE ((ID < 800) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
OR ((ID BETWEEN 900 AND 1500) AND
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 105000)));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,Population 39,3,4 NULL 212 Using sort_union(Name,Country,Population); Using where
+1 SIMPLE City range PRIMARY,Population,Country,Name PRIMARY 4 NULL 1400 Using where
EXPLAIN
SELECT * FROM City
WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
@@ -588,7 +588,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City WHERE Country < 'C';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Country Country 3 NULL 446 Using index condition
+1 SIMPLE City ALL Country NULL NULL NULL 4079 Using where
EXPLAIN
SELECT * FROM City WHERE Country < 'AGO';
id select_type table type possible_keys key key_len ref rows Extra
@@ -596,7 +596,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City WHERE Name BETWEEN 'P' AND 'S';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Name Name 35 NULL 385 Using index condition
+1 SIMPLE City ALL Name NULL NULL NULL 4079 Using where
EXPLAIN
SELECT * FROM City WHERE Name BETWEEN 'P' AND 'Pb';
id select_type table type possible_keys key key_len ref rows Extra
@@ -620,7 +620,7 @@ WHERE ((Population > 101000 AND Population < 102000) AND
((ID BETWEEN 3400 AND 3800) AND
(Country < 'AGO' OR Name LIKE 'Pa%'));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge PRIMARY,Population,Country,Name Country,Name,Population 3,39,4 NULL 115 Using sort_union(Country,Name,Population); Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country,Name Population,PRIMARY 4,4 NULL 440 Using sort_union(Population,PRIMARY); Using where
EXPLAIN
SELECT * FROM City
WHERE ((Population > 101000 AND Population < 110000) AND
@@ -1242,7 +1242,7 @@ SELECT * FROM City
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
AND (Population >= 100000 AND Population < 120000);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Country,Name,Population Name,Country 35,3 NULL # Using sort_union(Name,Country); Using where
+1 SIMPLE City ALL Country,Name,Population NULL NULL NULL # Using where
FLUSH STATUS;
SELECT * FROM City
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
@@ -1310,14 +1310,14 @@ ID Name Country Population
SHOW STATUS LIKE 'Handler_read_%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 2
+Handler_read_key 0
Handler_read_last 0
-Handler_read_next 385
+Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
-Handler_read_rnd 377
+Handler_read_rnd 0
Handler_read_rnd_deleted 0
-Handler_read_rnd_next 0
+Handler_read_rnd_next 4080
EXPLAIN
SELECT * FROM City
WHERE ((Name > 'Ca' AND Name < 'Cf') OR (Country > 'E' AND Country < 'H'))
@@ -1660,7 +1660,7 @@ SELECT COUNT(*) FROM t1
WHERE c = 'i' OR b IN ( 'Arkansas' , 'd' , 'pdib' , 'can' ) OR
(pk BETWEEN 120 AND 79 + 255 OR a IN ( 4 , 179 , 1 ) ) AND a > 8 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index_merge PRIMARY,idx1,idx2,idx3 idx3,idx2,idx1,PRIMARY 67,13,3,4 NULL 9 Using sort_union(idx3,idx2,idx1,PRIMARY); Using where
+1 SIMPLE t1 ALL PRIMARY,idx1,idx2,idx3 NULL NULL NULL 87 Using where
DROP TABLE t1;
CREATE TABLE t1 (
f1 int, f2 int, f3 int, f4 int, f5 int,
@@ -1900,7 +1900,7 @@ INDEX (Percentage)
DROP INDEX Country ON City;
CREATE INDEX CountryName ON City(Country,Name);
CREATE INDEX Name ON City(Name);
-select * from City
+explain select * from City
where
Country='FIN' AND Name IN ('Lahti','Imatra') OR
Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR
@@ -1912,26 +1912,9 @@ Country='FRA' AND Name IN ('Paris', 'Marcel') OR
Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR
Country='NOR' AND Name IN ('Oslo', 'Bergen') OR
Country='ITA' AND Name IN ('Napoli', 'Venezia');
-ID Name Country Population
-175 Antwerpen BEL 446525
-2808 Bergen NOR 230948
-3068 Berlin DEU 3386667
-3087 Bonn DEU 301048
-2918 Braga PRT 90535
-176 Gent BEL 224180
-3242 Lahti FIN 96921
-3580 Moscow RUS 8389200
-1466 Napoli ITA 1002619
-2807 Oslo NOR 508726
-2974 Paris FRA 2125246
-2915 Porto PRT 273060
-3581 St Petersburg RUS 4694000
-3048 Stockholm SWE 750348
-3051 Uppsala SWE 189569
-1474 Venezia ITA 277305
-2928 Warszawa POL 1615369
-2931 Wroclaw POL 636765
-explain select * from City
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE City range CountryName,Name CountryName 38 NULL 20 Using index condition
+select * from City
where
Country='FIN' AND Name IN ('Lahti','Imatra') OR
Country='RUS' AND Name IN ('St Petersburg', 'Moscow') OR
@@ -1943,8 +1926,25 @@ Country='FRA' AND Name IN ('Paris', 'Marcel') OR
Country='POL' AND Name IN ('Warszawa', 'Wroclaw') OR
Country='NOR' AND Name IN ('Oslo', 'Bergen') OR
Country='ITA' AND Name IN ('Napoli', 'Venezia');
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range CountryName,Name Name 35 NULL 20 Using index condition; Using where
+ID Name Country Population
+1466 Napoli ITA 1002619
+1474 Venezia ITA 277305
+175 Antwerpen BEL 446525
+176 Gent BEL 224180
+2807 Oslo NOR 508726
+2808 Bergen NOR 230948
+2915 Porto PRT 273060
+2918 Braga PRT 90535
+2928 Warszawa POL 1615369
+2931 Wroclaw POL 636765
+2974 Paris FRA 2125246
+3048 Stockholm SWE 750348
+3051 Uppsala SWE 189569
+3068 Berlin DEU 3386667
+3087 Bonn DEU 301048
+3242 Lahti FIN 96921
+3580 Moscow RUS 8389200
+3581 St Petersburg RUS 4694000
DROP DATABASE world;
set session optimizer_switch='index_merge_sort_intersection=default';
set global innodb_stats_persistent= @innodb_stats_persistent_save;
diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result
index 76ce2eb78d4..600e6470c79 100644
--- a/mysql-test/main/rowid_filter.result
+++ b/mysql-test/main/rowid_filter.result
@@ -228,7 +228,7 @@ EXPLAIN
"key_length": "4",
"used_key_parts": ["l_shipDATE"],
"rows": 509,
- "filtered": 100,
+ "filtered": 11.69025803,
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
"attached_condition": "lineitem.l_quantity > 45"
}
@@ -238,7 +238,7 @@ set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_orderkey,
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 510.00 100.00 11.76 Using index condition; Using where
+1 SIMPLE lineitem range i_l_shipdate,i_l_quantity i_l_shipdate 4 NULL 509 510.00 11.69 11.76 Using index condition; Using where
set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_orderkey, l_linenumber, l_shipdate, l_quantity FROM lineitem
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45;
@@ -260,7 +260,7 @@ ANALYZE
"r_rows": 510,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 100,
+ "filtered": 11.69025803,
"r_filtered": 11.76470588,
"index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
"attached_condition": "lineitem.l_quantity > 45"
@@ -337,7 +337,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
o_totalprice between 200000 and 230000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 Using index condition
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (2%) Using where; Using rowid filter
+1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (2%) Using where; Using rowid filter
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
@@ -366,7 +366,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -379,7 +379,7 @@ EXPLAIN
"selectivity_pct": 1.631973356
},
"rows": 4,
- "filtered": 1.631973386,
+ "filtered": 0.026655342,
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'"
}
}
@@ -390,7 +390,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
o_totalprice between 200000 and 230000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 71.00 100.00 100.00 Using index condition
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (2%) 0.15 (2%) 1.63 100.00 Using where; Using rowid filter
+1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (2%) 0.15 (2%) 0.03 100.00 Using where; Using rowid filter
set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-01-31' AND
@@ -426,7 +426,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -447,7 +447,7 @@ ANALYZE
"r_rows": 0.154929577,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 1.631973386,
+ "filtered": 0.026655342,
"r_filtered": 100,
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-01-31'"
}
@@ -593,8 +593,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45 AND
o_totalprice between 180000 and 230000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 Using index condition
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter
+1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -605,19 +605,8 @@ EXPLAIN
"query_block": {
"select_id": 1,
"table": {
- "table_name": "orders",
- "access_type": "range",
- "possible_keys": ["PRIMARY", "i_o_totalprice"],
- "key": "i_o_totalprice",
- "key_length": "9",
- "used_key_parts": ["o_totalprice"],
- "rows": 139,
- "filtered": 100,
- "index_condition": "orders.o_totalprice between 180000 and 230000"
- },
- "table": {
"table_name": "lineitem",
- "access_type": "ref",
+ "access_type": "range",
"possible_keys": [
"PRIMARY",
"i_l_shipdate",
@@ -625,21 +614,33 @@ EXPLAIN
"i_l_orderkey_quantity",
"i_l_quantity"
],
- "key": "i_l_orderkey",
+ "key": "i_l_shipdate",
"key_length": "4",
- "used_key_parts": ["l_orderkey"],
- "ref": ["dbt3_s001.orders.o_orderkey"],
+ "used_key_parts": ["l_shipDATE"],
"rowid_filter": {
"range": {
- "key": "i_l_shipdate",
- "used_key_parts": ["l_shipDATE"]
+ "key": "i_l_quantity",
+ "used_key_parts": ["l_quantity"]
},
- "rows": 509,
- "selectivity_pct": 8.476269775
+ "rows": 702,
+ "selectivity_pct": 11.69025812
},
- "rows": 4,
- "filtered": 0.990897834,
- "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
+ "rows": 509,
+ "filtered": 11.69025803,
+ "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
+ "attached_condition": "lineitem.l_quantity > 45"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 9.266666412,
+ "attached_condition": "orders.o_totalprice between 180000 and 230000"
}
}
}
@@ -649,8 +650,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45 AND
o_totalprice between 180000 and 230000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 144.00 100.00 100.00 Using index condition
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.54 (8%) 0.99 20.51 Using where; Using rowid filter
+1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) 60.00 (11%) 11.69 100.00 Using index condition; Using where; Using rowid filter
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.27 26.67 Using where
set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -663,24 +664,8 @@ ANALYZE
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
- "table_name": "orders",
- "access_type": "range",
- "possible_keys": ["PRIMARY", "i_o_totalprice"],
- "key": "i_o_totalprice",
- "key_length": "9",
- "used_key_parts": ["o_totalprice"],
- "r_loops": 1,
- "rows": 139,
- "r_rows": 144,
- "r_table_time_ms": "REPLACED",
- "r_other_time_ms": "REPLACED",
- "filtered": 100,
- "r_filtered": 100,
- "index_condition": "orders.o_totalprice between 180000 and 230000"
- },
- "table": {
"table_name": "lineitem",
- "access_type": "ref",
+ "access_type": "range",
"possible_keys": [
"PRIMARY",
"i_l_shipdate",
@@ -688,30 +673,47 @@ ANALYZE
"i_l_orderkey_quantity",
"i_l_quantity"
],
- "key": "i_l_orderkey",
+ "key": "i_l_shipdate",
"key_length": "4",
- "used_key_parts": ["l_orderkey"],
- "ref": ["dbt3_s001.orders.o_orderkey"],
+ "used_key_parts": ["l_shipDATE"],
"rowid_filter": {
"range": {
- "key": "i_l_shipdate",
- "used_key_parts": ["l_shipDATE"]
+ "key": "i_l_quantity",
+ "used_key_parts": ["l_quantity"]
},
- "rows": 509,
- "selectivity_pct": 8.476269775,
- "r_rows": 510,
- "r_selectivity_pct": 8.176100629,
+ "rows": 702,
+ "selectivity_pct": 11.69025812,
+ "r_rows": 605,
+ "r_selectivity_pct": 11.76470588,
"r_buffer_size": "REPLACED",
"r_filling_time_ms": "REPLACED"
},
- "r_loops": 144,
- "rows": 4,
- "r_rows": 0.541666667,
+ "r_loops": 1,
+ "rows": 509,
+ "r_rows": 60,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 0.990897834,
- "r_filtered": 20.51282051,
- "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
+ "filtered": 11.69025803,
+ "r_filtered": 100,
+ "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
+ "attached_condition": "lineitem.l_quantity > 45"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "r_loops": 60,
+ "rows": 1,
+ "r_rows": 1,
+ "r_table_time_ms": "REPLACED",
+ "r_other_time_ms": "REPLACED",
+ "filtered": 9.266666412,
+ "r_filtered": 26.66666667,
+ "attached_condition": "orders.o_totalprice between 180000 and 230000"
}
}
}
@@ -743,8 +745,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45 AND
o_totalprice between 180000 and 230000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 Using index condition
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -755,19 +757,8 @@ EXPLAIN
"query_block": {
"select_id": 1,
"table": {
- "table_name": "orders",
- "access_type": "range",
- "possible_keys": ["PRIMARY", "i_o_totalprice"],
- "key": "i_o_totalprice",
- "key_length": "9",
- "used_key_parts": ["o_totalprice"],
- "rows": 139,
- "filtered": 100,
- "index_condition": "orders.o_totalprice between 180000 and 230000"
- },
- "table": {
"table_name": "lineitem",
- "access_type": "ref",
+ "access_type": "range",
"possible_keys": [
"PRIMARY",
"i_l_shipdate",
@@ -775,13 +766,25 @@ EXPLAIN
"i_l_orderkey_quantity",
"i_l_quantity"
],
- "key": "i_l_orderkey",
+ "key": "i_l_shipdate",
"key_length": "4",
- "used_key_parts": ["l_orderkey"],
- "ref": ["dbt3_s001.orders.o_orderkey"],
- "rows": 4,
- "filtered": 0.990897834,
- "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
+ "used_key_parts": ["l_shipDATE"],
+ "rows": 509,
+ "filtered": 11.69025803,
+ "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
+ "attached_condition": "lineitem.l_quantity > 45"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 9.266666412,
+ "attached_condition": "orders.o_totalprice between 180000 and 230000"
}
}
}
@@ -791,8 +794,8 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
l_quantity > 45 AND
o_totalprice between 180000 and 230000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 139 144.00 100.00 100.00 Using index condition
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.62 0.99 1.68 Using where
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate 4 NULL 509 510.00 11.69 11.76 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 9.27 26.67 Using where
set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, l_quantity, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -805,24 +808,8 @@ ANALYZE
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
- "table_name": "orders",
- "access_type": "range",
- "possible_keys": ["PRIMARY", "i_o_totalprice"],
- "key": "i_o_totalprice",
- "key_length": "9",
- "used_key_parts": ["o_totalprice"],
- "r_loops": 1,
- "rows": 139,
- "r_rows": 144,
- "r_table_time_ms": "REPLACED",
- "r_other_time_ms": "REPLACED",
- "filtered": 100,
- "r_filtered": 100,
- "index_condition": "orders.o_totalprice between 180000 and 230000"
- },
- "table": {
"table_name": "lineitem",
- "access_type": "ref",
+ "access_type": "range",
"possible_keys": [
"PRIMARY",
"i_l_shipdate",
@@ -830,18 +817,35 @@ ANALYZE
"i_l_orderkey_quantity",
"i_l_quantity"
],
- "key": "i_l_orderkey",
+ "key": "i_l_shipdate",
"key_length": "4",
- "used_key_parts": ["l_orderkey"],
- "ref": ["dbt3_s001.orders.o_orderkey"],
- "r_loops": 144,
- "rows": 4,
- "r_rows": 6.625,
+ "used_key_parts": ["l_shipDATE"],
+ "r_loops": 1,
+ "rows": 509,
+ "r_rows": 510,
+ "r_table_time_ms": "REPLACED",
+ "r_other_time_ms": "REPLACED",
+ "filtered": 11.69025803,
+ "r_filtered": 11.76470588,
+ "index_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'",
+ "attached_condition": "lineitem.l_quantity > 45"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "r_loops": 60,
+ "rows": 1,
+ "r_rows": 1,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 0.990897834,
- "r_filtered": 1.677148847,
- "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
+ "filtered": 9.266666412,
+ "r_filtered": 26.66666667,
+ "attached_condition": "orders.o_totalprice between 180000 and 230000"
}
}
}
@@ -874,14 +878,14 @@ l_quantity > 45 AND
o_totalprice between 180000 and 230000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE lineitem range|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity i_l_shipdate|i_l_quantity 4|9 NULL 509 (12%) Using index condition; Using where; Using rowid filter
-1 SIMPLE orders eq_ref|filter PRIMARY,i_o_totalprice PRIMARY|i_o_totalprice 4|9 dbt3_s001.lineitem.l_orderkey 1 (9%) Using where; Using rowid filter
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 Using index condition
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter
+1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) Using where; Using rowid filter
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -910,7 +914,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -923,7 +927,7 @@ EXPLAIN
"selectivity_pct": 8.476269775
},
"rows": 4,
- "filtered": 8.476269722,
+ "filtered": 0.719064236,
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
}
}
@@ -934,7 +938,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 71.00 100.00 100.00 Using index condition
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.52 (7%) 8.48 100.00 Using where; Using rowid filter
+1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (8%) 0.52 (7%) 0.72 100.00 Using where; Using rowid filter
set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -970,7 +974,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -991,7 +995,7 @@ ANALYZE
"r_rows": 0.521126761,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 8.476269722,
+ "filtered": 0.719064236,
"r_filtered": 100,
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
}
@@ -1045,7 +1049,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 Using index condition
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -1074,12 +1078,12 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
"rows": 4,
- "filtered": 8.476269722,
+ "filtered": 8.483263016,
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
}
}
@@ -1090,7 +1094,7 @@ WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
o_totalprice between 200000 and 230000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice i_o_totalprice 9 NULL 69 71.00 100.00 100.00 Using index condition
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.70 8.48 7.77 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.70 8.48 7.77 Using where
set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_orderkey, l_linenumber, l_shipdate, o_totalprice
FROM orders JOIN lineitem ON o_orderkey=l_orderkey
WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND
@@ -1126,7 +1130,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1135,7 +1139,7 @@ ANALYZE
"r_rows": 6.704225352,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 8.476269722,
+ "filtered": 8.483263016,
"r_filtered": 7.773109244,
"attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30'"
}
@@ -1223,7 +1227,7 @@ EXPLAIN
"key_length": "4",
"used_key_parts": ["l_receiptDATE"],
"rows": 18,
- "filtered": 100,
+ "filtered": 0.566194832,
"index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
},
@@ -1248,7 +1252,7 @@ l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
o_totalprice BETWEEN 200000 AND 250000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 100.00 38.89 Using index condition; Using where
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where
1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 7.47 14.29 Using where
set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
FROM orders, lineitem
@@ -1280,7 +1284,7 @@ ANALYZE
"r_rows": 18,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 100,
+ "filtered": 0.566194832,
"r_filtered": 38.88888889,
"index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
@@ -1345,7 +1349,7 @@ EXPLAIN
"key_length": "4",
"used_key_parts": ["l_receiptDATE"],
"rows": 18,
- "filtered": 100,
+ "filtered": 0.566194832,
"index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
},
@@ -1370,7 +1374,7 @@ l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
o_totalprice BETWEEN 200000 AND 250000;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 100.00 38.89 Using index condition; Using where
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where
1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 7.47 14.29 Using where
set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
FROM orders, lineitem
@@ -1402,7 +1406,7 @@ ANALYZE
"r_rows": 18,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 100,
+ "filtered": 0.566194832,
"r_filtered": 38.88888889,
"index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
@@ -1449,7 +1453,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM orders, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1468,7 +1472,7 @@ EXPLAIN
"key_length": "9",
"used_key_parts": ["o_totaldiscount"],
"rows": 39,
- "filtered": 100,
+ "filtered": 3.200000048,
"index_condition": "orders.o_totaldiscount between 18000 and 20000",
"attached_condition": "orders.o_totalprice between 200000 and 220000"
},
@@ -1481,20 +1485,12 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
- "rowid_filter": {
- "range": {
- "key": "i_l_shipdate",
- "used_key_parts": ["l_shipDATE"]
- },
- "rows": 183,
- "selectivity_pct": 3.04746045
- },
"rows": 4,
- "filtered": 3.047460556,
+ "filtered": 3.04997468,
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
}
}
@@ -1506,8 +1502,8 @@ o_totaldiscount BETWEEN 18000 AND 20000 AND
o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 100.00 2.44 Using index condition; Using where
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) 3.05 100.00 Using where; Using rowid filter
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM orders, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1532,7 +1528,7 @@ ANALYZE
"r_rows": 41,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 100,
+ "filtered": 3.200000048,
"r_filtered": 2.43902439,
"index_condition": "orders.o_totaldiscount between 18000 and 20000",
"attached_condition": "orders.o_totalprice between 200000 and 220000"
@@ -1546,29 +1542,17 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
- "rowid_filter": {
- "range": {
- "key": "i_l_shipdate",
- "used_key_parts": ["l_shipDATE"]
- },
- "rows": 183,
- "selectivity_pct": 3.04746045,
- "r_rows": 183,
- "r_selectivity_pct": 66.66666667,
- "r_buffer_size": "REPLACED",
- "r_filling_time_ms": "REPLACED"
- },
"r_loops": 1,
"rows": 4,
- "r_rows": 4,
+ "r_rows": 6,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 3.047460556,
- "r_filtered": 100,
+ "filtered": 3.04997468,
+ "r_filtered": 66.66666667,
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
}
}
@@ -1592,7 +1576,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM orders, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1611,7 +1595,7 @@ EXPLAIN
"key_length": "9",
"used_key_parts": ["o_totaldiscount"],
"rows": 39,
- "filtered": 100,
+ "filtered": 3.200000048,
"index_condition": "orders.o_totaldiscount between 18000 and 20000",
"attached_condition": "orders.o_totalprice between 200000 and 220000"
},
@@ -1624,12 +1608,12 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
"rows": 4,
- "filtered": 3.047460556,
+ "filtered": 3.04997468,
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
}
}
@@ -1641,8 +1625,8 @@ o_totaldiscount BETWEEN 18000 AND 20000 AND
o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 100.00 2.44 Using index condition; Using where
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.20 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM orders, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1667,7 +1651,7 @@ ANALYZE
"r_rows": 41,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 100,
+ "filtered": 3.200000048,
"r_filtered": 2.43902439,
"index_condition": "orders.o_totaldiscount between 18000 and 20000",
"attached_condition": "orders.o_totalprice between 200000 and 220000"
@@ -1681,7 +1665,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1690,7 +1674,7 @@ ANALYZE
"r_rows": 6,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
- "filtered": 3.047460556,
+ "filtered": 3.04997468,
"r_filtered": 66.66666667,
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
}
@@ -1718,7 +1702,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) Using where; Using rowid filter
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM v1, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1755,18 +1739,10 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
- "rowid_filter": {
- "range": {
- "key": "i_l_shipdate",
- "used_key_parts": ["l_shipDATE"]
- },
- "rows": 183,
- "selectivity_pct": 3.04746045
- },
"rows": 4,
"filtered": "REPLACED",
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
@@ -1781,7 +1757,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 # 2.44 Using index condition; Using where
-1 SIMPLE lineitem ref|filter PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey|i_l_shipdate 4|4 dbt3_s001.orders.o_orderkey 4 (3%) 4.00 (66%) # 100.00 Using where; Using rowid filter
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where
set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM v1, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1825,29 +1801,17 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
- "rowid_filter": {
- "range": {
- "key": "i_l_shipdate",
- "used_key_parts": ["l_shipDATE"]
- },
- "rows": 183,
- "selectivity_pct": 3.04746045,
- "r_rows": 183,
- "r_selectivity_pct": 66.66666667,
- "r_buffer_size": "REPLACED",
- "r_filling_time_ms": "REPLACED"
- },
"r_loops": 1,
"rows": 4,
- "r_rows": 4,
+ "r_rows": 6,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": "REPLACED",
- "r_filtered": 100,
+ "r_filtered": 66.66666667,
"attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
}
}
@@ -1871,7 +1835,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM v1, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1908,7 +1872,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1926,7 +1890,7 @@ o_totalprice BETWEEN 200000 AND 220000 AND
l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 # 2.44 Using index condition; Using where
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 # 66.67 Using where
set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
FROM v1, lineitem
WHERE o_orderkey=l_orderkey AND
@@ -1970,7 +1934,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "i_l_orderkey",
+ "key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -2069,7 +2033,7 @@ EXPLAIN EXTENDED
SELECT * FROM t1 HAVING (7, 9) IN (SELECT t2.i1, t2.i2 FROM t2 WHERE t2.i1 = 3);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
-2 SUBQUERY t2 ref i1,i2 i1 5 const 1 100.00 Using index condition; Using where
+2 SUBQUERY t2 ref i1,i2 i1 5 const 1 10.00 Using index condition; Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` having 0
DROP TABLE t1,t2;
@@ -2107,7 +2071,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN t2 ON ( pk1 <> pk2 AND pk1 = a2 )
WHERE b1 <= ( SELECT MAX(b2) FROM t2 WHERE pk2 <= 1 );
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 101 100.00 Using where
-1 PRIMARY t1 eq_ref|filter PRIMARY,b1 PRIMARY|b1 4|4 test.t2.a2 1 (87%) 87.00 Using where; Using rowid filter
+1 PRIMARY t1 eq_ref PRIMARY,b1 PRIMARY 4 test.t2.a2 1 87.00 Using where
2 SUBQUERY t2 range PRIMARY PRIMARY 4 NULL 1 100.00 Using index condition
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,`test`.`t2`.`pk2` AS `pk2`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b2` AS `b2` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`pk1` = `test`.`t2`.`a2` and `test`.`t1`.`b1` <= (/* select#2 */ select max(`test`.`t2`.`b2`) from `test`.`t2` where `test`.`t2`.`pk2` <= 1) and `test`.`t2`.`a2` <> `test`.`t2`.`pk2`
@@ -2132,14 +2096,6 @@ EXPLAIN
"key_length": "4",
"used_key_parts": ["pk1"],
"ref": ["test.t2.a2"],
- "rowid_filter": {
- "range": {
- "key": "b1",
- "used_key_parts": ["b1"]
- },
- "rows": 87,
- "selectivity_pct": 87
- },
"rows": 1,
"filtered": 87,
"attached_condition": "t1.b1 <= (subquery#2)"
@@ -2208,14 +2164,16 @@ drop table t10, t11, t1;
set @save_optimizer_switch= @@optimizer_switch;
SET @@optimizer_switch="index_merge_sort_union=OFF";
CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b));
-INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4);
+INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0);
explain
SELECT * FROM t1 WHERE a > 0 AND b=0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a,b a 5 NULL 1 Using index condition; Using where
+1 SIMPLE t1 ref|filter a,b b|a 5|5 const 7 (47%) Using where; Using rowid filter
SELECT * FROM t1 WHERE a > 0 AND b=0;
a b
1 0
+1 0
+2 0
drop table t1;
SET @@optimizer_switch=@save_optimizer_switch;
set @@use_stat_tables=@save_use_stat_tables;
@@ -2255,8 +2213,8 @@ pk a b c
7 5 k 5
explain SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where
-1 SIMPLE t1 ref|filter PRIMARY,a,a_2 a|PRIMARY 5|4 test.t2.c 3 (4%) Using where; Using rowid filter
+1 SIMPLE t1 range PRIMARY,a,a_2 PRIMARY 4 NULL 4 Using index condition; Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
SET optimizer_switch='rowid_filter=off';
SELECT * FROM t1 JOIN t2 WHERE a = c AND pk BETWEEN 4 AND 7 AND a BETWEEN 2 AND 12 AND b != 'foo';
pk a b c
diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test
index e4cb1f88039..70770237ee1 100644
--- a/mysql-test/main/rowid_filter.test
+++ b/mysql-test/main/rowid_filter.test
@@ -405,7 +405,7 @@ drop table t10, t11, t1;
set @save_optimizer_switch= @@optimizer_switch;
SET @@optimizer_switch="index_merge_sort_union=OFF";
CREATE TABLE t1 (a INT, b INT, INDEX(a), INDEX(b));
-INSERT INTO t1 VALUES (0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4);
+INSERT INTO t1 VALUES (0,0),(0,0),(1,0),(-1,1), (-2,1), (-2,3), (-3,4), (-2,4),(3,3),(3,4),(3,5),(8,8),(8,9),(1,0),(2,0),(0,0),(0,0);
explain
SELECT * FROM t1 WHERE a > 0 AND b=0;
SELECT * FROM t1 WHERE a > 0 AND b=0;
diff --git a/mysql-test/main/show_explain.result b/mysql-test/main/show_explain.result
index 8fd4c828bdc..1ec5a092516 100644
--- a/mysql-test/main/show_explain.result
+++ b/mysql-test/main/show_explain.result
@@ -28,7 +28,7 @@ select count(*) from t1 where a < 100000;
connection default;
show explain for $thr2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 1000 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 999 Using where; Using index
Warnings:
Note 1003 select count(*) from t1 where a < 100000
connection con1;
diff --git a/mysql-test/main/ssl.result b/mysql-test/main/ssl.result
index 794830e5529..2694d177056 100644
--- a/mysql-test/main/ssl.result
+++ b/mysql-test/main/ssl.result
@@ -9,6 +9,7 @@ SHOW STATUS LIKE 'Ssl_server_not_after';
Variable_name Value
Ssl_server_not_after Feb 27 03:03:03 2040 GMT
drop table if exists t1,t2,t3,t4;
+set @@default_storage_engine="aria";
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -609,6 +610,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
+#
+# Some test with ORDER BY and limit
+#
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
@@ -1298,7 +1302,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
PRIMARY KEY (companynr),
UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
+) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
companynr companyname
00 Unknown
@@ -1388,6 +1392,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
+#
+# Test left join optimization
+#
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
@@ -1402,15 +1409,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1426,11 +1433,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/main/ssl_compress.result b/mysql-test/main/ssl_compress.result
index 69de425cdc1..beb21ce8b16 100644
--- a/mysql-test/main/ssl_compress.result
+++ b/mysql-test/main/ssl_compress.result
@@ -6,6 +6,7 @@ SHOW STATUS LIKE 'Compression';
Variable_name Value
Compression ON
drop table if exists t1,t2,t3,t4;
+set @@default_storage_engine="aria";
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
@@ -606,6 +607,9 @@ explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
+#
+# Some test with ORDER BY and limit
+#
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
@@ -1295,7 +1299,7 @@ companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
PRIMARY KEY (companynr),
UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
+) ENGINE=aria MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
companynr companyname
00 Unknown
@@ -1385,6 +1389,9 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
+#
+# Test left join optimization
+#
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
@@ -1399,15 +1406,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
@@ -1423,11 +1430,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
+1 SIMPLE t4 range PRIMARY PRIMARY 1 NULL 12 Using index condition
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/main/status.result b/mysql-test/main/status.result
index b34713a4c73..75684dc272c 100644
--- a/mysql-test/main/status.result
+++ b/mysql-test/main/status.result
@@ -71,16 +71,16 @@ a
6
show status like 'last_query_cost';
Variable_name Value
-Last_query_cost 13.542725
+Last_query_cost 0.017820
show status like 'last_query_cost';
Variable_name Value
-Last_query_cost 13.542725
+Last_query_cost 0.017820
select 1;
1
1
show status like 'last_query_cost';
Variable_name Value
-Last_query_cost 0.000000
+Last_query_cost 0.010085
drop table t1;
FLUSH STATUS;
SHOW STATUS LIKE 'max_used_connections';
@@ -134,20 +134,20 @@ a
1
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 1.501709
+Last_query_cost 0.010313
EXPLAIN SELECT a FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 1.501709
+Last_query_cost 0.010313
SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
a
1
2
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 0.000000
+Last_query_cost 0.010313
EXPLAIN SELECT a FROM t1 UNION SELECT a FROM t1 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
@@ -155,25 +155,25 @@ id select_type table type possible_keys key key_len ref rows Extra
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL Using filesort
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 0.000000
+Last_query_cost 0.010313
SELECT a IN (SELECT a FROM t1) FROM t1 LIMIT 1;
a IN (SELECT a FROM t1)
1
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 0.000000
+Last_query_cost 0.010313
SELECT (SELECT a FROM t1 LIMIT 1) x FROM t1 LIMIT 1;
x
1
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 0.000000
+Last_query_cost 0.010313
SELECT * FROM t1 a, t1 b LIMIT 1;
a a
1 1
SHOW SESSION STATUS LIKE 'Last_query_cost';
Variable_name Value
-Last_query_cost 3.953418
+Last_query_cost 0.021119
DROP TABLE t1;
connect con1,localhost,root,,;
show status like 'com_show_status';
diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result
index dcd1174caf9..f92a3181019 100644
--- a/mysql-test/main/subselect.result
+++ b/mysql-test/main/subselect.result
@@ -345,7 +345,7 @@ patient_uq clinic_uq
explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t7 index PRIMARY PRIMARY 4 NULL 2 100.00 Using index
-1 PRIMARY t6 ALL i1 NULL NULL NULL 4 75.00 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t6 ref i1 i1 5 test.t7.uq 2 100.00
Warnings:
Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t7` join `test`.`t6` where `test`.`t6`.`clinic_uq` = `test`.`t7`.`uq`
@@ -1429,6 +1429,9 @@ drop table if exists t1;
(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
a
1
+#
+# IN subselect optimization test
+#
create table t1 (a int not null, b int, primary key (a));
create table t2 (a int not null, primary key (a));
create table t3 (a int not null, b int, primary key (a));
@@ -1486,7 +1489,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a`
select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
@@ -1496,7 +1499,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
@@ -1506,8 +1509,8 @@ a
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t3 index a a 5 NULL 3 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 100.00 Using index; FirstMatch(t2)
+1 PRIMARY t3 range a a 5 NULL 3 100.00 Using where; Using index
+1 PRIMARY t1 ref a a 10 test.t2.a,test.t3.a 116 0.29 Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1` join `test`.`t3`) where `test`.`t1`.`b` = `test`.`t3`.`a` and `test`.`t1`.`a` = `test`.`t2`.`a`
insert into t1 values (3,31);
@@ -1523,7 +1526,7 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index a a 5 NULL 4 100.00 Using where; Using index
-1 PRIMARY t1 ref a a 5 test.t2.a 101 100.00 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t1 ref a a 5 test.t2.a 101 0.99 Using where; Using index; FirstMatch(t2)
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` <> 30
drop table t0, t1, t2, t3;
@@ -1587,6 +1590,9 @@ Note 1003 (select 'tttt' AS `s1` from dual)
s1
tttt
drop table t1;
+#
+# IN optimisation test results
+#
create table t1 (s1 char(5), index s1(s1));
create table t2 (s1 char(5), index s1(s1));
insert into t1 values ('a1'),('a2'),('a3');
@@ -1614,21 +1620,21 @@ a3 1
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
@@ -2420,22 +2426,23 @@ a
1
3
DROP TABLE t1;
+#
+# SELECT(EXISTS * ...)optimisation
+#
create table t1 (a int, b int);
insert into t1 values (1,2),(3,4),(5,6),(7,8);
-select * from t1 up where exists (select * from t1 where t1.a=up.a);
-a b
-1 2
-3 4
-5 6
-7 8
-explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
+insert into t1 select seq,seq from seq_20_to_40;
+select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a);
+sum(a+b)
+1296
+explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00
+1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
-2 MATERIALIZED t1 ALL NULL NULL NULL NULL 4 100.00
+2 MATERIALIZED t1 ALL NULL NULL NULL NULL 25 100.00
Warnings:
Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` semi join (`test`.`t1`) where 1
+Note 1003 select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` semi join (`test`.`t1`) where 1
drop table t1;
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
@@ -3103,6 +3110,10 @@ retailerID statusID changed
0048 1 2006-01-06 12:37:50
0059 1 2006-01-06 12:37:50
drop table t1;
+#
+# Bug#21180 Subselect with index for both WHERE and ORDER BY
+# produces empty result
+#
create table t1(a int, primary key (a));
insert into t1 values (10);
create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b));
@@ -3118,7 +3129,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
-2 SUBQUERY t2 ref cb cb 5 const 1 Using where
+2 SUBQUERY t2 range cb cb 40 NULL 3 Using where
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@@ -3130,7 +3141,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
-2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where
+2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
@@ -4230,8 +4241,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3);
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
id st
-3 FL
1 GA
+3 FL
7 FL
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
@@ -4332,6 +4343,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1;
0
0
DROP TABLE t1, t2;
+#
+# Bug#28076 inconsistent binary/varbinary comparison
+#
CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5));
INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43);
SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1);
@@ -4393,8 +4407,8 @@ CREATE INDEX I1 ON t1 (a);
CREATE INDEX I2 ON t1 (b);
EXPLAIN SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where
-1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1)
+1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan
+1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1);
a b
CREATE TABLE t2 (a VARCHAR(1), b VARCHAR(10));
@@ -4403,15 +4417,15 @@ CREATE INDEX I1 ON t2 (a);
CREATE INDEX I2 ON t2 (b);
EXPLAIN SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL I2 NULL NULL NULL 2 Using where
-1 PRIMARY t2 ref I1 I1 4 test.t2.b 2 Using where; Using index; FirstMatch(t2)
+1 PRIMARY t2 index I1 I1 4 NULL 2 Using where; Using index; LooseScan
+1 PRIMARY t2 ref I2 I2 13 test.t2.a 2 Using index condition
SELECT a,b FROM t2 WHERE b IN (SELECT a FROM t2);
a b
EXPLAIN
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL I2 NULL NULL NULL 2 Using where
-1 PRIMARY t1 ref I1 I1 2 test.t1.b 2 Using where; Using index; FirstMatch(t1)
+1 PRIMARY t1 index I1 I1 2 NULL 2 Using where; Using index; LooseScan
+1 PRIMARY t1 ref I2 I2 13 test.t1.a 2 Using index condition
SELECT a,b FROM t1 WHERE b IN (SELECT a FROM t1 WHERE LENGTH(a)<500);
a b
DROP TABLE t1,t2;
@@ -4456,11 +4470,10 @@ EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 100.00
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
-2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 select 2 AS `2` from `test`.`t1` semi join (`test`.`t2`) where 1
+Note 1003 select 2 AS `2` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`a`
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
@@ -5707,6 +5720,7 @@ CREATE TABLE t1 (a int) ;
INSERT INTO t1 VALUES (NULL), (1), (NULL), (2);
CREATE TABLE t2 (a int, INDEX idx(a)) ;
INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000);
+insert into t2 select seq from seq_3_to_100;
SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a);
a
@@ -5717,7 +5731,7 @@ WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
-2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 102
SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
a
@@ -5727,7 +5741,7 @@ SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
-1 PRIMARY t2 ref idx idx 5 test.t1.a 2 Using index; FirstMatch(t1)
+1 PRIMARY t2 ref idx idx 5 test.t1.a 11 Using index; FirstMatch(t1)
DROP TABLE t1,t2;
#
# BUG#752992: Wrong results for a subquery with 'semijoin=on'
diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test
index e84b928f891..934447bd005 100644
--- a/mysql-test/main/subselect.test
+++ b/mysql-test/main/subselect.test
@@ -885,9 +885,9 @@ drop table if exists t1;
(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
-#
-# IN subselect optimization test
-#
+--echo #
+--echo # IN subselect optimization test
+--echo #
create table t1 (a int not null, b int, primary key (a));
create table t2 (a int not null, primary key (a));
create table t3 (a int not null, b int, primary key (a));
@@ -993,9 +993,9 @@ explain extended (select * from t1);
(select * from t1);
drop table t1;
-#
-# IN optimisation test results
-#
+--echo #
+--echo # IN optimisation test results
+--echo #
create table t1 (s1 char(5), index s1(s1));
create table t2 (s1 char(5), index s1(s1));
insert into t1 values ('a1'),('a2'),('a3');
@@ -1421,13 +1421,14 @@ SELECT a FROM t1 WHERE a <> ALL (SELECT a FROM t1 WHERE b = '2');
DROP TABLE t1;
-#
-# SELECT(EXISTS * ...)optimisation
-#
+--echo #
+--echo # SELECT(EXISTS * ...)optimisation
+--echo #
create table t1 (a int, b int);
insert into t1 values (1,2),(3,4),(5,6),(7,8);
-select * from t1 up where exists (select * from t1 where t1.a=up.a);
-explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
+insert into t1 select seq,seq from seq_20_to_40;
+select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a);
+explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a);
drop table t1;
@@ -2028,10 +2029,10 @@ select * from t1 r1
drop table t1;
-#
-# Bug#21180 Subselect with index for both WHERE and ORDER BY
-# produces empty result
-#
+--echo #
+--echo # Bug#21180 Subselect with index for both WHERE and ORDER BY
+--echo # produces empty result
+--echo #
create table t1(a int, primary key (a));
insert into t1 values (10);
@@ -3051,6 +3052,7 @@ INSERT INTO t1 VALUES
CREATE TABLE t2 (id int NOT NULL, INDEX idx(id));
INSERT INTO t2 VALUES (7), (5), (1), (3);
+--sorted_result
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
SELECT id, st FROM t1
@@ -3217,9 +3219,9 @@ DROP TABLE t1, t2;
#--enable_query_log
#drop table t1;
-#
-# Bug#28076 inconsistent binary/varbinary comparison
-#
+--echo #
+--echo # Bug#28076 inconsistent binary/varbinary comparison
+--echo #
CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5));
INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43);
@@ -4795,6 +4797,7 @@ INSERT INTO t1 VALUES (NULL), (1), (NULL), (2);
CREATE TABLE t2 (a int, INDEX idx(a)) ;
INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000);
+insert into t2 select seq from seq_3_to_100;
SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a);
diff --git a/mysql-test/main/subselect_mat_cost.result b/mysql-test/main/subselect_mat_cost.result
index 9de70573189..1b6bdf9b4a5 100644
--- a/mysql-test/main/subselect_mat_cost.result
+++ b/mysql-test/main/subselect_mat_cost.result
@@ -59,15 +59,15 @@ set @@optimizer_switch = 'in_to_exists=on,semijoin=on,materialization=on,partial
Q1.1m:
MATERIALIZATION: there are too many rows in the outer query
to be looked up in the inner table.
-set statement optimizer_cache_hit_ratio=20 for EXPLAIN
+EXPLAIN
SELECT count(*) FROM Country
WHERE (Code IN (select Country from City where City.Population > 100000) OR
Name LIKE 'L%') AND
surfacearea > 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY Country ALL Name,SurfaceArea NULL NULL NULL 239 Using where
-3 MATERIALIZED City ALL Population,Country NULL NULL NULL 4079 Using where
-set statement optimizer_cache_hit_ratio=20 for SELECT count(*) FROM Country
+2 MATERIALIZED City ALL Population,Country NULL NULL NULL 4079 Using where
+SELECT count(*) FROM Country
WHERE (Code IN (select Country from City where City.Population > 100000) OR
Name LIKE 'L%') AND
surfacearea > 100000;
@@ -105,13 +105,25 @@ Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND
(select Language from CountryLanguage where Percentage > 50) OR
City.name LIKE '%Island%');
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 47 Using index condition; Rowid-ordered scan
+1 PRIMARY Country ALL PRIMARY,SurfaceArea NULL NULL NULL 239 Using where
1 PRIMARY City ref Country Country 3 world.Country.Code 17 Using where
-2 MATERIALIZED CountryLanguage range Percentage,Language Percentage 4 NULL 197 Using index condition; Rowid-ordered scan
+2 MATERIALIZED CountryLanguage ALL Percentage,Language NULL NULL NULL 984 Using where
+EXPLAIN
SELECT *
FROM Country, City
WHERE City.Country = Country.Code AND
-Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND
+Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND
+(City.Name IN
+(select Language from CountryLanguage where Percentage > 50) OR
+City.name LIKE '%Island%');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 32 Using index condition; Rowid-ordered scan
+1 PRIMARY City ref Country Country 3 world.Country.Code 17 Using where
+2 MATERIALIZED CountryLanguage ALL Percentage,Language NULL NULL NULL 984 Using where
+SELECT *
+FROM Country, City
+WHERE City.Country = Country.Code AND
+Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND
(City.Name IN
(select Language from CountryLanguage where Percentage > 50) OR
City.name LIKE '%Island%');
@@ -130,7 +142,7 @@ Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND
(select Language from CountryLanguage where Percentage > 50) OR
Country.name LIKE '%Island%');
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 47 Using index condition; Using where; Rowid-ordered scan
+1 PRIMARY Country ALL PRIMARY,SurfaceArea NULL NULL NULL 239 Using where
1 PRIMARY City ref Country Country 3 world.Country.Code 17
2 DEPENDENT SUBQUERY CountryLanguage index_subquery Percentage,Language Language 30 func 2 Using where
SELECT *
@@ -175,7 +187,7 @@ OR
(Country.Code, City.Name) IN
(select Country, Language from CountryLanguage));
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY Country range PRIMARY,SurfaceArea SurfaceArea 4 NULL 73 Using index condition; Rowid-ordered scan
+1 PRIMARY Country ALL PRIMARY,SurfaceArea NULL NULL NULL 239 Using where
1 PRIMARY City ref Country Country 3 world.Country.Code 17 Using where
3 MATERIALIZED CountryLanguage index PRIMARY,Language PRIMARY 33 NULL 984 Using index
2 DEPENDENT SUBQUERY CountryLanguage unique_subquery PRIMARY,Percentage,Language PRIMARY 33 func,func 1 Using where
@@ -487,9 +499,30 @@ FROM City JOIN Country ON City.Country = Country.Code
GROUP BY City.Name
HAVING City.Name IN (select Name from Country where population < 1000000);
id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY City ALL Country NULL NULL NULL 4079 Using temporary; Using filesort
+1 PRIMARY Country eq_ref PRIMARY PRIMARY 3 world.City.Country 1 Using index
+2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where
+Last_query_cost 5.934809
+EXPLAIN
+SELECT straight_join City.Name, City.Population
+FROM Country JOIN City ON City.Country = Country.Code
+GROUP BY City.Name
+HAVING City.Name IN (select Name from Country where population < 1000000);
+id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY Country index PRIMARY PRIMARY 3 NULL 239 Using index; Using temporary; Using filesort
1 PRIMARY City ref Country Country 3 world.Country.Code 17
2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where
+Last_query_cost 7.951232
+EXPLAIN
+SELECT City.Name, City.Population
+FROM Country LEFT JOIN City ON City.Country = Country.Code
+GROUP BY City.Name
+HAVING City.Name IN (select Name from Country where population < 1000000);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY Country index NULL PRIMARY 3 NULL 239 Using index; Using temporary; Using filesort
+1 PRIMARY City ref Country Country 3 world.Country.Code 17
+2 MATERIALIZED Country ALL Name NULL NULL NULL 239 Using where
+Last_query_cost 7.951232
SELECT City.Name, City.Population
FROM City JOIN Country ON City.Country = Country.Code
GROUP BY City.Name
diff --git a/mysql-test/main/subselect_mat_cost.test b/mysql-test/main/subselect_mat_cost.test
index 6b7fa4fee64..60763076c45 100644
--- a/mysql-test/main/subselect_mat_cost.test
+++ b/mysql-test/main/subselect_mat_cost.test
@@ -73,13 +73,13 @@ set @@optimizer_switch = 'in_to_exists=on,semijoin=on,materialization=on,partial
-- echo Q1.1m:
-- echo MATERIALIZATION: there are too many rows in the outer query
-- echo to be looked up in the inner table.
-set statement optimizer_cache_hit_ratio=20 for EXPLAIN
+EXPLAIN
SELECT count(*) FROM Country
WHERE (Code IN (select Country from City where City.Population > 100000) OR
Name LIKE 'L%') AND
surfacearea > 100000;
-set statement optimizer_cache_hit_ratio=20 for SELECT count(*) FROM Country
+SELECT count(*) FROM Country
WHERE (Code IN (select Country from City where City.Population > 100000) OR
Name LIKE 'L%') AND
surfacearea > 100000;
@@ -113,10 +113,19 @@ SELECT *
(select Language from CountryLanguage where Percentage > 50) OR
City.name LIKE '%Island%');
+EXPLAIN
SELECT *
FROM Country, City
WHERE City.Country = Country.Code AND
- Country.SurfaceArea < 3000 AND Country.SurfaceArea > 10 AND
+ Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND
+ (City.Name IN
+ (select Language from CountryLanguage where Percentage > 50) OR
+ City.name LIKE '%Island%');
+
+SELECT *
+ FROM Country, City
+ WHERE City.Country = Country.Code AND
+ Country.SurfaceArea < 500 AND Country.SurfaceArea > 10 AND
(City.Name IN
(select Language from CountryLanguage where Percentage > 50) OR
City.name LIKE '%Island%');
@@ -374,12 +383,26 @@ SELECT City.Name, City.Population
FROM City JOIN Country ON City.Country = Country.Code
GROUP BY City.Name
HAVING City.Name IN (select Name from Country where population < 1000000);
+--source include/last_query_cost.inc
+EXPLAIN
+SELECT straight_join City.Name, City.Population
+FROM Country JOIN City ON City.Country = Country.Code
+GROUP BY City.Name
+HAVING City.Name IN (select Name from Country where population < 1000000);
+--source include/last_query_cost.inc
+
+EXPLAIN
SELECT City.Name, City.Population
-FROM City JOIN Country ON City.Country = Country.Code
+FROM Country LEFT JOIN City ON City.Country = Country.Code
GROUP BY City.Name
HAVING City.Name IN (select Name from Country where population < 1000000);
+--source include/last_query_cost.inc
+SELECT City.Name, City.Population
+FROM City JOIN Country ON City.Country = Country.Code
+GROUP BY City.Name
+HAVING City.Name IN (select Name from Country where population < 1000000);
-- echo
-- echo 5. Subqueries with UNION
diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result
index a5a62a2b65d..83004c8445b 100644
--- a/mysql-test/main/subselect_no_semijoin.result
+++ b/mysql-test/main/subselect_no_semijoin.result
@@ -914,9 +914,9 @@ a t1.a in (select t2.a from t2)
explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
-2 MATERIALIZED t2 index a a 5 NULL 3 100.00 Using index
+2 SUBQUERY t2 index_subquery a a 5 func 2 100.00 Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`a`)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t2 on a checking NULL having `test`.`t2`.`a` is null)))) AS `t1.a in (select t2.a from t2)` from `test`.`t1`
CREATE TABLE t3 (a int(11) default '0');
INSERT INTO t3 VALUES (1),(2),(3);
SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
@@ -928,8 +928,8 @@ a t1.a in (select t2.a from t2,t3 where t3.a=t2.a)
explain extended SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
-2 MATERIALIZED t3 ALL NULL NULL NULL NULL 3 100.00
-2 MATERIALIZED t2 index a a 5 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 MATERIALIZED t3 ALL NULL NULL NULL NULL 3 100.00 Using where
+2 MATERIALIZED t2 ref a a 5 test.t3.a 2 100.00 Using index
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,<expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`a` from `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t3`.`a` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`a`)))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1`
drop table t1,t2,t3;
@@ -1432,6 +1432,9 @@ drop table if exists t1;
(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
a
1
+#
+# IN subselect optimization test
+#
create table t1 (a int not null, b int, primary key (a));
create table t2 (a int not null, primary key (a));
create table t3 (a int not null, b int, primary key (a));
@@ -1456,9 +1459,9 @@ a
explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
-2 MATERIALIZED t1 ALL PRIMARY NULL NULL NULL 4 100.00 Using where
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`b` <> 30 ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`a`))))
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY where `test`.`t1`.`b` <> 30 and <cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
a
2
@@ -1466,10 +1469,10 @@ a
explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 100.00 Using where; Using index
-2 MATERIALIZED t1 ALL PRIMARY NULL NULL NULL 4 100.00 Using where
-2 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
+2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where
+2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`a`))))
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and <cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))
drop table t1, t2, t3;
create table t1 (a int, b int, index a (a,b));
create table t2 (a int, index a (a));
@@ -1510,7 +1513,7 @@ explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 5 NULL 4 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 ref a a 5 func 1001 100.00 Using index
-2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 75.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 66.67 Using where; Using index; Using join buffer (flat, BNL join)
Warnings:
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`b` and <cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`)))
insert into t1 values (3,31);
@@ -1590,6 +1593,9 @@ Note 1003 (select 'tttt' AS `s1` from dual)
s1
tttt
drop table t1;
+#
+# IN optimisation test results
+#
create table t1 (s1 char(5), index s1(s1));
create table t2 (s1 char(5), index s1(s1));
insert into t1 values ('a1'),('a2'),('a3');
@@ -1617,27 +1623,27 @@ a3 1
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 = ANY (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 DEPENDENT SUBQUERY t2 index s1 s1 6 NULL 2 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 100.00 Using index; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where trigcond(<cache>(`test`.`t1`.`s1`) = `test`.`t2`.`s1` or `test`.`t2`.`s1` is null) having trigcond(`test`.`t2`.`s1` is null)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 <> ALL (SELECT s1 FROM t2)` from `test`.`t1`
explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index NULL s1 6 NULL 3 100.00 Using index
-2 MATERIALIZED t2 range s1 s1 6 NULL 1 100.00 Using where; Using index
+2 SUBQUERY t2 index_subquery s1 s1 6 func 2 50.00 Using index; Using where; Full scan on NULL key
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,`test`.`t1`.`s1` in ( <materialize> (/* select#2 */ select `test`.`t2`.`s1` from `test`.`t2` where `test`.`t2`.`s1` < 'a2' ), <primary_index_lookup>(`test`.`t1`.`s1` in <temporary table> on distinct_key where `test`.`t1`.`s1` = `<subquery2>`.`s1`)))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
+Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t1`.`s1`>(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where `test`.`t2`.`s1` < 'a2' having trigcond(`test`.`t2`.`s1` is null))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1`
drop table t1,t2;
create table t2 (a int, b int not null);
create table t3 (a int);
@@ -1890,9 +1896,9 @@ id text
explain extended select * from t1 where id not in (select id from t1 where id < 8);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 100.00 Using where
-2 MATERIALIZED t1 range PRIMARY PRIMARY 4 NULL 7 100.00 Using where; Using index
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index; Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,`test`.`t1`.`id` in ( <materialize> (/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 ), <primary_index_lookup>(`test`.`t1`.`id` in <temporary table> on distinct_key where `test`.`t1`.`id` = `<subquery2>`.`id`))))
+Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`text` AS `text` from `test`.`t1` where !<expr_cache><`test`.`t1`.`id`>(<in_optimizer>(`test`.`t1`.`id`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`id`) in t1 on PRIMARY where `test`.`t1`.`id` < 8 and <cache>(`test`.`t1`.`id`) = `test`.`t1`.`id`))))
explain extended select * from t1 as tt where not exists (select id from t1 where id < 8 and (id = tt.id or id is null) having id is not null);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY tt ALL NULL NULL NULL NULL 12 100.00 Using where
@@ -2423,21 +2429,22 @@ a
1
3
DROP TABLE t1;
+#
+# SELECT(EXISTS * ...)optimisation
+#
create table t1 (a int, b int);
insert into t1 values (1,2),(3,4),(5,6),(7,8);
-select * from t1 up where exists (select * from t1 where t1.a=up.a);
-a b
-1 2
-3 4
-5 6
-7 8
-explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
+insert into t1 select seq,seq from seq_20_to_40;
+select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a);
+sum(a+b)
+1296
+explain extended select sum(a+b) from t1 up where exists (select * from t1 where t1.a=up.a);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY up ALL NULL NULL NULL NULL 4 100.00 Using where
-2 MATERIALIZED t1 ALL NULL NULL NULL NULL 4 100.00
+1 PRIMARY up ALL NULL NULL NULL NULL 25 100.00 Using where
+2 MATERIALIZED t1 ALL NULL NULL NULL NULL 25 100.00
Warnings:
Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(<in_optimizer>(`test`.`up`.`a`,`test`.`up`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), <primary_index_lookup>(`test`.`up`.`a` in <temporary table> on distinct_key where `test`.`up`.`a` = `<subquery2>`.`a`))))
+Note 1003 /* select#1 */ select sum(`test`.`up`.`a` + `test`.`up`.`b`) AS `sum(a+b)` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(<in_optimizer>(`test`.`up`.`a`,`test`.`up`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where 1 ), <primary_index_lookup>(`test`.`up`.`a` in <temporary table> on distinct_key where `test`.`up`.`a` = `<subquery2>`.`a`))))
drop table t1;
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
@@ -3104,6 +3111,10 @@ retailerID statusID changed
0048 1 2006-01-06 12:37:50
0059 1 2006-01-06 12:37:50
drop table t1;
+#
+# Bug#21180 Subselect with index for both WHERE and ORDER BY
+# produces empty result
+#
create table t1(a int, primary key (a));
insert into t1 values (10);
create table t2 (a int primary key, b varchar(32), c int, unique key cb(c, b));
@@ -3119,7 +3130,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
-2 SUBQUERY t2 ref cb cb 5 const 1 Using where
+2 SUBQUERY t2 range cb cb 40 NULL 3 Using where
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
@@ -3131,7 +3142,7 @@ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
1 PRIMARY r const PRIMARY PRIMARY 4 const 1
-2 SUBQUERY t2 ref cb cb 5 const 1 Using index condition; Using where
+2 SUBQUERY t2 range cb cb 40 NULL 3 Using index condition
SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
@@ -4229,8 +4240,8 @@ INSERT INTO t2 VALUES (7), (5), (1), (3);
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id);
id st
-3 FL
1 GA
+3 FL
7 FL
SELECT id, st FROM t1
WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id)
@@ -4331,6 +4342,9 @@ SELECT ((a1,a2) IN (SELECT * FROM t2 WHERE b2 > 0)) IS NULL FROM t1;
0
0
DROP TABLE t1, t2;
+#
+# Bug#28076 inconsistent binary/varbinary comparison
+#
CREATE TABLE t1 (s1 BINARY(5), s2 VARBINARY(5));
INSERT INTO t1 VALUES (0x41,0x41), (0x42,0x42), (0x43,0x43);
SELECT s1, s2 FROM t1 WHERE s2 IN (SELECT s1 FROM t1);
@@ -4623,7 +4637,7 @@ WHERE outr.int_key NOT IN (SELECT t1.pk FROM t1, t2)
ORDER BY outr.pk;
id select_type table type possible_keys key key_len ref rows Extra
x x outr ALL x x x x x x
-x x t1 index x x x x x x
+x x t1 eq_ref x x x x x x
x x t2 index x x x x x x
# should not crash on debug binaries
SELECT * FROM t2 outr
@@ -5702,6 +5716,7 @@ CREATE TABLE t1 (a int) ;
INSERT INTO t1 VALUES (NULL), (1), (NULL), (2);
CREATE TABLE t2 (a int, INDEX idx(a)) ;
INSERT INTO t2 VALUES (NULL), (1), (NULL),(1000);
+insert into t2 select seq from seq_3_to_100;
SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 USE INDEX () WHERE t2.a = t1.a);
a
@@ -5711,7 +5726,7 @@ SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
-2 MATERIALIZED t2 ALL NULL NULL NULL NULL 4
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 102
SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
a
@@ -5721,7 +5736,7 @@ SELECT * FROM t1
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
-2 DEPENDENT SUBQUERY t2 index_subquery idx idx 5 func 2 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery idx idx 5 func 11 Using index
DROP TABLE t1,t2;
#
# BUG#752992: Wrong results for a subquery with 'semijoin=on'
diff --git a/mysql-test/suite/innodb_fts/t/fulltext.test b/mysql-test/suite/innodb_fts/t/fulltext.test
index 4b73e2ea15b..e94480f37d8 100644
--- a/mysql-test/suite/innodb_fts/t/fulltext.test
+++ b/mysql-test/suite/innodb_fts/t/fulltext.test
@@ -570,6 +570,8 @@ INSERT INTO t2 VALUES (1,'Scargill');
CREATE TABLE t3 (a int, b int) ENGINE = InnoDB;
INSERT INTO t3 VALUES (1,1), (2,1);
+SELECT * FROM t2 where MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE);
+
--echo # t2 should use full text index
EXPLAIN
SELECT count(*) FROM t1 WHERE
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index 1826eecf70c..596446251a1 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@ -2244,11 +2244,21 @@ READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_CACHE_HIT_RATIO
VARIABLE_SCOPE SESSION
-VARIABLE_TYPE INT UNSIGNED
-VARIABLE_COMMENT Expected hit rate of the row and index cache in storage engines. The value should be an integer between 0 and 99, where 0 means cache is empty and 99 means that value is almost always in the cache.
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Expected hit rate of the row and index cache in storage engines. The value should be an integer between 0 and 100, where 0 means cache is empty and 100 means that value is almost always in the cache
NUMERIC_MIN_VALUE 0
-NUMERIC_MAX_VALUE 99
-NUMERIC_BLOCK_SIZE 1
+NUMERIC_MAX_VALUE 100
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_DISK_READ_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost of reading a block of IO_SIZE from an disk (ms 4096 bytes)
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
@@ -2282,6 +2292,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_KEY_LOOKUP_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost modifier for finding a row based on not clustered key
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_KEY_NEXT_FIND_COST
VARIABLE_SCOPE SESSION
VARIABLE_TYPE DOUBLE
@@ -2322,6 +2342,36 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_ROW_LOOKUP_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost of fiding a row based on a rowid or a clustered key
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_ROW_NEXT_FIND_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost of finding the next row when scanning the table
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 1
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_SCAN_LOOKUP_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost modifier for reading a block when scanning a table
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
@@ -2385,7 +2435,7 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_WHERE_COST
VARIABLE_SCOPE SESSION
VARIABLE_TYPE DOUBLE
-VARIABLE_COMMENT Cost of checking the row against the WHERE clause.
+VARIABLE_COMMENT Cost of checking the row against the WHERE clause
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1
NUMERIC_BLOCK_SIZE NULL
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index a5a51309bf8..81fa6413c2f 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -2404,11 +2404,21 @@ READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_CACHE_HIT_RATIO
VARIABLE_SCOPE SESSION
-VARIABLE_TYPE INT UNSIGNED
-VARIABLE_COMMENT Expected hit rate of the row and index cache in storage engines. The value should be an integer between 0 and 99, where 0 means cache is empty and 99 means that value is almost always in the cache.
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Expected hit rate of the row and index cache in storage engines. The value should be an integer between 0 and 100, where 0 means cache is empty and 100 means that value is almost always in the cache
NUMERIC_MIN_VALUE 0
-NUMERIC_MAX_VALUE 99
-NUMERIC_BLOCK_SIZE 1
+NUMERIC_MAX_VALUE 100
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_DISK_READ_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost of reading a block of IO_SIZE from an disk (ms 4096 bytes)
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
@@ -2442,6 +2452,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_KEY_LOOKUP_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost modifier for finding a row based on not clustered key
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_KEY_NEXT_FIND_COST
VARIABLE_SCOPE SESSION
VARIABLE_TYPE DOUBLE
@@ -2482,6 +2502,36 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_ROW_LOOKUP_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost of fiding a row based on a rowid or a clustered key
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_ROW_NEXT_FIND_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost of finding the next row when scanning the table
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 1
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME OPTIMIZER_SCAN_LOOKUP_COST
+VARIABLE_SCOPE SESSION
+VARIABLE_TYPE DOUBLE
+VARIABLE_COMMENT Cost modifier for reading a block when scanning a table
+NUMERIC_MIN_VALUE 0
+NUMERIC_MAX_VALUE 10
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST NULL
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_SEARCH_DEPTH
VARIABLE_SCOPE SESSION
VARIABLE_TYPE BIGINT UNSIGNED
@@ -2545,7 +2595,7 @@ COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME OPTIMIZER_WHERE_COST
VARIABLE_SCOPE SESSION
VARIABLE_TYPE DOUBLE
-VARIABLE_COMMENT Cost of checking the row against the WHERE clause.
+VARIABLE_COMMENT Cost of checking the row against the WHERE clause
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1
NUMERIC_BLOCK_SIZE NULL