summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/my_base.h1
-rw-r--r--mysql-test/include/icp_tests.inc4
-rw-r--r--mysql-test/include/index_merge1.inc2
-rw-r--r--mysql-test/main/cte_nonrecursive.result30
-rw-r--r--mysql-test/main/cte_nonrecursive.test12
-rw-r--r--mysql-test/main/ctype_ucs.result4
-rw-r--r--mysql-test/main/derived.result15
-rw-r--r--mysql-test/main/derived.test4
-rw-r--r--mysql-test/main/derived_cond_pushdown.result180
-rw-r--r--mysql-test/main/derived_opt.result4
-rw-r--r--mysql-test/main/derived_split_innodb.result3
-rw-r--r--mysql-test/main/derived_split_innodb.test2
-rw-r--r--mysql-test/main/disabled.def2
-rw-r--r--mysql-test/main/distinct.result6
-rw-r--r--mysql-test/main/explain_json.result4
-rw-r--r--mysql-test/main/func_group.result10
-rw-r--r--mysql-test/main/func_in.result4
-rw-r--r--mysql-test/main/func_like.result4
-rw-r--r--mysql-test/main/group_by.result4
-rw-r--r--mysql-test/main/group_min_max.result178
-rw-r--r--mysql-test/main/group_min_max.test2
-rw-r--r--mysql-test/main/index_intersect.result26
-rw-r--r--mysql-test/main/index_intersect.test22
-rw-r--r--mysql-test/main/index_intersect_innodb.result26
-rw-r--r--mysql-test/main/index_merge_myisam.result4
-rw-r--r--mysql-test/main/information_schema_stats.result4
-rw-r--r--mysql-test/main/innodb_ext_key.result4
-rw-r--r--mysql-test/main/innodb_icp.result10
-rw-r--r--mysql-test/main/join.result4
-rw-r--r--mysql-test/main/join_cache.result10
-rw-r--r--mysql-test/main/join_nested.result4
-rw-r--r--mysql-test/main/join_nested_jcl6.result6
-rw-r--r--mysql-test/main/join_outer.result6
-rw-r--r--mysql-test/main/join_outer_innodb.result40
-rw-r--r--mysql-test/main/join_outer_jcl6.result6
-rw-r--r--mysql-test/main/key.result4
-rw-r--r--mysql-test/main/key_cache.result6
-rw-r--r--mysql-test/main/limit_rows_examined.result4
-rw-r--r--mysql-test/main/myisam_explain_non_select_all.result64
-rw-r--r--mysql-test/main/myisam_icp.result14
-rw-r--r--mysql-test/main/negation_elimination.result18
-rw-r--r--mysql-test/main/null_key.result14
-rw-r--r--mysql-test/main/opt_trace.result381
-rw-r--r--mysql-test/main/opt_trace_index_merge.result102
-rw-r--r--mysql-test/main/opt_trace_index_merge_innodb.result16
-rw-r--r--mysql-test/main/opt_trace_ucs2.result2
-rw-r--r--mysql-test/main/opt_tvc.result16
-rw-r--r--mysql-test/main/order_by.result4
-rw-r--r--mysql-test/main/partition.result20
-rw-r--r--mysql-test/main/partition.test3
-rw-r--r--mysql-test/main/partition_innodb.result2
-rw-r--r--mysql-test/main/partition_mrr_aria.result12
-rw-r--r--mysql-test/main/partition_mrr_innodb.result12
-rw-r--r--mysql-test/main/partition_mrr_myisam.result16
-rw-r--r--mysql-test/main/partition_pruning.result210
-rw-r--r--mysql-test/main/partition_range.result25
-rw-r--r--mysql-test/main/partition_range.test27
-rw-r--r--mysql-test/main/ps_1general.result10
-rw-r--r--mysql-test/main/range.result32
-rw-r--r--mysql-test/main/range_innodb.result2
-rw-r--r--mysql-test/main/range_mrr_icp.result22
-rw-r--r--mysql-test/main/range_vs_index_merge.result2
-rw-r--r--mysql-test/main/range_vs_index_merge_innodb.result4
-rw-r--r--mysql-test/main/rowid_filter.result48
-rw-r--r--mysql-test/main/rowid_filter_innodb.result184
-rw-r--r--mysql-test/main/select.result16
-rw-r--r--mysql-test/main/select_jcl6.result18
-rw-r--r--mysql-test/main/select_pkeycache.result16
-rw-r--r--mysql-test/main/selectivity.result12
-rw-r--r--mysql-test/main/selectivity_innodb.result6
-rw-r--r--mysql-test/main/stat_tables.result10
-rw-r--r--mysql-test/main/stat_tables_innodb.result2
-rw-r--r--mysql-test/main/subselect.result8
-rw-r--r--mysql-test/main/subselect2.result4
-rw-r--r--mysql-test/main/subselect3.result4
-rw-r--r--mysql-test/main/subselect3_jcl6.result4
-rw-r--r--mysql-test/main/subselect4.result4
-rw-r--r--mysql-test/main/subselect_mat.result20
-rw-r--r--mysql-test/main/subselect_mat_cost.result2
-rw-r--r--mysql-test/main/subselect_mat_cost_bugs.result6
-rw-r--r--mysql-test/main/subselect_no_exists_to_in.result8
-rw-r--r--mysql-test/main/subselect_no_mat.result4
-rw-r--r--mysql-test/main/subselect_no_opts.result6
-rw-r--r--mysql-test/main/subselect_no_scache.result8
-rw-r--r--mysql-test/main/subselect_no_semijoin.result6
-rw-r--r--mysql-test/main/subselect_sj.result10
-rw-r--r--mysql-test/main/subselect_sj2.result8
-rw-r--r--mysql-test/main/subselect_sj2_jcl6.result8
-rw-r--r--mysql-test/main/subselect_sj2_mat.result28
-rw-r--r--mysql-test/main/subselect_sj_jcl6.result12
-rw-r--r--mysql-test/main/subselect_sj_mat.result46
-rw-r--r--mysql-test/main/subselect_sj_nonmerged.result8
-rw-r--r--mysql-test/main/table_elim.result8
-rw-r--r--mysql-test/main/type_bit.result2
-rw-r--r--mysql-test/main/type_blob.result2
-rw-r--r--mysql-test/main/type_enum.result12
-rw-r--r--mysql-test/suite/gcol/r/gcol_bugfixes.result2
-rw-r--r--mysql-test/suite/gcol/r/gcol_keys_innodb.result2
-rw-r--r--mysql-test/suite/gcol/r/gcol_select_innodb.result6
-rw-r--r--mysql-test/suite/gcol/r/gcol_select_myisam.result6
-rw-r--r--mysql-test/suite/heap/heap.result2
-rw-r--r--mysql-test/suite/heap/heap_btree.result8
-rw-r--r--mysql-test/suite/heap/heap_btree.test8
-rw-r--r--mysql-test/suite/innodb/r/full_crc32_import.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb-isolation.result6
-rw-r--r--mysql-test/suite/innodb/r/innodb_mysql.result20
-rw-r--r--mysql-test/suite/innodb/r/innodb_wl6326.result16
-rw-r--r--mysql-test/suite/innodb/r/monitor.result12
-rw-r--r--mysql-test/suite/innodb/r/temporary_table.result2
-rw-r--r--mysql-test/suite/innodb/r/temporary_table_optimization.result2
-rw-r--r--mysql-test/suite/innodb/t/full_crc32_import.test4
-rw-r--r--mysql-test/suite/innodb/t/mdev-117.test2
-rw-r--r--mysql-test/suite/innodb_gis/r/rtree_estimate.result6
-rw-r--r--mysql-test/suite/maria/icp.result12
-rw-r--r--mysql-test/suite/maria/maria.result2
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_innodb.result6
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_myisam.result6
-rw-r--r--mysql-test/suite/versioning/r/cte.result5
-rw-r--r--sql/filesort_utils.cc6
-rw-r--r--sql/handler.cc6
-rw-r--r--sql/handler.h21
-rw-r--r--sql/item_func.cc2
-rw-r--r--sql/multi_range_read.cc284
-rw-r--r--sql/opt_range.cc38
-rw-r--r--sql/opt_subselect.cc9
-rw-r--r--sql/sql_const.h5
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_select.cc202
-rw-r--r--sql/table.cc4
-rw-r--r--sql/uniques.cc6
-rw-r--r--sql/uniques.h5
-rw-r--r--storage/connect/mysql-test/connect/r/mysql_index.result2
-rw-r--r--storage/connect/mysql-test/connect/t/mysql_index.test1
-rw-r--r--storage/heap/ha_heap.h6
-rw-r--r--storage/maria/ha_maria.cc3
-rw-r--r--storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result2
-rw-r--r--storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_primary_key_not_equal.result2
-rw-r--r--storage/myisam/ha_myisam.cc3
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result14
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result6
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test1
-rw-r--r--storage/spider/mysql-test/spider/r/direct_left_join_nullable.result2
-rw-r--r--storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result2
-rw-r--r--storage/spider/mysql-test/spider/r/direct_right_join_nullable.result2
-rw-r--r--storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/cluster_delete.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/cluster_key.result4
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/type_bit.result4
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/type_datetime.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result12
-rw-r--r--storage/tokudb/mysql-test/tokudb_alter_table/r/hcr3.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb_bugs/r/2383.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result4
158 files changed, 1686 insertions, 1365 deletions
diff --git a/include/my_base.h b/include/my_base.h
index 5bc778655dc..7efa5eb9673 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -615,7 +615,6 @@ enum data_file_type {
#define EQ_RANGE 32U
#define NULL_RANGE 64U
#define GEOM_FLAG 128U
-#define SKIP_RANGE 256U
typedef struct st_key_range
{
diff --git a/mysql-test/include/icp_tests.inc b/mysql-test/include/icp_tests.inc
index aa7ab6e60a1..be892cf774b 100644
--- a/mysql-test/include/icp_tests.inc
+++ b/mysql-test/include/icp_tests.inc
@@ -1,3 +1,5 @@
+--source include/have_sequence.inc
+
--echo #
--echo # Bug#36981 - "innodb crash when selecting for update"
--echo #
@@ -721,10 +723,12 @@ DROP TABLE t1;
CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b));
INSERT INTO t1 VALUES (1,4,'Ill');
+insert into t1 select seq+100,5,seq from seq_1_to_100;
CREATE TABLE t2 (a varchar(1024), KEY (a(512)));
INSERT INTO t2 VALUES
('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w');
+insert into t2 select seq from seq_1_to_100;
SET SESSION optimizer_switch='index_condition_pushdown=off';
EXPLAIN
diff --git a/mysql-test/include/index_merge1.inc b/mysql-test/include/index_merge1.inc
index 5364780b689..5934539061a 100644
--- a/mysql-test/include/index_merge1.inc
+++ b/mysql-test/include/index_merge1.inc
@@ -182,7 +182,7 @@ alter table t2 add index i321(key3, key2, key1);
explain select key3 from t2 where key1 = 100 or key2 = 100;
# index_merge vs 'index', 'index' is better.
-explain select key3 from t2 where key1 < 500 or key2 < 500;
+explain select key3 from t2 where key1 < 600 or key2 < 600;
# index_merge vs 'all', index_merge is better.
explain select key7 from t2 where key1 <100 or key2 < 100;
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index a24ebdd1fff..f105330976a 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -1159,10 +1159,10 @@ with cte as
union
(select a from t1 where a < 2);
a
+1
4
5
7
-1
prepare stmt from "with cte as
(select a from t1 where a between 4 and 7 group by a)
(select a from cte where exists( select a from t1 where cte.a=t1.a ))
@@ -1170,16 +1170,16 @@ union
(select a from t1 where a < 2)";
execute stmt;
a
+1
4
5
7
-1
execute stmt;
a
+1
4
5
7
-1
deallocate prepare stmt;
with cte as
(select a from t1 where a between 4 and 7 group by a)
@@ -1216,9 +1216,9 @@ union
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
a
1
-7
-5
4
+5
+7
prepare stmt from "with cte as
(select a from t1 where a between 4 and 7)
(select a from t1 where a < 2)
@@ -1227,15 +1227,15 @@ union
execute stmt;
a
1
-7
-5
4
+5
+7
execute stmt;
a
1
-7
-5
4
+5
+7
deallocate prepare stmt;
with cte as
(select a from t1 where a between 4 and 7)
@@ -1244,9 +1244,9 @@ where exists( select a from t1 where t1.a < 2 and cte.a=t1.a ))
union
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
a
-7
-5
4
+5
+7
prepare stmt from "with cte as
(select a from t1 where a between 4 and 7)
(select a from cte
@@ -1255,14 +1255,14 @@ union
(select a from cte where exists( select a from t1 where cte.a=t1.a ))";
execute stmt;
a
-7
-5
4
+5
+7
execute stmt;
a
-7
-5
4
+5
+7
deallocate prepare stmt;
drop table t1;
#
diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test
index f311271d4d2..b39d6cde8a5 100644
--- a/mysql-test/main/cte_nonrecursive.test
+++ b/mysql-test/main/cte_nonrecursive.test
@@ -808,9 +808,12 @@ with cte as
union
(select a from t1 where a < 2);
+--sorted_result
eval $q1;
eval prepare stmt from "$q1";
+--sorted_result
execute stmt;
+--sorted_result
execute stmt;
deallocate prepare stmt;
@@ -821,9 +824,12 @@ with cte as
union
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
+--sorted_result
eval $q2;
eval prepare stmt from "$q2";
+--sorted_result
execute stmt;
+--sorted_result
execute stmt;
deallocate prepare stmt;
@@ -834,9 +840,12 @@ with cte as
union
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
+--sorted_result
eval $q3;
eval prepare stmt from "$q3";
+--sorted_result
execute stmt;
+--sorted_result
execute stmt;
deallocate prepare stmt;
@@ -848,9 +857,12 @@ with cte as
union
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
+--sorted_result
eval $q4;
eval prepare stmt from "$q4";
+--sorted_result
execute stmt;
+--sorted_result
execute stmt;
deallocate prepare stmt;
diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result
index 4688df046c9..48b866b64f5 100644
--- a/mysql-test/main/ctype_ucs.result
+++ b/mysql-test/main/ctype_ucs.result
@@ -1569,7 +1569,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 23 NULL 1 Using where; Using index
EXPLAIN SELECT * FROM t1 WHERE a LIKE 'c%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index
+1 SIMPLE t1 range a a 23 NULL 31 Using where; Using index
SELECT * FROM t1 WHERE a LIKE 'c%';
a
ca
@@ -1585,7 +1585,7 @@ ch
ALTER TABLE t1 MODIFY a VARCHAR(10) CHARACTER SET ucs2 COLLATE ucs2_croatian_ci;
EXPLAIN SELECT * FROM t1 WHERE a LIKE 'd%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 23 NULL 31 Using where; Using index
+1 SIMPLE t1 range a a 23 NULL 31 Using where; Using index
SELECT hex(concat('d',_ucs2 0x017E,'%'));
hex(concat('d',_ucs2 0x017E,'%'))
0064017E0025
diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result
index 87e6dfb3680..8264e311f93 100644
--- a/mysql-test/main/derived.result
+++ b/mysql-test/main/derived.result
@@ -324,11 +324,11 @@ create table t2 (a int, b int, primary key (a));
insert into t2 values (1,7),(2,7);
explain select a from t2 where a>1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
explain select a from (select a from t2 where a>1) tt;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+2 DERIVED t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
drop table t2;
CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`));
insert into t1 values (128, 'rozn', 2, curdate(), 10),
@@ -1064,16 +1064,19 @@ INSERT INTO t2 VALUES (NULL),(NULL);
CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
+INSERT INTO t1 select seq from seq_1_to_1000;
+INSERT INTO t2 select seq+1000 from seq_1_to_1000;
+INSERT INTO t3 select 'qqq',seq+2000 from seq_1_to_1000;
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
-1 PRIMARY <derived3> hash_ALL NULL #hash#$hj 3075 func 2 Using where; Using join buffer (flat, BNLH join)
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 1002
+1 PRIMARY <derived3> hash_ALL NULL #hash#$hj 3075 func 1002 Using where; Using join buffer (flat, BNLH join)
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 v3.d 1 Using index
-3 DERIVED t3 ALL NULL NULL NULL NULL 2
-2 DERIVED t1 ALL NULL NULL NULL NULL 2
+3 DERIVED t3 ALL NULL NULL NULL NULL 1002
+2 DERIVED t1 ALL NULL NULL NULL NULL 1002
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
a b c d
DROP VIEW v1, v3;
diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test
index f4477ce8550..8c41f80ffbd 100644
--- a/mysql-test/main/derived.test
+++ b/mysql-test/main/derived.test
@@ -1,5 +1,6 @@
# Initialize
--source include/default_optimizer_switch.inc
+--source include/have_sequence.inc
--disable_warnings
drop table if exists t1,t2,t3;
@@ -919,6 +920,9 @@ INSERT INTO t2 VALUES (NULL),(NULL);
CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
+INSERT INTO t1 select seq from seq_1_to_1000;
+INSERT INTO t2 select seq+1000 from seq_1_to_1000;
+INSERT INTO t3 select 'qqq',seq+2000 from seq_1_to_1000;
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 7dea6a81e04..c7f6448f2d8 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -8828,9 +8828,21 @@ EXPLAIN
"query_block": {
"select_id": 1,
"table": {
- "table_name": "<derived2>",
+ "table_name": "t1",
"access_type": "ALL",
- "rows": 3,
+ "rows": 4,
+ "filtered": 100,
+ "attached_condition": "t1.id2 is not null"
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["id2"],
+ "ref": ["test.t1.id2"],
+ "rows": 2,
"filtered": 100,
"attached_condition": "vc.ct > 0",
"materialized": {
@@ -8850,18 +8862,6 @@ EXPLAIN
}
}
}
- },
- "block-nl-join": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 4,
- "filtered": 100
- },
- "buffer_type": "flat",
- "buffer_size": "163",
- "join_type": "BNL",
- "attached_condition": "t1.id2 = vc.id2"
}
}
}
@@ -9078,9 +9078,8 @@ WHERE d_tab.e>1
)
;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
EXPLAIN FORMAT=JSON SELECT * FROM t1
WHERE (t1.a,t1.b) IN
@@ -9103,44 +9102,33 @@ EXPLAIN
"table_name": "t1",
"access_type": "ALL",
"rows": 5,
- "filtered": 100
+ "filtered": 100,
+ "attached_condition": "t1.a > 1 and t1.a is not null and t1.b is not null"
},
"table": {
- "table_name": "<subquery2>",
- "access_type": "eq_ref",
- "possible_keys": ["distinct_key"],
- "key": "distinct_key",
- "key_length": "8",
+ "table_name": "<derived3>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "10",
"used_key_parts": ["e", "max_f"],
- "ref": ["func", "func"],
- "rows": 1,
+ "ref": ["test.t1.a", "test.t1.b"],
+ "rows": 2,
"filtered": 100,
+ "first_match": "t1",
"materialized": {
- "unique": 1,
"query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "d_tab.e > 1",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "max_f > 18",
- "filesort": {
- "sort_key": "t2.e",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t2.e > 1"
- }
- }
- }
+ "select_id": 3,
+ "having_condition": "max_f > 18",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t2.e > 1"
}
}
}
@@ -9179,9 +9167,8 @@ WHERE d_tab.max_f<25
)
;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY <derived3> ref key0 key0 10 test.t1.a,test.t1.b 2 FirstMatch(t1)
3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
EXPLAIN FORMAT=JSON SELECT * FROM t1
WHERE (t1.a,t1.b) IN
@@ -9204,43 +9191,32 @@ EXPLAIN
"table_name": "t1",
"access_type": "ALL",
"rows": 5,
- "filtered": 100
+ "filtered": 100,
+ "attached_condition": "t1.b < 25 and t1.a is not null and t1.b is not null"
},
"table": {
- "table_name": "<subquery2>",
- "access_type": "eq_ref",
- "possible_keys": ["distinct_key"],
- "key": "distinct_key",
- "key_length": "8",
+ "table_name": "<derived3>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "10",
"used_key_parts": ["e", "max_f"],
- "ref": ["func", "func"],
- "rows": 1,
+ "ref": ["test.t1.a", "test.t1.b"],
+ "rows": 2,
"filtered": 100,
+ "first_match": "t1",
"materialized": {
- "unique": 1,
"query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "d_tab.max_f < 25",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "max_f > 18 and max_f < 25",
- "filesort": {
- "sort_key": "t2.e",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- }
- }
- }
+ "select_id": 3,
+ "having_condition": "max_f > 18 and max_f < 25",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
}
}
}
@@ -14045,16 +14021,16 @@ a b max_c a b c
1 21 345 3 21 231
select * from v1,t2 where (v1.b=t2.b) and (v1.a<5);
a b max_c a b c
-2 33 7 5 33 207
4 33 123 5 33 207
-2 33 7 8 33 117
+2 33 7 5 33 207
4 33 123 8 33 117
-1 21 345 3 21 231
+2 33 7 8 33 117
3 21 500 3 21 231
+1 21 345 3 21 231
explain select * from v1,t2 where (v1.b=t2.b) and (v1.a<5);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using where
-1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t2.b 2 Using where
2 DERIVED t3 range i1 i1 5 NULL 5 Using index condition
explain format=json select * from v1,t2 where (v1.b=t2.b) and (v1.a<5);
EXPLAIN
@@ -14062,9 +14038,21 @@ EXPLAIN
"query_block": {
"select_id": 1,
"table": {
- "table_name": "<derived2>",
+ "table_name": "t2",
"access_type": "ALL",
- "rows": 5,
+ "rows": 9,
+ "filtered": 100,
+ "attached_condition": "t2.b is not null"
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["b"],
+ "ref": ["test.t2.b"],
+ "rows": 2,
"filtered": 100,
"attached_condition": "v1.a < 5",
"materialized": {
@@ -14083,18 +14071,6 @@ EXPLAIN
}
}
}
- },
- "block-nl-join": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 9,
- "filtered": 100
- },
- "buffer_type": "flat",
- "buffer_size": "173",
- "join_type": "BNL",
- "attached_condition": "t2.b = v1.b"
}
}
}
diff --git a/mysql-test/main/derived_opt.result b/mysql-test/main/derived_opt.result
index c30f56d9925..9da9e6e4413 100644
--- a/mysql-test/main/derived_opt.result
+++ b/mysql-test/main/derived_opt.result
@@ -137,10 +137,10 @@ create table t2 (a int, b int, primary key (a));
insert into t2 values (1,7),(2,7);
explain select a from t2 where a>1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
explain select a from (select a from t2 where a>1) tt;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
drop table t2;
create table t1
(
diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result
index e8f9df5f80d..15b67b51f45 100644
--- a/mysql-test/main/derived_split_innodb.result
+++ b/mysql-test/main/derived_split_innodb.result
@@ -9,6 +9,7 @@ KEY c1 (c1),
KEY n1_c1_n2 (n1,c1,n2)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, 2, 'a'), (1, 3, 'a');
+insert into t1 select seq+1,seq+2,'c' from seq_1_to_1000;
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -16,7 +17,7 @@ test.t1 analyze status OK
EXPLAIN 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;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index c1,n1_c1_n2 n1_c1_n2 9 NULL 2 Using where; Using index
+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 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
diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test
index 4f9d2e970f7..d4d7fde1fcd 100644
--- a/mysql-test/main/derived_split_innodb.test
+++ b/mysql-test/main/derived_split_innodb.test
@@ -1,5 +1,6 @@
--source include/have_innodb.inc
--source include/default_optimizer_switch.inc
+--source include/have_sequence.inc
--echo #
--echo # MDEV-16917: do not use splitting for derived with join cache
@@ -13,6 +14,7 @@ CREATE TABLE t1 (
KEY n1_c1_n2 (n1,c1,n2)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0, 2, 'a'), (1, 3, 'a');
+insert into t1 select seq+1,seq+2,'c' from seq_1_to_1000;
ANALYZE TABLE t1;
diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def
index 02104f6a680..d3366587ee5 100644
--- a/mysql-test/main/disabled.def
+++ b/mysql-test/main/disabled.def
@@ -18,3 +18,5 @@ file_contents : MDEV-6526 these files are not installed anymore
max_statement_time : cannot possibly work, depends on timing
partition_open_files_limit : open_files_limit check broken by MDEV-18360
partition_innodb : Waiting for fix MDEV-20169
+type_enum : Waiting for fix MDEV-6978
+type_set : Waiting for fix MDEV-6978
diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result
index 8fcc45e740a..2062ff0091d 100644
--- a/mysql-test/main/distinct.result
+++ b/mysql-test/main/distinct.result
@@ -538,10 +538,10 @@ PRIMARY KEY (a,b));
INSERT INTO t2 VALUES (1,1,1,50), (1,2,3,40), (2,1,3,4);
EXPLAIN SELECT DISTINCT a FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
+1 SIMPLE t2 range NULL PRIMARY 4 NULL 4 Using index for group-by
EXPLAIN SELECT DISTINCT a,a FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
+1 SIMPLE t2 range NULL PRIMARY 4 NULL 4 Using index for group-by
EXPLAIN SELECT DISTINCT b,a FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL PRIMARY 8 NULL 3 Using index
@@ -756,7 +756,7 @@ INSERT INTO t1(a, b, c) VALUES (1, 1, 1),
(1, 2, 3);
EXPLAIN SELECT DISTINCT a, b, d, c FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL a 16 NULL 6 Using index
+1 SIMPLE t1 range NULL PRIMARY 16 NULL 7 Using index for group-by; Using temporary
SELECT DISTINCT a, b, d, c FROM t1;
a b d c
1 1 0 1
diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result
index a48cfcf213b..18a15795aab 100644
--- a/mysql-test/main/explain_json.result
+++ b/mysql-test/main/explain_json.result
@@ -1037,7 +1037,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by (scanning)
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by
explain format=json select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
EXPLAIN
{
@@ -1070,7 +1070,7 @@ EXPLAIN
"rows": 65,
"filtered": 100,
"attached_condition": "t1.b = 'a' and t1.c = 'i121' and t1.a2 >= 'b'",
- "using_index_for_group_by": "scanning"
+ "using_index_for_group_by": true
}
}
}
diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result
index 938acbae0e2..82dbb062e20 100644
--- a/mysql-test/main/func_group.result
+++ b/mysql-test/main/func_group.result
@@ -604,11 +604,11 @@ AME AME
explain
select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX';
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 0 NULL 15 Using where; Using index
explain
select min(a1) from t1 where 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));
@@ -1927,7 +1927,7 @@ b
EXPLAIN
SELECT MIN(f2) FROM t1 WHERE f2 >= 'abc';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index f2 f2 4 NULL 2 Using where; Using index
+1 SIMPLE t1 range f2 f2 4 NULL 1 Using where; Using index
SELECT MIN(f2) FROM t1 WHERE f2 >= 'abc';
MIN(f2)
b
@@ -1941,7 +1941,7 @@ b
EXPLAIN
SELECT MIN(f2) FROM t1 WHERE f2 BETWEEN 'abc' AND 'b' ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index f2 f2 4 NULL 2 Using where; Using index
+1 SIMPLE t1 range f2 f2 4 NULL 1 Using where; Using index
SELECT MIN(f2) FROM t1 WHERE f2 BETWEEN 'abc' AND 'b' ;
MIN(f2)
b
diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result
index 9a3c1dba045..51074650d29 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
@@ -553,7 +553,7 @@ Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'b'
explain select f2 from t2 where f2 in ('a','b');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
+1 SIMPLE t2 range t2f2 t2f2 5 NULL 1 Using where; Using index
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'b'
diff --git a/mysql-test/main/func_like.result b/mysql-test/main/func_like.result
index a937037167c..0ec6724d7c0 100644
--- a/mysql-test/main/func_like.result
+++ b/mysql-test/main/func_like.result
@@ -3,12 +3,12 @@ create table t1 (a varchar(10), key(a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
explain extended select * from t1 where a like 'abc%';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 index a a 13 NULL 5 40.00 Using where; Using index
+1 SIMPLE t1 range a a 13 NULL 2 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` like 'abc%'
explain extended select * from t1 where a like concat('abc','%');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 index a a 13 NULL 5 40.00 Using where; Using index
+1 SIMPLE t1 range a a 13 NULL 2 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` like <cache>(concat('abc','%'))
select * from t1 where a like "abc%";
diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result
index b8d9af2e8da..3a49c075ddd 100644
--- a/mysql-test/main/group_by.result
+++ b/mysql-test/main/group_by.result
@@ -1578,7 +1578,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT a FROM t1 FORCE INDEX FOR JOIN (i2)
FORCE INDEX FOR GROUP BY (i2) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL i2 9 NULL 144 Using index
+1 SIMPLE t1 range NULL i2 4 NULL 145 Using index for group-by
EXPLAIN SELECT a FROM t1 USE INDEX () IGNORE INDEX (i2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 144
@@ -1701,7 +1701,7 @@ NULL 1
1 2
EXPLAIN SELECT a from t2 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL a 10 NULL 6 Using index
+1 SIMPLE t2 range NULL a 5 NULL 7 Using index for group-by
SELECT a from t2 GROUP BY a;
a
NULL
diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result
index a28cc418207..4f32db780fd 100644
--- a/mysql-test/main/group_min_max.result
+++ b/mysql-test/main/group_min_max.result
@@ -35,6 +35,8 @@ insert into t1 (a1, a2, b, c, d) values
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
+insert into t1 select * from t1;
+insert into t1 select * from t1;
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);
@@ -290,34 +292,34 @@ b i421 l421
b m422 p422
explain select a1,a2,b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 >= 'c' or a1 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 >= 'c' or a2 < 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where a1 = 'z' or a1 = 'b' or a1 = 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 9 Using where; Using index for group-by
explain select a1,min(c),max(c) from t1 where a1 >= 'b' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select a1, max(c) from t1 where a1 in ('a','b','d') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
@@ -1361,9 +1363,9 @@ explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c = t1.c )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 16 func 1
-2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 164 Using index
+2 MATERIALIZED t2 index NULL idx_t2_1 163 NULL 548 Using index
select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c = t1.c )
group by a1,a2,b;
@@ -1388,8 +1390,8 @@ explain select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using index
-2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using index
+2 SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
select a1,a2,b,min(c),max(c) from t1
where exists ( select * from t2 where t2.c > 'b1' )
group by a1,a2,b;
@@ -1414,8 +1416,8 @@ explain select a1,a2,b,c,min(c), max(c) from t1
where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
-2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
select a1,a2,b,c,min(c), max(c) from t1
where exists ( select * from t2 where t1.b > 'a' and t2.c > 'b1' )
group by a1,a2,b;
@@ -1436,8 +1438,8 @@ where t2.c in (select c from t3 where t3.c > t1.b) and
t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
-2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
select a1,a2,b,c,min(c), max(c) from t1
where exists ( select * from t2
@@ -1466,8 +1468,8 @@ explain select a1,a2,b,c,min(c), max(c) from t1
where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
-2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
select a1,a2,b,c,min(c), max(c) from t1
where exists ( select * from t2 where t1.c > 'a' and t2.c > 'b1' )
group by a1,a2,b;
@@ -1496,8 +1498,8 @@ where t2.c in (select c from t3 where t3.c > t1.c) and
t2.c > 'b1' )
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL idx_t1_1 163 NULL 128 Using where; Using index
-2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 PRIMARY t1 index NULL idx_t1_1 163 NULL 512 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
2 DEPENDENT SUBQUERY t3 index NULL idx_t3_1 10 NULL 192 Using where; Using index; FirstMatch(t2)
select a1,a2,b,c,min(c), max(c) from t1
where exists ( select * from t2
@@ -1533,13 +1535,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c < 'h112') or (c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 13 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where ((a1 > 'a') or (a1 < '9')) and ((a2 >= 'b') and (a2 < 'z')) and (b = 'a') and ((c = 'j121') or (c > 'k121' and c < 'm122') or (c > 'o122') or (c < 'h112') or (c = 'c111')) group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 163 NULL 13 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 14 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select a1,a2,b,min(c) from t1 where (ord(a1) > 97) and (ord(a2) + ord(a1) > 194) and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
@@ -1656,7 +1658,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select a1,a2,b from t2 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
@@ -1716,15 +1718,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain extended select distinct a1,a2,b,c from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 index NULL idx_t1_1 163 NULL 128 0.38 Using where; Using index
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 100.00 Using where; Using index for group-by
Warnings:
Note 1003 select distinct `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where `test`.`t1`.`b` = 'a' and `test`.`t1`.`c` = 'i121' and `test`.`t1`.`a2` >= 'b'
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select distinct b from t1 where (a2 >= 'b') and (b = 'a');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using where; Using index
explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using index for group-by
@@ -1733,7 +1735,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 146 NULL # Using where; Using index for group-by
explain extended select distinct a1,a2,b,c from t2 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 0.30 Using where; Using index
+1 SIMPLE t2 range NULL idx_t2_1 163 NULL 69 100.00 Using where; Using index for group-by
Warnings:
Note 1003 select distinct `test`.`t2`.`a1` AS `a1`,`test`.`t2`.`a2` AS `a2`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where `test`.`t2`.`b` = 'a' and `test`.`t2`.`c` = 'i121' and `test`.`t2`.`a2` >= 'b'
explain select distinct a1,a2,b from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
@@ -1741,7 +1743,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by
explain select distinct b from t2 where (a2 >= 'b') and (b = 'a');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL idx_t2_2 146 NULL 164 Using where; Using index
+1 SIMPLE t2 index NULL idx_t2_2 146 NULL 548 Using where; Using index
select distinct a1,a2,b from t1;
a1 a2 b
a a a
@@ -1867,7 +1869,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select distinct a1,a2,b from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 13 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 Using where; Using index for group-by
explain select distinct b from t1 where (a2 >= 'b') and (b = 'a') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
@@ -1959,18 +1961,18 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select count(distinct a1,a2,b,c) from t1 where (a2 >= 'b') and (b = 'a') and (c = 'i121');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by (scanning)
+1 SIMPLE t1 range NULL idx_t1_1 163 NULL 65 Using where; Using index for group-by
explain extended select count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a') and (b = 'c');
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_2 147 NULL 13 100.00 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 100.00 Using where; Using index for group-by
Warnings:
Note 1003 select count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`b` = 'c' and `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a'
explain select count(distinct b) from t1 where (a2 >= 'b') and (b = 'a');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using where; Using index
explain extended select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
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_2 147 NULL 13 100.00 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 13 100.00 Using where; Using index for group-by
Warnings:
Note 1003 select 98 + count(distinct `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`) AS `98 + count(distinct a1,a2,b)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' and `test`.`t1`.`a2` > 'a'
select count(distinct a1,a2,b) from t1 where (a2 >= 'b') and (b = 'a');
@@ -1990,16 +1992,16 @@ select 98 + count(distinct a1,a2,b) from t1 where (a1 > 'a') and (a2 > 'a');
104
explain select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by
explain select concat(a1,min(c)),b from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by
explain select concat(a1,min(c)),b,max(c) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by
explain select concat(a1,a2),b,min(c),max(c) from t1 where a1 < 'd' group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 12 Using where; Using index for group-by
explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by
@@ -2071,63 +2073,63 @@ concat(ord(min(b)),ord(max(b))) min(b) max(b)
9798 a b
explain select a1,a2,b,d,min(c),max(c) from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using temporary; Using filesort
explain select a1,a2,b,d from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using temporary; Using filesort
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 77 99.22 Using where; Using index
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 99.22 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
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 45.12 Using where; Using temporary; Using filesort
+1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 40.43 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` 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`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select a1,a2,b,c from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 128 45.12 Using where; Using temporary; Using filesort
+1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 40.43 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` 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`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+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 77 99.22 Using where; Using index
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 99.22 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;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;
a1 a2 min(b) c
a a a a111
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b = 'a') group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
explain select a1,a2,b,min(c),max(c) from t2
where (c > 'a000') and (c <= 'd999') and (c like '_8__') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL idx_t2_1 163 NULL 164 Using where; Using index
+1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
explain select a1, a2, b, c, min(d), max(d) from t1 group by a1,a2,b,c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using temporary; Using filesort
explain select a1,a2,count(a2) from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using index
explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') 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_2 65 NULL 101 95.05 Using where; Using index
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 392 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select sum(ord(a1)) from t1 where (a1 > 'a') 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_2 65 NULL 101 95.05 Using where; Using index
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 392 100.00 Using where; Using index
Warnings:
Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where `test`.`t1`.`a1` > 'a' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
create table t4 as select distinct a1, a2, b, c from t1;
@@ -2158,7 +2160,7 @@ d b b m422
drop table t4;
explain select distinct(a1) from t1 where ord(a2) = 98;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
+1 SIMPLE t1 index NULL idx_t1_2 147 NULL 512 Using where; Using index
select distinct(a1) from t1 where ord(a2) = 98;
a1
a
@@ -2372,7 +2374,7 @@ 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 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 for group-by
+1 SIMPLE t2 range PRIMARY PRIMARY 12 NULL 1 Using where; Using index
SELECT MIN(c) FROM t2 WHERE b = 2 and a = 1 and c > 1 GROUP BY a;
MIN(c)
2
@@ -2386,7 +2388,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL a 10 NULL 15 Using index
+1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by
FLUSH STATUS;
SELECT max(b), a FROM t1 GROUP BY a;
max(b) a
@@ -2396,18 +2398,18 @@ max(b) a
6 4
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 15
+Handler_read_key 8
+Handler_read_next 0
Handler_read_retry 0
EXPLAIN SELECT max(b), a FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL a 10 NULL 15 Using index
+1 SIMPLE t1 range NULL a 5 NULL 6 Using index for group-by
FLUSH STATUS;
CREATE TABLE t2 SELECT max(b), a FROM t1 GROUP BY a;
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 15
+Handler_read_key 8
+Handler_read_next 0
Handler_read_retry 0
FLUSH STATUS;
SELECT * FROM (SELECT max(b), a FROM t1 GROUP BY a) b;
@@ -2418,8 +2420,8 @@ max(b) a
6 4
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 15
+Handler_read_key 8
+Handler_read_next 0
Handler_read_retry 0
FLUSH STATUS;
(SELECT max(b), a FROM t1 GROUP BY a) UNION
@@ -2431,20 +2433,20 @@ max(b) a
6 4
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 30
+Handler_read_key 16
+Handler_read_next 0
Handler_read_retry 0
EXPLAIN (SELECT max(b), a FROM t1 GROUP BY a) UNION
(SELECT max(b), a FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL a 10 NULL 15 Using index
-2 UNION t1 index NULL a 10 NULL 15 Using index
+1 PRIMARY t1 range NULL a 5 NULL 6 Using index for group-by
+2 UNION t1 range NULL a 5 NULL 6 Using index for group-by
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
EXPLAIN SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
FROM t1 AS t1_outer;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
-2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
@@ -2454,38 +2456,38 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
a IN (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
-1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 3 Using index
-2 MATERIALIZED t1 range a a 5 NULL 2 Using where; Using index for group-by
+1 PRIMARY t1_outer index a a 10 NULL 15 Using where; Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1_outer.a 1
+2 MATERIALIZED t1 range a a 5 NULL 5 Using where; Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer GROUP BY a HAVING
a > (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
-2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+1 PRIMARY t1_outer range NULL a 5 NULL 6 Using index for group-by
+2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer1 JOIN t1 AS t1_outer2
ON t1_outer1.a = (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2)
AND t1_outer1.b = t1_outer2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer1 ref a a 5 const 1 Using where; Using index
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using where; Using index; Using join buffer (flat, BNL join)
-2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index
EXPLAIN SELECT (SELECT (SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) x
FROM t1 AS t1_outer) x2 FROM t1 AS t1_outer2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer2 index NULL a 10 NULL 15 Using index
2 SUBQUERY t1_outer index NULL a 10 NULL 15 Using index
-3 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+3 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index
CREATE TABLE t3 LIKE t1;
FLUSH STATUS;
INSERT INTO t3 SELECT a,MAX(b) FROM t1 GROUP BY a;
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 5
-Handler_read_next 15
+Handler_read_key 13
+Handler_read_next 0
Handler_read_retry 0
DELETE FROM t3;
FLUSH STATUS;
@@ -2493,15 +2495,15 @@ INSERT INTO t3 SELECT 1, (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2)
FROM t1 LIMIT 1;
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 15
+Handler_read_key 8
+Handler_read_next 0
Handler_read_retry 0
FLUSH STATUS;
DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 15
+Handler_read_key 8
+Handler_read_next 0
Handler_read_retry 0
FLUSH STATUS;
DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x
@@ -2509,8 +2511,8 @@ FROM t1) > 10000;
ERROR 21000: Subquery returns more than 1 row
SHOW STATUS LIKE 'handler_read__e%';
Variable_name Value
-Handler_read_key 0
-Handler_read_next 16
+Handler_read_key 8
+Handler_read_next 1
Handler_read_retry 0
DROP TABLE t1,t2,t3;
CREATE TABLE t1 (a int, INDEX idx(a));
@@ -2662,7 +2664,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 ref a,index a 5 const 15 100.00 Using index; Using temporary
+1 SIMPLE t1 ref a,index a 5 const 15 20.00 Using index; 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;
@@ -3662,7 +3664,7 @@ f1 COUNT(DISTINCT f2)
3 4
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 9 Using index for group-by (scanning)
+1 SIMPLE t1 range NULL f1 5 NULL 9 Using index for group-by
drop table t1;
# End of test#50539.
#
@@ -4000,10 +4002,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
diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test
index 0dc7ea2fee7..526552dda92 100644
--- a/mysql-test/main/group_min_max.test
+++ b/mysql-test/main/group_min_max.test
@@ -53,6 +53,8 @@ insert into t1 (a1, a2, b, c, d) values
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
+insert into t1 select * from t1;
+insert into t1 select * from t1;
create index idx_t1_0 on t1 (a1);
create index idx_t1_1 on t1 (a1,a2,b,c);
diff --git a/mysql-test/main/index_intersect.result b/mysql-test/main/index_intersect.result
index bb2478c8c46..3ec98216479 100644
--- a/mysql-test/main/index_intersect.result
+++ b/mysql-test/main/index_intersect.result
@@ -80,7 +80,7 @@ EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where
+1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
SELECT * FROM City USE INDEX ()
WHERE Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
@@ -335,8 +335,8 @@ ID Name Country Population
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
ID Name Country Population
-3580 Moscow RUS 8389200
1024 Mumbai (Bombay) IND 10500000
+3580 Moscow RUS 8389200
SELECT COUNT(*) FROM City WHERE Name BETWEEN 'M' AND 'N';
COUNT(*)
301
@@ -368,14 +368,14 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Name,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
EXPLAIN
SELECT * FROM City
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
+1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Population,Name,Country Name # NULL # Using index condition; Using where
+1 SIMPLE City index_merge Population,Name,Country Name,Country,Population # NULL # Using sort_intersect(Name,Country,Population); Using where
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 AND Country LIKE 'C%';
ID Name Country Population
@@ -387,12 +387,14 @@ ID Name Country Population
1810 Montréal CAN 1016376
2259 Medellín COL 1861265
SELECT * FROM City USE INDEX ()
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
ID Name Country Population
+1533 Jokohama [Yokohama] JPN 3339594
1541 Hiroshima JPN 1119117
SELECT * FROM City
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
ID Name Country Population
+1533 Jokohama [Yokohama] JPN 3339594
1541 Hiroshima JPN 1119117
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
@@ -464,17 +466,17 @@ EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 501 AND 1000 AND Population > 700000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY,Country 4,4,3 NULL # Using sort_intersect(Population,PRIMARY,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range PRIMARY,Population,Country Population 4 NULL # Using index condition; Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country Population,PRIMARY,Country 4,4,3 NULL # Using sort_intersect(Population,PRIMARY,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range PRIMARY,Population,Country Country 3 NULL # Using index condition; Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country Country,PRIMARY 3,4 NULL # Using sort_intersect(Country,PRIMARY); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000
@@ -693,7 +695,7 @@ ID Name Country Population
3808 Austin USA 656562
3809 Baltimore USA 651154
3810 Memphis USA 650100
-SET SESSION sort_buffer_size = 2048;
+SET SESSION sort_buffer_size = IF(@@version_compile_machine like '%64%', 2048, 1536);
EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
@@ -706,7 +708,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
EXPLAIN
diff --git a/mysql-test/main/index_intersect.test b/mysql-test/main/index_intersect.test
index a3fbe0de8b9..26937fd5eef 100644
--- a/mysql-test/main/index_intersect.test
+++ b/mysql-test/main/index_intersect.test
@@ -139,7 +139,7 @@ SELECT * FROM City
--replace_column 9 #
EXPLAIN
SELECT * FROM City
- WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+ WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
--replace_column 7 # 9 #
--replace_result Population,Country,Name Population,Name,Country
@@ -161,11 +161,11 @@ SELECT * FROM City
SELECT * FROM City USE INDEX ()
- WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+ WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
--sorted_result
SELECT * FROM City
- WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+ WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
SELECT * FROM City USE INDEX ()
@@ -275,10 +275,22 @@ SELECT * FROM City USE INDEX ()
SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
AND Country BETWEEN 'S' AND 'Z' ;
+
+# Originally this was just sort_buffer_size=2048. Then, it started
+# failing on 32bit due to different cost number in
+# Unique::get_use_cost() because of sizeof(sizeof(TREE_ELEMENT)+key_size)
+# On 64 bit: Unique object element_size=32, which gives 2048/32= 64 elements
+# in the tree.
+# On 32 bit: Unique object element_size=24.
+# If we want 64 elements in the tree, we need 64*24=1536 as sort_buffer_size.
-SET SESSION sort_buffer_size = 2048;
+# The purpose of setting sort_buffer_size is to show that some of the following
+# explains should use 'index_merge' while others should use range
+# If the following code causes future problems, the other option would be
+# to create a separate result-.diff file for 32 bit.
+SET SESSION sort_buffer_size = IF(@@version_compile_machine like '%64%', 2048, 1536);
# The following EXPLAIN command demonstrate that the execution plans
# may be different if sort_buffer_size is set to a small value
@@ -298,7 +310,7 @@ SELECT * FROM City WHERE
--replace_column 9 #
EXPLAIN
SELECT * FROM City
- WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+ WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
--replace_column 9 #
EXPLAIN
diff --git a/mysql-test/main/index_intersect_innodb.result b/mysql-test/main/index_intersect_innodb.result
index 45f3152fa41..c070b41e54d 100644
--- a/mysql-test/main/index_intersect_innodb.result
+++ b/mysql-test/main/index_intersect_innodb.result
@@ -86,7 +86,7 @@ EXPLAIN
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range Population,Name Population 4 NULL # Using index condition; Using where
+1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
SELECT * FROM City USE INDEX ()
WHERE Name LIKE 'C%' AND Population > 1000000;
ID Name Country Population
@@ -341,8 +341,8 @@ ID Name Country Population
SELECT * FROM City
WHERE Name LIKE 'M%' AND Population > 7000000;
ID Name Country Population
-3580 Moscow RUS 8389200
1024 Mumbai (Bombay) IND 10500000
+3580 Moscow RUS 8389200
SELECT COUNT(*) FROM City WHERE Name BETWEEN 'M' AND 'N';
COUNT(*)
301
@@ -371,12 +371,12 @@ EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'M' AND 'N' AND Population > 1000000 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 Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
+1 SIMPLE City index_merge Population,Country,Name Population,Name,Country 4,35,3 NULL # Using sort_intersect(Population,Name,Country); Using where
EXPLAIN
SELECT * FROM City
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
+1 SIMPLE City index_merge Population,Country,Name Population,Country,Name 4,3,35 NULL # Using sort_intersect(Population,Country,Name); Using where
EXPLAIN
SELECT * FROM City
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
@@ -393,12 +393,14 @@ ID Name Country Population
1810 Montréal CAN 1016376
2259 Medellín COL 1861265
SELECT * FROM City USE INDEX ()
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
ID Name Country Population
+1533 Jokohama [Yokohama] JPN 3339594
1541 Hiroshima JPN 1119117
SELECT * FROM City
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
ID Name Country Population
+1533 Jokohama [Yokohama] JPN 3339594
1541 Hiroshima JPN 1119117
SELECT * FROM City USE INDEX ()
WHERE Name BETWEEN 'G' AND 'K' AND Population > 500000 AND Country LIKE 'C%';
@@ -480,13 +482,13 @@ EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 2001 AND 2500 AND Population > 300000 AND Country LIKE 'H%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range PRIMARY,Population,Country Country 7 NULL # Using index condition; Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3701 AND 4000 AND Population > 1000000
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 PRIMARY,Population 4,4 NULL # Using sort_intersect(PRIMARY,Population); Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country PRIMARY,Population,Country 4,4,7 NULL # Using sort_intersect(PRIMARY,Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 3001 AND 4000 AND Population > 600000
@@ -699,7 +701,7 @@ ID Name Country Population
3808 Austin USA 656562
3809 Baltimore USA 651154
3810 Memphis USA 650100
-SET SESSION sort_buffer_size = 2048;
+SET SESSION sort_buffer_size = IF(@@version_compile_machine like '%64%', 2048, 1536);
EXPLAIN
SELECT * FROM City WHERE
Name LIKE 'C%' AND Population > 1000000;
@@ -712,14 +714,14 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Name Population,Name 4,35 NULL # Using sort_intersect(Population,Name); Using where
EXPLAIN
SELECT * FROM City
-WHERE Name BETWEEN 'G' AND 'J' AND Population > 1000000 AND Country LIKE 'J%';
+WHERE Name BETWEEN 'G' AND 'K' AND Population > 1000000 AND Country LIKE 'J%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City index_merge Population,Country,Name Population,Country 4,3 NULL # Using sort_intersect(Population,Country); Using where
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,Population 35,4 NULL # Using sort_intersect(Name,Population); Using where
+1 SIMPLE City index_merge Population,Country,Name Name,Population,Country 35,4,3 NULL # Using sort_intersect(Name,Population,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE ID BETWEEN 1 AND 500 AND Population > 700000 AND Country LIKE 'C%';
diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result
index da56a3cbb29..c1597e583a4 100644
--- a/mysql-test/main/index_merge_myisam.result
+++ b/mysql-test/main/index_merge_myisam.result
@@ -215,7 +215,7 @@ alter table t2 add index i321(key3, key2, key1);
explain select key3 from t2 where key1 = 100 or key2 = 100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index_merge i1_3,i2_3 i1_3,i2_3 4,4 NULL 2 Using sort_union(i1_3,i2_3); Using where
-explain select key3 from t2 where key1 < 500 or key2 < 500;
+explain select key3 from t2 where key1 < 600 or key2 < 600;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index i1_3,i2_3 i321 12 NULL 1024 Using where; Using index
explain select key7 from t2 where key1 <100 or key2 < 100;
@@ -1475,7 +1475,7 @@ EXPLAIN SELECT t1.f1 FROM t1
WHERE (SELECT COUNT(*) FROM t2 WHERE t2.f3 = 'h' AND t2.f2 = t1.f1) = 0 AND t1.f1 = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
-2 SUBQUERY t2 ref f2,f3 f2 5 const 2 Using where
+2 SUBQUERY t2 ref f2,f3 f3 2 const 2 Using index condition; Using where
DROP TABLE t1,t2;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
diff --git a/mysql-test/main/information_schema_stats.result b/mysql-test/main/information_schema_stats.result
index 8e044bc9f96..352bcbab823 100644
--- a/mysql-test/main/information_schema_stats.result
+++ b/mysql-test/main/information_schema_stats.result
@@ -57,12 +57,12 @@ count(*)
3
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
-test just_a_test PRIMARY 5
+test just_a_test PRIMARY 4
test just_a_test first_name 1
test just_a_test state 2
select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
-test just_a_test 8 5 15
+test just_a_test 7 5 15
drop table just_a_test;
select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test';
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result
index 27cb1657719..ff92b4506ba 100644
--- a/mysql-test/main/innodb_ext_key.result
+++ b/mysql-test/main/innodb_ext_key.result
@@ -1186,7 +1186,7 @@ EXPLAIN
"key_length": "3070",
"used_key_parts": ["f2", "pk1"],
"rows": 1,
- "filtered": 50,
+ "filtered": 100,
"index_condition": "t1.pk1 <= 5 and t1.pk2 <= 5 and t1.f2 = 'abc'",
"attached_condition": "t1.f1 <= '3'"
}
@@ -1216,7 +1216,7 @@ EXPLAIN
"key_length": "3011",
"used_key_parts": ["pk1", "f2", "pk2"],
"rows": 1,
- "filtered": 50,
+ "filtered": 100,
"index_condition": "t1.f2 <= 5 and t1.pk2 <= 5 and t1.pk1 = 'abc'",
"attached_condition": "t1.f1 <= '3'"
}
diff --git a/mysql-test/main/innodb_icp.result b/mysql-test/main/innodb_icp.result
index 4f736f22ab9..16d60ddba43 100644
--- a/mysql-test/main/innodb_icp.result
+++ b/mysql-test/main/innodb_icp.result
@@ -658,7 +658,7 @@ SELECT * FROM t1
WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL b NULL NULL NULL # Using where; Using filesort
+1 SIMPLE t1 range b b 13 NULL # Using where; Rowid-ordered scan; Using filesort
SELECT * FROM t1
WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
ORDER BY a;
@@ -670,7 +670,7 @@ SELECT * FROM t1
WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL b NULL NULL NULL # Using where; Using filesort
+1 SIMPLE t1 range b b 13 NULL # Using index condition; Rowid-ordered scan; Using filesort
SELECT * FROM t1
WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
ORDER BY a;
@@ -682,15 +682,17 @@ DROP TABLE t1;
#
CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b));
INSERT INTO t1 VALUES (1,4,'Ill');
+insert into t1 select seq+100,5,seq from seq_1_to_100;
CREATE TABLE t2 (a varchar(1024), KEY (a(512)));
INSERT INTO t2 VALUES
('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w');
+insert into t2 select seq from seq_1_to_100;
SET SESSION optimizer_switch='index_condition_pushdown=off';
EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 101 Using where; Using filesort
1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
@@ -701,7 +703,7 @@ EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 101 Using where; Using filesort
1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result
index 1a59c7b16e9..e5fa88512b9 100644
--- a/mysql-test/main/join.result
+++ b/mysql-test/main/join.result
@@ -1473,8 +1473,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE DU system dog_id NULL NULL NULL 1
1 SIMPLE D system PRIMARY NULL NULL NULL 1
1 SIMPLE DSAR system NULL NULL NULL NULL 1
-1 SIMPLE DT range t_id t_id 2 NULL 2 Using where
-1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,func 1 Using index
+1 SIMPLE DSA ref PRIMARY PRIMARY 4 const 3 Using where; Using index
+1 SIMPLE DT ALL t_id NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR
WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND
DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id;
diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result
index 290aa492a98..dac621f2564 100644
--- a/mysql-test/main/join_cache.result
+++ b/mysql-test/main/join_cache.result
@@ -5060,8 +5060,8 @@ EXPLAIN
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where
-1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Rowid-ordered scan
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
f1 f3 f3 f2 f4
@@ -5070,8 +5070,8 @@ EXPLAIN
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 2 Using where
-1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Rowid-ordered scan
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
SELECT * FROM t1,t2
WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6);
f1 f3 f3 f2 f4
@@ -6110,7 +6110,7 @@ EXPLAIN
"select_id": 1,
"table": {
"table_name": "a",
- "access_type": "index",
+ "access_type": "range",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "4",
diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result
index 4f6583b6fbc..b323190d8d5 100644
--- a/mysql-test/main/join_nested.result
+++ b/mysql-test/main/join_nested.result
@@ -1284,9 +1284,9 @@ 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 t1 index NULL a 5 NULL 21 Using index
-1 SIMPLE t3 index c c 5 NULL 0 Using where; Using index
-1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
a b c
NULL NULL NULL
diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result
index 3293f20aa17..f7d0242244d 100644
--- a/mysql-test/main/join_nested_jcl6.result
+++ b/mysql-test/main/join_nested_jcl6.result
@@ -1293,9 +1293,9 @@ 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 t1 index NULL a 5 NULL 21 Using index
-1 SIMPLE t3 index c c 5 NULL 0 Using where; Using index
-1 SIMPLE t2 ref b b 5 test.t3.c 2 Using index
SELECT a, b, c FROM t1 LEFT JOIN (t2, t3) ON b < 3 and b = c;
a b c
NULL NULL NULL
@@ -2034,7 +2034,7 @@ ON t6.b >= 2 AND t5.b=t7.b AND
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
1 SIMPLE t7 ref|filter PRIMARY,b_i b_i|PRIMARY 5|4 test.t5.b 2 (29%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter
-1 SIMPLE t6 range PRIMARY,b_i PRIMARY 4 NULL 3 Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join)
+1 SIMPLE t6 range|filter PRIMARY,b_i PRIMARY|b_i 4|5 NULL 3 (86%) Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join); Using rowid filter
1 SIMPLE t8 ref b_i b_i 5 test.t5.b 2 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5
diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result
index 676eb53f830..12f776d47c7 100644
--- a/mysql-test/main/join_outer.result
+++ b/mysql-test/main/join_outer.result
@@ -1740,7 +1740,7 @@ from t1,t2
where t2.pk=t1.pk+1000 and t1.pk>1000
group by t2.pk;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using index; Using temporary; Using filesort
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index; Using temporary; Using filesort
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using index
@@ -2272,11 +2272,11 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1 left join t2 on t2.b 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 b b 5 const 780 Using where
+1 SIMPLE t2 ALL b NULL NULL NULL 1000 Using where
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 393 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/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result
index a0358094baa..5bfcf7f20e1 100644
--- a/mysql-test/main/join_outer_innodb.result
+++ b/mysql-test/main/join_outer_innodb.result
@@ -8,13 +8,13 @@ EXPLAIN
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t1 range PRIMARY,name name 23 NULL 2 Using where; Using index
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index
EXPLAIN
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t1 range PRIMARY,name name 23 NULL 2 Using where; Using index
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index
DROP TABLE t1,t2;
#
@@ -433,47 +433,47 @@ left join t16 on t15.o1 = t16.p1
where t1.a10 = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index
+1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where
+1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 1 test.t1.a7 1
+1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t1.a5 1
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where
1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where
-1 SIMPLE t13 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index
+1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where; Using index
-1 SIMPLE m2 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index
-1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
+1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where
-1 SIMPLE t14 ALL PRIMARY NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index
+1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where
1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where; Using index
1 SIMPLE t16 ref PRIMARY PRIMARY 2 test.t15.o1 1 Using where
1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where
-1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a4,a6,a5,a7 NULL NULL NULL 3 Using where
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index
+1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index
+1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where
+1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index
1 SIMPLE t8 eq_ref PRIMARY PRIMARY 1 test.t1.a4 1 Using index
1 SIMPLE t7 eq_ref PRIMARY PRIMARY 1 test.t1.a7 1
+1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
1 SIMPLE t11 eq_ref PRIMARY PRIMARY 4 test.t1.a5 1
1 SIMPLE t12 eq_ref PRIMARY PRIMARY 4 test.t11.k3 1 Using where
1 SIMPLE l2 eq_ref PRIMARY PRIMARY 4 test.t11.k4 1 Using where
-1 SIMPLE t13 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 Using index
+1 SIMPLE t13 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
1 SIMPLE l4 eq_ref PRIMARY PRIMARY 4 test.t13.m2 1 Using where; Using index
-1 SIMPLE m2 ref PRIMARY,m3 PRIMARY 4 test.t1.a1 1 Using where; Using index
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.b2 1 Using where; Using index
-1 SIMPLE t9 ref PRIMARY PRIMARY 1 test.t1.a4 1
+1 SIMPLE m2 ref PRIMARY,m3 m3 8 const,test.t1.a1 1 Using index
1 SIMPLE l3 eq_ref PRIMARY PRIMARY 4 test.m2.m2 1 Using where
-1 SIMPLE t14 ALL PRIMARY NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 eq_ref PRIMARY PRIMARY 4 test.t1.a2 1 Using index
+1 SIMPLE t14 eq_ref PRIMARY PRIMARY 2 test.t1.a8 1 Using where
1 SIMPLE t15 eq_ref PRIMARY PRIMARY 2 test.t1.a9 1 Using where; Using index
1 SIMPLE t16 ref PRIMARY PRIMARY 2 test.t15.o1 1 Using where
1 SIMPLE t10 ALL PRIMARY NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 eq_ref PRIMARY PRIMARY 4 test.t4.d1 1 Using where
-1 SIMPLE t6 eq_ref PRIMARY PRIMARY 4 test.t1.a3 1 Using where; Using index
drop view v1;
drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16;
#
diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result
index f34078ceeb2..6d4a0284e5a 100644
--- a/mysql-test/main/join_outer_jcl6.result
+++ b/mysql-test/main/join_outer_jcl6.result
@@ -1747,7 +1747,7 @@ from t1,t2
where t2.pk=t1.pk+1000 and t1.pk>1000
group by t2.pk;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 2 50.00 Using where; Using index; Using temporary; Using filesort
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index; Using temporary; Using filesort
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 func 1 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t4 eq_ref PRIMARY PRIMARY 4 test.t3.pk 1 100.00 Using index
@@ -2279,11 +2279,11 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1 left join t2 on t2.b 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 b b 5 const 780 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 SIMPLE t2 ALL b NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join)
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 393 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 SIMPLE t2 ALL c NULL NULL NULL 1000 Using where; Using join buffer (flat, BNL join)
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 12f6c36edd8..996341e1557 100644
--- a/mysql-test/main/key.result
+++ b/mysql-test/main/key.result
@@ -216,7 +216,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
explain select 1 from t1 where id =2 or id=3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
explain select name from t1 where id =2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
@@ -611,7 +611,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+2 SUBQUERY t1 range a a 5 NULL 5 Using where; Using index
SELECT 1 as RES FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
RES
diff --git a/mysql-test/main/key_cache.result b/mysql-test/main/key_cache.result
index b94d05a962f..c8bdc979387 100644
--- a/mysql-test/main/key_cache.result
+++ b/mysql-test/main/key_cache.result
@@ -739,13 +739,13 @@ p
1019
explain select i from t2 where a='yyyy' and i=3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref k1,k2 k1 5 const 189 Using where
+1 SIMPLE t2 index_merge k1,k2 k1,k2 5,11 NULL 50 Using intersect(k1,k2); Using where; Using index
select i from t2 where a='yyyy' and i=3;
i
3
explain select a from t2 where a='yyyy' and i=3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref k1,k2 k1 5 const 189 Using where
+1 SIMPLE t2 index_merge k1,k2 k1,k2 5,11 NULL 50 Using intersect(k1,k2); Using where; Using index
select a from t2 where a='yyyy' and i=3 ;
a
yyyy
@@ -753,7 +753,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 3201 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/limit_rows_examined.result b/mysql-test/main/limit_rows_examined.result
index 0711e10ddde..2c208fd5d4c 100644
--- a/mysql-test/main/limit_rows_examined.result
+++ b/mysql-test/main/limit_rows_examined.result
@@ -255,7 +255,7 @@ select * from t1i
where c1 IN (select * from t2i where c2 > ' ')
LIMIT ROWS EXAMINED 6;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index
+1 PRIMARY t1i range PRIMARY PRIMARY 2 NULL 4 Using where; Using index
1 PRIMARY t2i eq_ref PRIMARY PRIMARY 2 test.t1i.c1 1 Using index
select * from t1i
where c1 IN (select * from t2i where c2 > ' ')
@@ -395,7 +395,7 @@ select * from t1i
where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 17;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1i index NULL PRIMARY 2 NULL 4 Using where; Using index
-2 MATERIALIZED t2i index PRIMARY PRIMARY 2 NULL 4 Using where; Using index
+2 MATERIALIZED t2i range PRIMARY PRIMARY 2 NULL 4 Using where; Using index
select * from t1i
where c1 IN (select * from t2i where c2 > ' ') LIMIT ROWS EXAMINED 17;
c1
diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result
index 7f24cb4896d..2ff966fdfd3 100644
--- a/mysql-test/main/myisam_explain_non_select_all.result
+++ b/mysql-test/main/myisam_explain_non_select_all.result
@@ -3091,12 +3091,11 @@ FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
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 <derived3> ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where 1
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) where `x`.`b` = `test`.`t1`.`a`
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
Handler_read_key 4
@@ -3105,7 +3104,7 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_key 7
-Handler_read_rnd_next 10
+Handler_read_rnd_next 8
Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
@@ -3126,19 +3125,17 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
EXPLAIN UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 FirstMatch(t1)
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3
3 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
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
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
# Status of EXPLAIN EXTENDED query
Variable_name Value
@@ -3147,13 +3144,12 @@ FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
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
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <derived3> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where 1
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where `x`.`b` = `test`.`t1`.`a`
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
Handler_read_key 4
@@ -3162,14 +3158,14 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_key 7
-Handler_read_rnd_next 10
+Handler_read_rnd_next 8
Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
# Status of testing query execution:
Variable_name Value
Handler_read_key 7
-Handler_read_rnd_next 10
+Handler_read_rnd_next 8
Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
@@ -3182,20 +3178,18 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
EXPLAIN UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+1 PRIMARY <derived4> ref key0 key0 5 test.t1.a 2 FirstMatch(t1)
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
-3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 3
4 DERIVED t2 ALL NULL NULL NULL NULL 3 Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 3
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
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 <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <derived4> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00
-3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 3 100.00
4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00
# Status of EXPLAIN EXTENDED query
@@ -3205,13 +3199,12 @@ FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x);
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 <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
+1 PRIMARY <derived4> ref key0 key0 5 test.t1.a 2 100.00 FirstMatch(t1)
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
-3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 3 100.00
4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where 1
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` semi join ((/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x`) join `test`.`t2` where `x`.`b` = `test`.`t1`.`a`
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
Handler_read_key 4
@@ -3220,14 +3213,14 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be
# Status of "equivalent" SELECT query execution:
Variable_name Value
Handler_read_key 7
-Handler_read_rnd_next 10
+Handler_read_rnd_next 8
Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
# Status of testing query execution:
Variable_name Value
Handler_read_key 7
-Handler_read_rnd_next 10
+Handler_read_rnd_next 8
Sort_priority_queue_sorts 1
Sort_rows 3
Sort_scan 1
@@ -3283,7 +3276,7 @@ FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED SELECT a t1 FROM t1 WHERE a>10;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 5 20.00 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `t1` from `test`.`t1` where `test`.`t1`.`a` > 10
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
@@ -3293,9 +3286,7 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Status of "equivalent" SELECT query execution:
Variable_name Value
-Handler_read_first 1
-Handler_read_key 3
-Handler_read_next 5
+Handler_read_key 4
# Status of testing query execution:
Variable_name Value
Handler_read_key 4
@@ -3322,7 +3313,7 @@ FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 5 20.00 Using where; Using index; Using filesort
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using index; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a` AS `t1` from `test`.`t1` where `test`.`t1`.`a` > 10 order by `test`.`t1`.`a` + 20
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
@@ -3332,9 +3323,8 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Status of "equivalent" SELECT query execution:
Variable_name Value
-Handler_read_key 3
-Handler_read_rnd_next 6
-Sort_scan 1
+Handler_read_key 4
+Sort_range 1
# Status of testing query execution:
Variable_name Value
Handler_read_key 4
diff --git a/mysql-test/main/myisam_icp.result b/mysql-test/main/myisam_icp.result
index 434bb4eca43..0ae18e6e817 100644
--- a/mysql-test/main/myisam_icp.result
+++ b/mysql-test/main/myisam_icp.result
@@ -407,7 +407,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240
ORDER BY c1
LIMIT 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY,k1 PRIMARY 4 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort
+1 SIMPLE t1 range|filter PRIMARY,k1 PRIMARY|k1 4|5 NULL 3 (50%) Using index condition; Using where; Rowid-ordered scan; Using filesort; Using rowid filter
DROP TABLE t1;
#
#
@@ -506,7 +506,7 @@ WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan
-1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
@@ -675,16 +675,18 @@ DROP TABLE t1;
#
CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b));
INSERT INTO t1 VALUES (1,4,'Ill');
+insert into t1 select seq+100,5,seq from seq_1_to_100;
CREATE TABLE t2 (a varchar(1024), KEY (a(512)));
INSERT INTO t2 VALUES
('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w');
+insert into t2 select seq from seq_1_to_100;
SET SESSION optimizer_switch='index_condition_pushdown=off';
EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
-1 SIMPLE t2 ref a a 515 const 1 Using where
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 101 Using where; Using filesort
+1 SIMPLE t2 ref a a 515 test.t1.a 10 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
b c
@@ -694,8 +696,8 @@ EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
-1 SIMPLE t2 ref a a 515 const 1 Using where
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 101 Using where; Using filesort
+1 SIMPLE t2 ref a a 515 test.t1.a 10 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
b c
diff --git a/mysql-test/main/negation_elimination.result b/mysql-test/main/negation_elimination.result
index f9be5b55e46..7b9a76d86b2 100644
--- a/mysql-test/main/negation_elimination.result
+++ b/mysql-test/main/negation_elimination.result
@@ -4,7 +4,7 @@ insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
explain select * from t1 where not(not(a));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
select * from t1 where not(not(a));
a
1
@@ -55,7 +55,7 @@ a
10
explain select * from t1 where not(a = 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 19 Using where; Using index
select * from t1 where not(a = 10);
a
0
@@ -145,7 +145,7 @@ a
19
explain select * from t1 where not(a is null);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
select * from t1 where not(a is null);
a
0
@@ -192,7 +192,7 @@ a
15
explain select * from t1 where not(a < 15 and a > 5);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
select * from t1 where not(a < 15 and a > 5);
a
0
@@ -208,7 +208,7 @@ a
19
explain select * from t1 where a = 2 or not(a < 10);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
select * from t1 where a = 2 or not(a < 10);
a
2
@@ -255,7 +255,7 @@ a
19
explain select * from t1 where a = 2 or not(a < 5 or a > 15);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
select * from t1 where a = 2 or not(a < 5 or a > 15);
a
2
@@ -272,7 +272,7 @@ a
15
explain select * from t1 where a = 7 or not(a < 15 and a > 5);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
select * from t1 where a = 7 or not(a < 15 and a > 5);
a
0
@@ -289,7 +289,7 @@ a
19
explain select * from t1 where NULL or not(a < 15 and a > 5);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 21 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
select * from t1 where NULL or not(a < 15 and a > 5);
a
0
@@ -500,7 +500,7 @@ NULL NULL
3 1
explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 index a a 5 NULL 5 80.00 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 4 100.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a` <> 0 AS `not(not(a))`,`test`.`t1`.`a` > 2 or `test`.`t1`.`a` <> 0 AS `not(a <= 2 and not(a))`,`test`.`t1`.`a` like '1' AS `not(a not like "1")`,`test`.`t1`.`a` in (1,2) AS `not (a not in (1,2))`,`test`.`t1`.`a` = 2 AS `not(a != 2)` from `test`.`t1` where `test`.`t1`.`a` <> 0 having `test`.`t1`.`a` <> 0
drop table t1;
diff --git a/mysql-test/main/null_key.result b/mysql-test/main/null_key.result
index 55b2060475f..6b9d59c636a 100644
--- a/mysql-test/main/null_key.result
+++ b/mysql-test/main/null_key.result
@@ -20,7 +20,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 9 NULL 12 Using where; Using index
explain select * from t1 where (a is null or a > 0 and a < 2) and b < 5 limit 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a,b a 9 NULL 12 Using where; Using index
+1 SIMPLE t1 range a,b a 9 NULL 2 Using where; Using index
explain select * from t1 where (a is null or a = 7) and b=7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref_or_null a,b a 9 const,const 2 Using where; Using index
@@ -32,7 +32,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a,b a 5 const 3 Using where; Using index
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref a,b a 5 const 2 Using where; Using index
+1 SIMPLE t1 range a,b a 9 NULL 3 Using where; Using index
explain select * from t1 where a > 1 and a < 3 limit 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index
@@ -160,7 +160,7 @@ a b
7 NULL
explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref_or_null a,b a 5 const 4 Using where; Using index
+1 SIMPLE t1 ref_or_null a,b a 5 const 5 Using where; Using index
select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
a b
7 NULL
@@ -194,7 +194,7 @@ a a b
explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 4 Using where; Using index
+1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 5 Using where; Using index
select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
a a b
7 7 7
@@ -204,7 +204,7 @@ a a b
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
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 ref_or_null a a 10 test.t2.a,const 4 Using where; Using index
+1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 5 Using where; Using index
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
a a b
7 7 7
@@ -214,7 +214,7 @@ a a b
explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
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 ref_or_null a a 5 test.t2.a 4 Using where; Using index
+1 SIMPLE t1 ref_or_null a a 5 test.t2.a 5 Using where; Using index
select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
a a b
7 7 NULL
@@ -261,7 +261,7 @@ INSERT INTO t1 VALUES (11,5),(12,6),(13,7),(14,8),(15,9);
INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
explain select id from t1 where uniq_id is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1 idx1 5 const 6 Using index condition
+1 SIMPLE t1 ALL idx1 NULL NULL NULL 15 Using where
explain select id from t1 where uniq_id =1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const idx1 idx1 5 const 1
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result
index f572deca84d..65fc7d6cc98 100644
--- a/mysql-test/main/opt_trace.result
+++ b/mysql-test/main/opt_trace.result
@@ -1022,7 +1022,7 @@ 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": 200,
+ "cost": 200.06,
"chosen": true
},
{
@@ -1035,13 +1035,13 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"chosen_access_method": {
"type": "ref",
"records": 1,
- "cost": 200,
+ "cost": 200.06,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 242.32,
+ "cost_for_plan": 242.38,
"estimated_join_cardinality": 100
}
]
@@ -1080,7 +1080,7 @@ 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": 200,
+ "cost": 200.06,
"chosen": true
},
{
@@ -1093,13 +1093,13 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"chosen_access_method": {
"type": "ref",
"records": 1,
- "cost": 200,
+ "cost": 200.06,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 100,
- "cost_for_plan": 242.32,
+ "cost_for_plan": 242.38,
"pruned_by_cost": true
}
]
@@ -1199,8 +1199,9 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 4812.5,
- "chosen": true
+ "cost": 13377,
+ "chosen": false,
+ "cause": "cost"
},
"group_index_range": {
"distinct_query": true,
@@ -1209,7 +1210,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"index": "a",
"covering": true,
"rows": 5,
- "cost": 6.75
+ "cost": 6.25
}
]
},
@@ -1221,7 +1222,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 5,
- "cost": 6.75,
+ "cost": 6.25,
"key_parts_used_for_access": ["a"],
"ranges": [],
"chosen": true
@@ -1235,12 +1236,12 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"max_aggregate": false,
"distinct_aggregate": false,
"rows": 5,
- "cost": 6.75,
+ "cost": 6.25,
"key_parts_used_for_access": ["a"],
"ranges": []
},
"rows_for_plan": 5,
- "cost_for_plan": 6.75,
+ "cost_for_plan": 6.25,
"chosen": true
}
}
@@ -1257,20 +1258,20 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
{
"access_type": "index_merge",
"resulting_rows": 5,
- "cost": 6.75,
+ "cost": 6.25,
"chosen": true
}
],
"chosen_access_method": {
"type": "index_merge",
"records": 5,
- "cost": 6.75,
+ "cost": 6.25,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 5,
- "cost_for_plan": 7.75,
+ "cost_for_plan": 7.25,
"estimated_join_cardinality": 5
}
]
@@ -1313,7 +1314,7 @@ 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 index NULL a 20 NULL 7 Using where; Using index
+1 SIMPLE t1 range NULL a 20 NULL 8 Using where; Using index for group-by
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 {
@@ -1372,7 +1373,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"range_analysis": {
"table_scan": {
"rows": 7,
- "cost": 5.5291
+ "cost": 5.4291
},
"potential_range_indexes": [
{
@@ -1383,7 +1384,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 1.3869,
+ "cost": 2.4092,
"chosen": true
},
"setup_range_conditions": [],
@@ -1416,24 +1417,26 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"cost": 2.2,
"key_parts_used_for_access": ["a", "b", "c"],
"ranges": ["(2,3) <= (b,c) <= (2,3)"],
- "chosen": false,
- "cause": "cost"
- }
- }
- },
- {
- "selectivity_for_indexes": [],
- "selectivity_for_columns": [
- {
- "column_name": "b",
- "selectivity_from_histogram": 0.2891
+ "chosen": true
},
- {
- "column_name": "c",
- "selectivity_from_histogram": 0.2891
+ "chosen_range_access_summary": {
+ "range_access_plan": {
+ "type": "index_group",
+ "index": "a",
+ "min_max_arg": "d",
+ "min_aggregate": true,
+ "max_aggregate": false,
+ "distinct_aggregate": false,
+ "rows": 8,
+ "cost": 2.2,
+ "key_parts_used_for_access": ["a", "b", "c"],
+ "ranges": ["(2,3) <= (b,c) <= (2,3)"]
+ },
+ "rows_for_plan": 8,
+ "cost_for_plan": 2.2,
+ "chosen": true
}
- ],
- "cond_selectivity": 0.0836
+ }
}
]
},
@@ -1445,24 +1448,24 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
"best_access_path": {
"considered_access_paths": [
{
- "access_type": "scan",
- "resulting_rows": 0.5849,
- "cost": 3.3121,
+ "access_type": "index_merge",
+ "resulting_rows": 8,
+ "cost": 2.2,
"chosen": true,
"use_tmp_table": true
}
],
"chosen_access_method": {
- "type": "scan",
- "records": 0.5849,
- "cost": 3.3121,
+ "type": "index_merge",
+ "records": 8,
+ "cost": 2.2,
"uses_join_buffering": false,
"filter_used": false
}
},
- "rows_for_plan": 0.5849,
- "cost_for_plan": 3.4291,
- "estimated_join_cardinality": 0.5849
+ "rows_for_plan": 8,
+ "cost_for_plan": 3.8,
+ "estimated_join_cardinality": 8
}
]
},
@@ -1480,25 +1483,6 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
}
]
}
- },
- {
- "reconsidering_access_paths_for_index_ordering": {
- "clause": "GROUP BY",
- "fanout": 1,
- "read_time": 3.3131,
- "table": "t1",
- "rows_estimation": 7,
- "possible_keys": [
- {
- "index": "a",
- "can_resolve_order": true,
- "updated_limit": 7,
- "index_scan_time": 7,
- "records": 7,
- "chosen": true
- }
- ]
- }
}
]
}
@@ -1524,7 +1508,7 @@ INSERT INTO t1 values (1,'2001-01-01'),(1,'2001-01-02'),
set optimizer_trace='enabled=on';
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
+1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
@@ -1583,7 +1567,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"range_analysis": {
"table_scan": {
"rows": 16,
- "cost": 7.3313
+ "cost": 7.2313
},
"potential_range_indexes": [
{
@@ -1594,7 +1578,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
],
"best_covering_index_scan": {
"index": "id",
- "cost": 1.8468,
+ "cost": 4.2117,
"chosen": true
},
"setup_range_conditions": [],
@@ -1627,15 +1611,26 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"cost": 2.35,
"key_parts_used_for_access": ["id"],
"ranges": ["(2001-01-04) <= (a)"],
- "chosen": false,
- "cause": "cost"
+ "chosen": true
+ },
+ "chosen_range_access_summary": {
+ "range_access_plan": {
+ "type": "index_group",
+ "index": "id",
+ "min_max_arg": "a",
+ "min_aggregate": true,
+ "max_aggregate": true,
+ "distinct_aggregate": false,
+ "rows": 9,
+ "cost": 2.35,
+ "key_parts_used_for_access": ["id"],
+ "ranges": ["(2001-01-04) <= (a)"]
+ },
+ "rows_for_plan": 9,
+ "cost_for_plan": 2.35,
+ "chosen": true
}
}
- },
- {
- "selectivity_for_indexes": [],
- "selectivity_for_columns": [],
- "cond_selectivity": 1
}
]
},
@@ -1647,24 +1642,24 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
"best_access_path": {
"considered_access_paths": [
{
- "access_type": "scan",
- "resulting_rows": 16,
- "cost": 2.0312,
+ "access_type": "index_merge",
+ "resulting_rows": 9,
+ "cost": 2.35,
"chosen": true,
"use_tmp_table": true
}
],
"chosen_access_method": {
- "type": "scan",
- "records": 16,
- "cost": 2.0312,
+ "type": "index_merge",
+ "records": 9,
+ "cost": 2.35,
"uses_join_buffering": false,
"filter_used": false
}
},
- "rows_for_plan": 16,
- "cost_for_plan": 5.2313,
- "estimated_join_cardinality": 16
+ "rows_for_plan": 9,
+ "cost_for_plan": 4.15,
+ "estimated_join_cardinality": 9
}
]
},
@@ -1682,25 +1677,6 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
}
]
}
- },
- {
- "reconsidering_access_paths_for_index_ordering": {
- "clause": "GROUP BY",
- "fanout": 1,
- "read_time": 2.0322,
- "table": "t1",
- "rows_estimation": 9,
- "possible_keys": [
- {
- "index": "id",
- "can_resolve_order": true,
- "updated_limit": 16,
- "index_scan_time": 16,
- "records": 16,
- "chosen": true
- }
- ]
- }
}
]
}
@@ -1715,7 +1691,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
} 0 0
EXPLAIN SELECT * 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
+1 SIMPLE t1 range NULL id 8 NULL 9 Using where; Using index for group-by
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
@@ -1774,7 +1750,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"range_analysis": {
"table_scan": {
"rows": 16,
- "cost": 7.3313
+ "cost": 7.2313
},
"potential_range_indexes": [
{
@@ -1785,7 +1761,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
],
"best_covering_index_scan": {
"index": "id",
- "cost": 1.8468,
+ "cost": 4.2117,
"chosen": true
},
"setup_range_conditions": [],
@@ -1818,15 +1794,26 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"cost": 2.35,
"key_parts_used_for_access": ["id", "a"],
"ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"],
- "chosen": false,
- "cause": "cost"
+ "chosen": true
+ },
+ "chosen_range_access_summary": {
+ "range_access_plan": {
+ "type": "index_group",
+ "index": "id",
+ "min_max_arg": null,
+ "min_aggregate": false,
+ "max_aggregate": false,
+ "distinct_aggregate": false,
+ "rows": 9,
+ "cost": 2.35,
+ "key_parts_used_for_access": ["id", "a"],
+ "ranges": ["(2001-01-04) <= (a) <= (2001-01-04)"]
+ },
+ "rows_for_plan": 9,
+ "cost_for_plan": 2.35,
+ "chosen": true
}
}
- },
- {
- "selectivity_for_indexes": [],
- "selectivity_for_columns": [],
- "cond_selectivity": 1
}
]
},
@@ -1838,24 +1825,24 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
"best_access_path": {
"considered_access_paths": [
{
- "access_type": "scan",
- "resulting_rows": 16,
- "cost": 2.0312,
+ "access_type": "index_merge",
+ "resulting_rows": 9,
+ "cost": 2.35,
"chosen": true,
"use_tmp_table": true
}
],
"chosen_access_method": {
- "type": "scan",
- "records": 16,
- "cost": 2.0312,
+ "type": "index_merge",
+ "records": 9,
+ "cost": 2.35,
"uses_join_buffering": false,
"filter_used": false
}
},
- "rows_for_plan": 16,
- "cost_for_plan": 5.2313,
- "estimated_join_cardinality": 16
+ "rows_for_plan": 9,
+ "cost_for_plan": 4.15,
+ "estimated_join_cardinality": 9
}
]
},
@@ -1873,25 +1860,6 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
}
]
}
- },
- {
- "reconsidering_access_paths_for_index_ordering": {
- "clause": "GROUP BY",
- "fanout": 1,
- "read_time": 2.0322,
- "table": "t1",
- "rows_estimation": 9,
- "possible_keys": [
- {
- "index": "id",
- "can_resolve_order": true,
- "updated_limit": 16,
- "index_scan_time": 16,
- "records": 16,
- "chosen": true
- }
- ]
- }
}
]
}
@@ -2011,7 +1979,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"range_analysis": {
"table_scan": {
"rows": 1000,
- "cost": 232.66
+ "cost": 232.56
},
"potential_range_indexes": [
{
@@ -2040,7 +2008,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"using_mrr": false,
"index_only": false,
"rows": 180,
- "cost": 229.72,
+ "cost": 216.29,
"chosen": true
},
{
@@ -2050,7 +2018,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"using_mrr": false,
"index_only": false,
"rows": 21,
- "cost": 27.445,
+ "cost": 25.362,
"chosen": true
}
],
@@ -2071,7 +2039,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": 21,
- "cost_for_plan": 27.445,
+ "cost_for_plan": 25.362,
"chosen": true
}
}
@@ -2109,7 +2077,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": 92,
+ "cost": 180.27,
"chosen": true
},
{
@@ -2117,7 +2085,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"index": "a_b",
"used_range_estimates": true,
"rows": 21,
- "cost": 22,
+ "cost": 21.142,
"chosen": true
},
{
@@ -2129,13 +2097,13 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"chosen_access_method": {
"type": "ref",
"records": 21,
- "cost": 22,
+ "cost": 21.142,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 21,
- "cost_for_plan": 26.2,
+ "cost_for_plan": 25.342,
"estimated_join_cardinality": 21
}
]
@@ -2159,7 +2127,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"reconsidering_access_paths_for_index_ordering": {
"clause": "ORDER BY",
"fanout": 1,
- "read_time": 22.001,
+ "read_time": 21.143,
"table": "t1",
"rows_estimation": 21,
"possible_keys": [
@@ -2175,8 +2143,8 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"index": "a_c",
"can_resolve_order": true,
"updated_limit": 47,
- "range_scan_time": 4.324,
- "index_scan_time": 4.324,
+ "range_scan_time": 4.331,
+ "index_scan_time": 4.331,
"records": 180,
"chosen": true
},
@@ -2222,7 +2190,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"using_mrr": false,
"index_only": false,
"rows": 180,
- "cost": 229.72,
+ "cost": 216.29,
"chosen": true
}
],
@@ -2243,7 +2211,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": 229.72,
+ "cost_for_plan": 216.29,
"chosen": true
}
}
@@ -3174,7 +3142,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 6.1317
+ "cost": 6.0317
},
"potential_range_indexes": [
{
@@ -3195,7 +3163,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
],
"best_covering_index_scan": {
"index": "pk_a_b",
- "cost": 1.5429,
+ "cost": 3.0107,
"chosen": true
},
"setup_range_conditions": [],
@@ -3208,9 +3176,8 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3773,
- "chosen": false,
- "cause": "cost"
+ "cost": 1.3456,
+ "chosen": true
},
{
"index": "pk_a",
@@ -3219,7 +3186,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3783,
+ "cost": 1.3458,
"chosen": false,
"cause": "cost"
},
@@ -3230,7 +3197,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 1.1793,
+ "cost": 0.3461,
"chosen": true
}
],
@@ -3238,10 +3205,10 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"intersecting_indexes": [
{
"index": "pk",
- "index_scan_cost": 1.0023,
- "cumulated_index_scan_cost": 1.0023,
+ "index_scan_cost": 1.0006,
+ "cumulated_index_scan_cost": 1.0006,
"disk_sweep_cost": 0.9008,
- "cumulative_total_cost": 1.9031,
+ "cumulative_total_cost": 1.9014,
"usable": true,
"matching_rows_now": 1,
"intersect_covering_with_this_index": false,
@@ -3279,7 +3246,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": 1.1793,
+ "cost_for_plan": 0.3461,
"chosen": true
}
}
@@ -3317,7 +3284,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"index": "pk",
"used_range_estimates": true,
"rows": 1,
- "cost": 2,
+ "cost": 1.1256,
"chosen": true
},
{
@@ -3325,7 +3292,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"index": "pk_a",
"used_range_estimates": true,
"rows": 1,
- "cost": 2,
+ "cost": 1.1258,
"chosen": false,
"cause": "cost"
},
@@ -3334,7 +3301,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": 1.0043,
+ "cost": 0.1261,
"chosen": true
},
{
@@ -3346,13 +3313,13 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
"chosen_access_method": {
"type": "ref",
"records": 1,
- "cost": 1.0043,
+ "cost": 0.1261,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 1.2043,
+ "cost_for_plan": 0.3261,
"estimated_join_cardinality": 1
}
]
@@ -3671,7 +3638,7 @@ explain delete from t0 where t0.a<3 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 6.122
+ "cost": 6.022
},
"potential_range_indexes": [
{
@@ -3690,7 +3657,7 @@ explain delete from t0 where t0.a<3 {
"using_mrr": false,
"index_only": false,
"rows": 3,
- "cost": 5.007,
+ "cost": 3.7468,
"chosen": true
}
],
@@ -3708,7 +3675,7 @@ explain delete from t0 where t0.a<3 {
"ranges": ["(NULL) < (a) < (3)"]
},
"rows_for_plan": 3,
- "cost_for_plan": 5.007,
+ "cost_for_plan": 3.7468,
"chosen": true
}
}
@@ -3809,7 +3776,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 6.122
+ "cost": 6.022
},
"potential_range_indexes": [
{
@@ -3820,7 +3787,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 1.5234,
+ "cost": 3.0059,
"chosen": true
},
"setup_range_conditions": [],
@@ -3833,7 +3800,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.407,
+ "cost": 0.7468,
"chosen": true
}
],
@@ -3854,7 +3821,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.407,
+ "cost_for_plan": 0.7468,
"chosen": true
}
}
@@ -3874,7 +3841,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"range_analysis": {
"table_scan": {
"rows": 10,
- "cost": 6.122
+ "cost": 6.022
},
"potential_range_indexes": [
{
@@ -3885,7 +3852,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
],
"best_covering_index_scan": {
"index": "a",
- "cost": 1.5234,
+ "cost": 3.0059,
"chosen": true
},
"setup_range_conditions": [],
@@ -3898,7 +3865,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.407,
+ "cost": 0.7468,
"chosen": true
}
],
@@ -3919,7 +3886,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.407,
+ "cost_for_plan": 0.7468,
"chosen": true
}
}
@@ -3946,20 +3913,20 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
{
"access_type": "range",
"resulting_rows": 3,
- "cost": 1.407,
+ "cost": 0.7468,
"chosen": true
}
],
"chosen_access_method": {
"type": "range",
"records": 3,
- "cost": 1.407,
+ "cost": 0.7468,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 2.007,
+ "cost_for_plan": 1.3468,
"rest_of_plan": [
{
"plan_prefix": ["t0"],
@@ -3972,7 +3939,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": 3.007,
+ "cost": 3.0018,
"chosen": true
},
{
@@ -3984,13 +3951,13 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"chosen_access_method": {
"type": "ref",
"records": 1,
- "cost": 3.007,
+ "cost": 3.0018,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 5.614,
+ "cost_for_plan": 4.9485,
"estimated_join_cardinality": 3
}
]
@@ -4003,20 +3970,20 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
{
"access_type": "range",
"resulting_rows": 3,
- "cost": 1.407,
+ "cost": 0.7468,
"chosen": true
}
],
"chosen_access_method": {
"type": "range",
"records": 3,
- "cost": 1.407,
+ "cost": 0.7468,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 3,
- "cost_for_plan": 2.007,
+ "cost_for_plan": 1.3468,
"rest_of_plan": [
{
"plan_prefix": ["t1"],
@@ -4029,7 +3996,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": 3.014,
+ "cost": 3.0035,
"chosen": true
},
{
@@ -4041,13 +4008,13 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"chosen_access_method": {
"type": "ref",
"records": 2,
- "cost": 3.014,
+ "cost": 3.0035,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 6,
- "cost_for_plan": 6.2211,
+ "cost_for_plan": 5.5503,
"pruned_by_cost": true
}
]
@@ -7534,7 +7501,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 1,
- "cost": 1.1783,
+ "cost": 0.3458,
"chosen": true
}
],
@@ -7568,7 +7535,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 107,
- "cost": 8.9549,
+ "cost": 21.634,
"chosen": true
}
],
@@ -7605,7 +7572,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1000,
- "cost": 1273.2,
+ "cost": 1203.9,
"chosen": true
}
],
@@ -7650,7 +7617,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 4,
- "cost": 6.2648,
+ "cost": 4.9487,
"chosen": true
}
],
@@ -7689,7 +7656,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3797,
+ "cost": 1.3462,
"chosen": true
}
],
@@ -7723,7 +7690,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3797,
+ "cost": 1.3462,
"chosen": true
}
],
@@ -7765,7 +7732,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3787,
+ "cost": 1.3459,
"chosen": true
}
],
@@ -7800,7 +7767,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3785,
+ "cost": 1.3459,
"chosen": true
}
],
@@ -7835,7 +7802,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3787,
+ "cost": 1.3459,
"chosen": true
}
],
@@ -7873,7 +7840,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3785,
+ "cost": 1.3459,
"chosen": true
}
],
@@ -7914,7 +7881,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 3.5719,
+ "cost": 1.3943,
"chosen": true
}
],
@@ -7953,7 +7920,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2,
- "cost": 3.6324,
+ "cost": 2.5469,
"chosen": true
}
],
@@ -8009,7 +7976,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1000,
- "cost": 1273.2,
+ "cost": 1203.9,
"chosen": true
}
],
@@ -8218,7 +8185,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"used_range_estimates": false,
"cause": "not available",
"rows": 1,
- "cost": 20,
+ "cost": 20.006,
"chosen": true
},
@@ -8233,13 +8200,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
{
"type": "ref",
"records": 1,
- "cost": 20,
+ "cost": 20.006,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 10,
- "cost_for_plan": 26.017,
+ "cost_for_plan": 26.023,
"selectivity": 0.8047,
"estimated_join_cardinality": 8.0469
}
@@ -8307,7 +8274,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.4265,
+ "cost": 1.3579,
"chosen": true
}
],
diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result
index 81ba04db5cb..ca8098391d5 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": 231.69
+ "cost": 231.59
},
"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": 1.1773,
+ "cost": 0.3456,
"chosen": true
}
],
"index_to_merge": "a",
- "cumulated_cost": 1.1773
+ "cumulated_cost": 0.3456
},
{
"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": 1.1773,
+ "cost": 0.3456,
"chosen": true
}
],
"index_to_merge": "b",
- "cumulated_cost": 2.3547
+ "cumulated_cost": 0.6912
}
],
- "cost_of_reading_ranges": 2.3547,
+ "cost_of_reading_ranges": 0.6912,
"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": 4.1484,
+ "index_roworder_union_cost": 2.4849,
"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": 4.1484,
+ "cost_for_plan": 2.4849,
"chosen": true
}
}
@@ -209,20 +209,20 @@ explain select * from t1 where a=1 or b=1 {
{
"access_type": "index_merge",
"resulting_rows": 2,
- "cost": 4.1484,
+ "cost": 2.4849,
"chosen": true
}
],
"chosen_access_method": {
"type": "index_merge",
"records": 2,
- "cost": 4.1484,
+ "cost": 2.4849,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 2,
- "cost_for_plan": 4.5484,
+ "cost_for_plan": 2.8849,
"estimated_join_cardinality": 2
}
]
@@ -323,7 +323,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2243,
- "cost": 2844.1,
+ "cost": 2700.1,
"chosen": true
},
@@ -337,7 +337,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2243,
- "cost": 2844.1,
+ "cost": 2700.1,
"chosen": false,
"cause": "cost"
},
@@ -352,7 +352,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": false,
"rows": 2243,
- "cost": 2844.1,
+ "cost": 2700.1,
"chosen": false,
"cause": "cost"
}
@@ -364,10 +364,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key1",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 58.252,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 10.314,
"disk_sweep_cost": 1923.1,
- "cumulative_total_cost": 1981.4,
+ "cumulative_total_cost": 1933.5,
"usable": true,
"matching_rows_now": 2243,
"intersect_covering_with_this_index": false,
@@ -376,10 +376,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key2",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 116.5,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 20.628,
"disk_sweep_cost": 84.518,
- "cumulative_total_cost": 201.02,
+ "cumulative_total_cost": 105.15,
"usable": true,
"matching_rows_now": 77.636,
"intersect_covering_with_this_index": false,
@@ -388,10 +388,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key3",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 174.76,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 30.942,
"disk_sweep_cost": 0,
- "cumulative_total_cost": 174.76,
+ "cumulative_total_cost": 30.942,
"usable": true,
"matching_rows_now": 2.6872,
"intersect_covering_with_this_index": true,
@@ -404,7 +404,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index"
},
"rows": 2,
- "cost": 174.76,
+ "cost": 30.942,
"covering": true,
"chosen": true
},
@@ -422,7 +422,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{
"type": "index_roworder_intersect",
"rows": 2,
- "cost": 174.76,
+ "cost": 30.942,
"covering": true,
"clustered_pk_scan": false,
"intersect_of":
@@ -460,7 +460,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
]
},
"rows_for_plan": 2,
- "cost_for_plan": 174.76,
+ "cost_for_plan": 30.942,
"chosen": true
}
]
@@ -501,7 +501,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 152.53,
+ "cost": 457.06,
"chosen": true
},
@@ -515,13 +515,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 152.53,
+ "cost": 457.06,
"chosen": false,
"cause": "cost"
}
],
"index_to_merge": "key1",
- "cumulated_cost": 152.53
+ "cumulated_cost": 457.06
},
{
@@ -538,7 +538,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 152.53,
+ "cost": 457.06,
"chosen": true
},
@@ -552,16 +552,16 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"using_mrr": false,
"index_only": true,
"rows": 2243,
- "cost": 152.53,
+ "cost": 457.06,
"chosen": false,
"cause": "cost"
}
],
"index_to_merge": "key3",
- "cumulated_cost": 305.05
+ "cumulated_cost": 914.12
}
],
- "cost_of_reading_ranges": 305.05,
+ "cost_of_reading_ranges": 914.12,
"use_roworder_union": true,
"cause": "always cheaper than non roworder retrieval",
"analyzing_roworder_scans":
@@ -582,10 +582,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key1",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 58.252,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 10.314,
"disk_sweep_cost": 1923.1,
- "cumulative_total_cost": 1981.4,
+ "cumulative_total_cost": 1933.5,
"usable": true,
"matching_rows_now": 2243,
"intersect_covering_with_this_index": false,
@@ -594,10 +594,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key2",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 116.5,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 20.628,
"disk_sweep_cost": 84.518,
- "cumulative_total_cost": 201.02,
+ "cumulative_total_cost": 105.15,
"usable": true,
"matching_rows_now": 77.636,
"intersect_covering_with_this_index": false,
@@ -610,7 +610,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index"
},
"rows": 77,
- "cost": 201.02,
+ "cost": 105.15,
"covering": false,
"chosen": true
}
@@ -631,10 +631,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key3",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 58.252,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 10.314,
"disk_sweep_cost": 1923.1,
- "cumulative_total_cost": 1981.4,
+ "cumulative_total_cost": 1933.5,
"usable": true,
"matching_rows_now": 2243,
"intersect_covering_with_this_index": false,
@@ -643,10 +643,10 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
{
"index": "key4",
- "index_scan_cost": 58.252,
- "cumulated_index_scan_cost": 116.5,
+ "index_scan_cost": 10.314,
+ "cumulated_index_scan_cost": 20.628,
"disk_sweep_cost": 84.518,
- "cumulative_total_cost": 201.02,
+ "cumulative_total_cost": 105.15,
"usable": true,
"matching_rows_now": 77.636,
"intersect_covering_with_this_index": false,
@@ -659,13 +659,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
"cause": "no clustered pk index"
},
"rows": 77,
- "cost": 201.02,
+ "cost": 105.15,
"covering": false,
"chosen": true
}
}
],
- "index_roworder_union_cost": 386.73,
+ "index_roworder_union_cost": 194.98,
"members": 2,
"chosen": true
}
@@ -686,7 +686,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{
"type": "index_roworder_intersect",
"rows": 77,
- "cost": 201.02,
+ "cost": 105.15,
"covering": false,
"clustered_pk_scan": false,
"intersect_of":
@@ -717,7 +717,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
{
"type": "index_roworder_intersect",
"rows": 77,
- "cost": 201.02,
+ "cost": 105.15,
"covering": false,
"clustered_pk_scan": false,
"intersect_of":
@@ -747,7 +747,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.chosen_range_access_summary'))
]
},
"rows_for_plan": 154,
- "cost_for_plan": 386.73,
+ "cost_for_plan": 194.98,
"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 b90c7098ac9..fd5780cc64c 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": 206.1
+ "cost": 206
},
"potential_range_indexes": [
{
@@ -117,7 +117,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"using_mrr": false,
"index_only": false,
"rows": 1000,
- "cost": 203.39,
+ "cost": 201.65,
"chosen": true
},
{
@@ -127,7 +127,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"using_mrr": false,
"index_only": false,
"rows": 1,
- "cost": 2.3751,
+ "cost": 1.3451,
"chosen": true
}
],
@@ -150,7 +150,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"cause": "cost"
},
"chosen": false,
- "cause": "too few indexes to merge"
+ "cause": "cost"
},
"analyzing_index_merge_union": []
},
@@ -166,7 +166,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"ranges": ["(1) <= (key1) <= (1)"]
},
"rows_for_plan": 1,
- "cost_for_plan": 2.3751,
+ "cost_for_plan": 1.3451,
"chosen": true
}
}
@@ -199,7 +199,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"index": "key1",
"used_range_estimates": true,
"rows": 1,
- "cost": 2,
+ "cost": 1.1251,
"chosen": true
},
{
@@ -211,13 +211,13 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"chosen_access_method": {
"type": "ref",
"records": 1,
- "cost": 2,
+ "cost": 1.1251,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 1,
- "cost_for_plan": 2.2,
+ "cost_for_plan": 1.3251,
"estimated_join_cardinality": 1
}
]
diff --git a/mysql-test/main/opt_trace_ucs2.result b/mysql-test/main/opt_trace_ucs2.result
index 306fdbf94ad..0d920341bcd 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": 3.7609,
+ "cost": 2.5477,
"chosen": true
}
],
diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result
index a68e70e8a25..9752aa71bfb 100644
--- a/mysql-test/main/opt_tvc.result
+++ b/mysql-test/main/opt_tvc.result
@@ -568,18 +568,18 @@ explain extended select * from t1
where (a,b) not in ((1,2),(8,9), (5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
+2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`_col_1` and `test`.`t1`.`b` = `<subquery2>`.`_col_2`))))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond(<cache>(`test`.`t1`.`b`) = `tvc_0`.`_col_2`)))))
explain extended select * from t1
where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
+2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`1` and `test`.`t1`.`b` = `<subquery2>`.`2`))))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t1`.`a`) = `tvc_0`.`1`) and trigcond(<cache>(`test`.`t1`.`b`) = `tvc_0`.`2`)))))
select * from t1
where b < 7 and (a,b) not in ((1,2),(8,9), (5,1));
a b
@@ -590,10 +590,10 @@ explain extended select * from t1
where b < 7 and (a,b) not in ((1,2),(8,9), (5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
+2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`_col_1` and `test`.`t1`.`b` = `<subquery2>`.`_col_2`))))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t1`.`a`) = `tvc_0`.`_col_1`) and trigcond(<cache>(`test`.`t1`.`b`) = `tvc_0`.`_col_2`)))))
select * from t2
where (a,c) not in ((1,2),(8,9), (5,1));
a b c
@@ -606,10 +606,10 @@ explain extended select * from t2
where (a,c) not in ((1,2),(8,9), (5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
+2 DEPENDENT SUBQUERY <derived3> index_subquery key0 key0 8 func,func 2 100.00 Using where; Full scan on NULL key
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`_col_1` and `test`.`t2`.`c` = `<subquery2>`.`_col_2`))))
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in (temporary) on key0 where trigcond(<cache>(`test`.`t2`.`a`) = `tvc_0`.`_col_1`) and trigcond(<cache>(`test`.`t2`.`c`) = `tvc_0`.`_col_2`)))))
drop table t1, t2, t3;
set @@in_predicate_conversion_threshold= default;
#
diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result
index 856937259bf..49aa1dd32a0 100644
--- a/mysql-test/main/order_by.result
+++ b/mysql-test/main/order_by.result
@@ -1191,7 +1191,7 @@ 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 index k2 k3 5 NULL 22318 Using where
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
@@ -3118,7 +3118,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 ref id_23_date,id_234_date id_23_date 2 const,const 8 Using where
+1 SIMPLE t2 range id_23_date,id_234_date id_23_date 2 NULL 8 Using where
drop table t1,t2;
#
# MDEV-8989: ORDER BY optimizer ignores equality propagation
diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result
index ea12158862e..9861b189c34 100644
--- a/mysql-test/main/partition.result
+++ b/mysql-test/main/partition.result
@@ -551,7 +551,7 @@ INSERT INTO `t1` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),
INSERT INTO `t2` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 NULL index c1 c1 5 NULL 20 Using where; Using index
+1 SIMPLE t1 NULL range c1 c1 5 NULL 4 Using where; Using index
FLUSH STATUS;
SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20);
c1
@@ -561,10 +561,10 @@ c1
19
SHOW STATUS LIKE 'Handler_read_%';
Variable_name Value
-Handler_read_first 1
-Handler_read_key 0
+Handler_read_first 0
+Handler_read_key 2
Handler_read_last 0
-Handler_read_next 20
+Handler_read_next 4
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
@@ -572,7 +572,7 @@ Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
EXPLAIN PARTITIONS SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 a index c1 c1 5 NULL 20 Using where; Using index
+1 SIMPLE t2 a range c1 c1 5 NULL 4 Using where; Using index
FLUSH STATUS;
SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20);
c1
@@ -582,10 +582,10 @@ c1
19
SHOW STATUS LIKE 'Handler_read_%';
Variable_name Value
-Handler_read_first 1
-Handler_read_key 0
+Handler_read_first 0
+Handler_read_key 2
Handler_read_last 0
-Handler_read_next 20
+Handler_read_next 4
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
@@ -2362,6 +2362,10 @@ 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
+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
DROP TABLE t1;
#
# Bug #45807: crash accessing partitioned table and sql_mode
diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test
index 89db3e92162..c016d201ee2 100644
--- a/mysql-test/main/partition.test
+++ b/mysql-test/main/partition.test
@@ -2293,6 +2293,9 @@ SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
EXPLAIN
SELECT b, c FROM t1 WHERE b = 1 GROUP BY b, c;
+EXPLAIN
+SELECT b, c FROM t1 WHERE b = 1 or b=2 GROUP BY b, c;
+
DROP TABLE t1;
--echo #
diff --git a/mysql-test/main/partition_innodb.result b/mysql-test/main/partition_innodb.result
index 554e7472a79..7d7039a8d4a 100644
--- a/mysql-test/main/partition_innodb.result
+++ b/mysql-test/main/partition_innodb.result
@@ -699,7 +699,7 @@ EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref PRIMARY,col1,col2 col1 8 const # Using where; Using filesort
+1 SIMPLE t1 range PRIMARY,col1,col2 PRIMARY 5 NULL # Using where; Using filesort
SELECT * FROM t1 USE INDEX () WHERE col1 = 1 AND col2 = 2
AND col3 BETWEEN '2013-03-08 00:00:00' AND '2013-03-12 12:00:00'
GROUP BY 1, 2, 3;
diff --git a/mysql-test/main/partition_mrr_aria.result b/mysql-test/main/partition_mrr_aria.result
index 9cef160cbe4..99fb17338c3 100644
--- a/mysql-test/main/partition_mrr_aria.result
+++ b/mysql-test/main/partition_mrr_aria.result
@@ -129,7 +129,7 @@ set join_cache_level=6;
set optimizer_switch='mrr=on';
explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1
@@ -146,7 +146,7 @@ tp a b c a
3 4 30 zzzyy 4
explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1
@@ -163,7 +163,7 @@ tp a b c a
3 4 30 zzzyy 4
explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4
@@ -189,7 +189,7 @@ tp a b c a
2 4 40 xxzy 4
explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4
@@ -221,7 +221,7 @@ test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null
@@ -229,7 +229,7 @@ select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
a tp a b c
explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null
diff --git a/mysql-test/main/partition_mrr_innodb.result b/mysql-test/main/partition_mrr_innodb.result
index fd6d0245fb2..8e34914a6e3 100644
--- a/mysql-test/main/partition_mrr_innodb.result
+++ b/mysql-test/main/partition_mrr_innodb.result
@@ -129,7 +129,7 @@ set join_cache_level=6;
set optimizer_switch='mrr=on';
explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1
@@ -146,7 +146,7 @@ tp a b c a
3 4 30 zzzyy 4
explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1
@@ -163,7 +163,7 @@ tp a b c a
3 4 30 zzzyy 4
explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4
@@ -189,7 +189,7 @@ tp a b c a
2 4 40 xxzy 4
explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4
@@ -221,7 +221,7 @@ test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null
@@ -229,7 +229,7 @@ select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
a tp a b c
explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null
diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result
index fbc308f5950..395b64ffb11 100644
--- a/mysql-test/main/partition_mrr_myisam.result
+++ b/mysql-test/main/partition_mrr_myisam.result
@@ -129,7 +129,7 @@ set join_cache_level=6;
set optimizer_switch='mrr=on';
explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1
@@ -146,7 +146,7 @@ tp a b c a
3 4 30 zzzyy 4
explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1
@@ -163,7 +163,7 @@ tp a b c a
3 4 30 zzzyy 4
explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4
@@ -189,7 +189,7 @@ tp a b c a
2 4 40 xxzy 4
explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 10.00 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4
@@ -221,7 +221,7 @@ test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null
@@ -229,7 +229,7 @@ select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null;
a tp a b c
explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 index idx idx 5 NULL 23 17.39 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null
@@ -287,13 +287,13 @@ set join_cache_level=6, optimizer_switch='mrr=on';
explain
select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index
1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan
# This will use "Using index condition(BKA)"
explain
select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index idx idx 5 NULL 20 Using where; Using index
+1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index
1 SIMPLE t1 ref idx idx 5 test.t2.a 12 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan
set join_cache_level=@tmp1, optimizer_switch=@tmp2;
drop table t0,t1,t2;
diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result
index f8ae65fbcea..519bf590b9b 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
# # # # # # # # # 3 #
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
id select_type table partitions type possible_keys key key_len ref rows Extra
-# # # # # # # # # 10 #
+# # # # # # # # # 8 #
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
# # # # # # # # # 3 #
@@ -42,7 +42,7 @@ a
0
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 p0 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t1 p0 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a < 2;
a
-1
@@ -50,7 +50,7 @@ a
1
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a < 3;
a
-1
@@ -59,7 +59,7 @@ a
2
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a < 4;
a
-1
@@ -69,7 +69,7 @@ a
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a < 5;
a
-1
@@ -80,7 +80,7 @@ a
4
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 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a < 6;
a
-1
@@ -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 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range 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 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a <= 1;
a
-1
@@ -113,7 +113,7 @@ a
1
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 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a <= 2;
a
-1
@@ -122,7 +122,7 @@ a
2
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a <= 3;
a
-1
@@ -132,7 +132,7 @@ a
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a <= 4;
a
-1
@@ -143,7 +143,7 @@ a
4
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a <= 5;
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 index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5 range 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 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 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 index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 9 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 index PRIMARY PRIMARY 4 NULL 8 Using where; Using index
+1 SIMPLE t1 p1,p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a >= 2;
a
2
@@ -249,7 +249,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a >= 3;
a
3
@@ -260,7 +260,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a >= 4;
a
4
@@ -270,7 +270,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p4,p5,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a >= 5;
a
5
@@ -279,7 +279,7 @@ a
8
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 p5,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p5,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a >= 6;
a
6
@@ -287,14 +287,14 @@ a
8
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a >= 7;
a
7
8
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 1;
a
2
@@ -306,7 +306,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 p2,p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p2,p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a > 2;
a
3
@@ -317,7 +317,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p3,p4,p5,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p3,p4,p5,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a > 3;
a
4
@@ -327,7 +327,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p4,p5,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p4,p5,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a > 4;
a
5
@@ -336,7 +336,7 @@ a
8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p5,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p5,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a > 5;
a
6
@@ -344,20 +344,20 @@ a
8
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a > 6;
a
7
8
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 7;
a
8
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY)
PARTITION BY RANGE (a) (
@@ -374,7 +374,7 @@ a
0
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 p0 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t1 p0 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a < 2;
a
-1
@@ -382,7 +382,7 @@ a
1
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a < 3;
a
-1
@@ -391,7 +391,7 @@ a
2
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a < 4;
a
-1
@@ -401,7 +401,7 @@ a
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a < 5;
a
-1
@@ -412,7 +412,7 @@ a
4
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 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a < 6;
a
-1
@@ -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 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a <= 1;
a
-1
@@ -432,7 +432,7 @@ a
1
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 p0,p1 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 p0,p1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a <= 2;
a
-1
@@ -441,7 +441,7 @@ a
2
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p0,p1,p2 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a <= 3;
a
-1
@@ -451,7 +451,7 @@ a
3
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3 index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3 range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a <= 4;
a
-1
@@ -462,7 +462,7 @@ a
4
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0,p1,p2,p3,p4 index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4 range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a <= 5;
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 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 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 index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
+1 SIMPLE t1 p0,p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 8 Using where; Using index
SELECT * FROM t1 WHERE a = 1;
a
1
@@ -535,7 +535,7 @@ a
7
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,max index PRIMARY PRIMARY 4 NULL 7 Using where; Using index
+1 SIMPLE t1 p1,p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 7 Using where; Using index
SELECT * FROM t1 WHERE a >= 2;
a
2
@@ -546,7 +546,7 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a >= 3;
a
3
@@ -556,7 +556,7 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p3,p4,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a >= 4;
a
4
@@ -565,7 +565,7 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p4,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a >= 5;
a
5
@@ -573,14 +573,14 @@ a
7
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a >= 6;
a
6
7
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 1;
a
2
@@ -591,7 +591,7 @@ a
7
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 p2,p3,p4,max index PRIMARY PRIMARY 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p2,p3,p4,max range PRIMARY PRIMARY 4 NULL 6 Using where; Using index
SELECT * FROM t1 WHERE a > 2;
a
3
@@ -601,7 +601,7 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p3,p4,max index PRIMARY PRIMARY 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p3,p4,max range PRIMARY PRIMARY 4 NULL 5 Using where; Using index
SELECT * FROM t1 WHERE a > 3;
a
4
@@ -610,7 +610,7 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p4,max index PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p4,max range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT * FROM t1 WHERE a > 4;
a
5
@@ -618,20 +618,20 @@ a
7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 3 Using where; Using index
SELECT * FROM t1 WHERE a > 5;
a
6
7
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a > 6;
a
7
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 max index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
DROP TABLE t1;
# test of RANGE and index
CREATE TABLE t1 (a DATE, KEY(a))
@@ -744,62 +744,62 @@ a
1001-01-01
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
# Disabling warnings for the invalid date
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 index a a 4 NULL 7 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 pNULL,p1001-01-01,p2001-01-01 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01 range a a 4 NULL 3 Using where; Using index
# test without index
ALTER TABLE t1 DROP KEY a;
SELECT * FROM t1 WHERE a < '1001-01-01';
@@ -1073,62 +1073,62 @@ a
1001-01-01
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
# Disabling warnings for the invalid date
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
# test without index
ALTER TABLE t1 DROP KEY a;
SELECT * FROM t1 WHERE a < '1001-01-01';
@@ -1402,62 +1402,62 @@ a
1001-01-01
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1001-01-01 system a NULL NULL NULL 1
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1001-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
# Disabling warnings for the invalid date
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 6 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0000-00-00' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 index a a 4 NULL 6 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 4 Using where; Using index
+1 SIMPLE t1 pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 index a a 4 NULL 5 Using where; Using index
+1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
# test without index
ALTER TABLE t1 DROP KEY a;
SELECT * FROM t1 WHERE a < '1001-01-01';
@@ -2676,13 +2676,13 @@ explain partitions
select * from t1 X, t1 Y
where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 8 Using where
-1 SIMPLE Y p2,p3 ALL a,b NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where
+1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using rowid filter
explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE X p1,p2 ALL a NULL NULL NULL 8 Using where
-1 SIMPLE Y p1,p2 ALL a NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE X p1,p2 range a a 4 NULL 4 Using where
+1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2
drop table t1;
create table t1 (a int) partition by hash(a) partitions 20;
insert into t1 values (1),(2),(3);
diff --git a/mysql-test/main/partition_range.result b/mysql-test/main/partition_range.result
index 6eb7147b461..ac8d34c71a2 100644
--- a/mysql-test/main/partition_range.result
+++ b/mysql-test/main/partition_range.result
@@ -2,16 +2,25 @@ drop table if exists t1, t2;
#
# Bug#48229: group by performance issue of partitioned table
#
-CREATE TABLE t1 (
-a INT,
-b INT,
-KEY a (a,b)
-)
-PARTITION BY HASH (a) PARTITIONS 1;
-INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020);
-EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a;
+CREATE TABLE t1 (a INT,b INT,KEY a (a,b));
+INSERT INTO `t1` VALUES (0,580092),(3000,894076),(4000,805483),(4000,913540),(6000,611137),(8000,171602),(9000,599495),(9000,746305),(10000,272829),(10000,847519),(12000,258869),(12000,929028),(13000,288970),(15000,20971),(15000,105839),(16000,788272),(17000,76914),(18000,827274),(19000,802258),(20000,123677),(20000,587729),(22000,701449),(25000,31565),(25000,230782),(25000,442887),(25000,733139),(25000,851020);
+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 1 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 1 Using where; Using index for group-by
+alter table t1 remove partitioning;
+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
+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
DROP TABLE t1;
create table t1 (a DATETIME)
partition by range (TO_DAYS(a))
diff --git a/mysql-test/main/partition_range.test b/mysql-test/main/partition_range.test
index 52497764241..f56851217cf 100644
--- a/mysql-test/main/partition_range.test
+++ b/mysql-test/main/partition_range.test
@@ -3,7 +3,8 @@
# Simple test for the partition storage engine
# Focuses on range partitioning tests
#
--- source include/have_partition.inc
+--source include/have_partition.inc
+--source include/have_sequence.inc
--disable_warnings
drop table if exists t1, t2;
@@ -12,19 +13,23 @@ drop table if exists t1, t2;
--echo #
--echo # Bug#48229: group by performance issue of partitioned table
--echo #
-CREATE TABLE t1 (
- a INT,
- b INT,
- KEY a (a,b)
-)
-PARTITION BY HASH (a) PARTITIONS 1;
-# insert some rows (i.e. so that rows/blocks > 1)
-INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020);
+CREATE TABLE t1 (a INT,b INT,KEY a (a,b));
+INSERT INTO `t1` VALUES (0,580092),(3000,894076),(4000,805483),(4000,913540),(6000,611137),(8000,171602),(9000,599495),(9000,746305),(10000,272829),(10000,847519),(12000,258869),(12000,929028),(13000,288970),(15000,20971),(15000,105839),(16000,788272),(17000,76914),(18000,827274),(19000,802258),(20000,123677),(20000,587729),(22000,701449),(25000,31565),(25000,230782),(25000,442887),(25000,733139),(25000,851020);
+
+EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a;
+
+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;
+alter table t1 remove partitioning;
+
+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;
-# Before the fix the 'Extra' column showed 'Using index for group-by'
-EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a;
+EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10000, 1000000, 3000) GROUP BY a;
+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;
DROP TABLE t1;
#
diff --git a/mysql-test/main/ps_1general.result b/mysql-test/main/ps_1general.result
index 83060437de1..46812425ebc 100644
--- a/mysql-test/main/ps_1general.result
+++ b/mysql-test/main/ps_1general.result
@@ -462,15 +462,15 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
def id 8 3 1 Y 32928 0 63
def select_type 253 19 6 N 1 39 8
def table 253 64 2 Y 0 39 8
-def type 253 10 3 Y 0 39 8
+def type 253 10 5 Y 0 39 8
def possible_keys 253 4_OR_8_K 7 Y 0 39 8
-def key 253 64 0 Y 0 39 8
-def key_len 253 4_OR_8_K 0 Y 0 39 8
+def key 253 64 7 Y 0 39 8
+def key_len 253 4_OR_8_K 1 Y 0 39 8
def ref 253 2048 0 Y 0 39 8
def rows 253 64 1 Y 0 39 8
-def Extra 253 255 27 N 1 39 8
+def Extra 253 255 37 N 1 39 8
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using filesort
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using index condition; Using filesort
drop table if exists t2;
create table t2 (id smallint, name varchar(20)) ;
prepare stmt1 from ' insert into t2 values(?, ?) ' ;
diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result
index ff162fc8d69..e56fd46b55f 100644
--- a/mysql-test/main/range.result
+++ b/mysql-test/main/range.result
@@ -252,7 +252,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref x x 5 const 1 Using index
explain select count(*) from t1 where x in (1,2,3,4);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index
+1 SIMPLE t1 range x x 5 NULL 4 Using where; Using index
drop table t1;
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1));
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1);
@@ -261,12 +261,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref j1 j1 4 const 1 Using index
-1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
+1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
explain select * from t1 force index(i1), t2 force index(j1) where
(t1.key1 <t2.keya + 1) and t2.keya=3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref j1 j1 4 const 1 Using index
-1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
+1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
DROP TABLE t1,t2;
CREATE TABLE t1 (
a int(11) default NULL,
@@ -327,8 +327,8 @@ KEY recount( owner, line )
INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5);
SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30;
id columnid tableid content showid line ordinal
-13 13 1 188 1 5 0
15 15 1 188 1 1 0
+13 13 1 188 1 5 0
drop table t1;
create table t1 (id int(10) primary key);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -723,7 +723,7 @@ WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition
+1 SIMPLE v ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL NULL 12 Using where
1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4)
SELECT s.oxid FROM t1 v, t1 s
WHERE
@@ -1047,10 +1047,10 @@ INSERT INTO `t1` VALUES
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
explain select * from t1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
@@ -1427,7 +1427,7 @@ SELECT * FROM t3 WHERE
a < 5 OR
a < 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index a a 10 NULL 23 Using where; Using index
+1 SIMPLE t3 range a a 5 NULL 9 Using where; Using index
DROP TABLE t1, t2, t3;
#
# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN
@@ -1981,7 +1981,7 @@ insert into t1 values (0,0,0), (2,2,0), (1,1,1), (2,2,1);
explain
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index idx idx 15 NULL 4 Using where; Using index
+1 SIMPLE t1 range idx idx 5 NULL 2 Using where; Using index
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
a b c
2 2 0
@@ -2510,7 +2510,7 @@ insert into t2 values
explain select * from t1,t2
where a = d and (a,e) in ((3,3),(7,7),(2,2));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range idx1,idx2 idx1 5 NULL 3 Using index condition; Using where
+1 SIMPLE t2 range|filter idx1,idx2 idx1|idx2 5|5 NULL 3 (60%) Using index condition; Using where; Using rowid filter
1 SIMPLE t1 ref idx idx 5 test.t2.d 8
explain format=json select * from t1,t2
where a = d and (a,e) in ((3,3),(7,7),(2,2));
@@ -2525,6 +2525,14 @@ EXPLAIN
"key": "idx1",
"key_length": "5",
"used_key_parts": ["d"],
+ "rowid_filter": {
+ "range": {
+ "key": "idx2",
+ "used_key_parts": ["e"]
+ },
+ "rows": 12,
+ "selectivity_pct": 60
+ },
"rows": 3,
"filtered": 60,
"index_condition": "t2.d is not null",
@@ -3105,12 +3113,12 @@ insert into t2 select A.a + B.a*10 + C.a*100 from ten A, ten B,ten C where A.a +
# expected type=range, rows=1487 , reason=using index dives
analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 index a a 5 NULL 2000 2000.00 74.35 59.95 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 1487 1199.00 100.00 100.00 Using where; Using index
insert into t2 values (200),(201);
# expected type=range, rows=201 , reason=using index statistics
analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 index a a 5 NULL 2000 2000.00 10.05 60.05 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 201 1201.00 100.00 100.00 Using where; Using index
drop table t1,ten,t2;
#
# End of 10.2 tests
diff --git a/mysql-test/main/range_innodb.result b/mysql-test/main/range_innodb.result
index 44138bdb85e..56bf67b0e94 100644
--- a/mysql-test/main/range_innodb.result
+++ b/mysql-test/main/range_innodb.result
@@ -95,7 +95,7 @@ KEY (a,b)
INSERT INTO t1 VALUES (1,'a',1),(2,'b',2);
explain SELECT a FROM t1 WHERE pk < 0 AND a <= 'w' and b > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,a a 9 NULL 2 Using where; Using index
+1 SIMPLE t1 range PRIMARY,a PRIMARY 4 NULL 1 Using where
SELECT a FROM t1 WHERE pk < 0 AND a <= 'w' and b > 0;
a
drop table t1;
diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result
index 5a84cd6bde8..ee92d612889 100644
--- a/mysql-test/main/range_mrr_icp.result
+++ b/mysql-test/main/range_mrr_icp.result
@@ -255,7 +255,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref x x 5 const 1 Using index
explain select count(*) from t1 where x in (1,2,3,4);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index x x 5 NULL 9 Using where; Using index
+1 SIMPLE t1 range x x 5 NULL 4 Using where; Using index
drop table t1;
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1));
INSERT INTO t1 VALUES (0),(0),(0),(0),(0),(1),(1);
@@ -264,12 +264,12 @@ INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref j1 j1 4 const 1 Using index
-1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
+1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
explain select * from t1 force index(i1), t2 force index(j1) where
(t1.key1 <t2.keya + 1) and t2.keya=3;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref j1 j1 4 const 1 Using index
-1 SIMPLE t1 index i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
+1 SIMPLE t1 range i1 i1 4 NULL 7 Using where; Using index; Using join buffer (flat, BNL join)
DROP TABLE t1,t2;
CREATE TABLE t1 (
a int(11) default NULL,
@@ -330,8 +330,8 @@ KEY recount( owner, line )
INSERT into t1 (owner,id,columnid,line) values (11,15,15,1),(11,13,13,5);
SELECT id, columnid, tableid, content, showid, line, ordinal FROM t1 WHERE owner=11 AND ((columnid IN ( 15, 13, 14 ) AND line IN ( 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 31 )) OR (columnid IN ( 13, 14 ) AND line IN ( 15 ))) LIMIT 0 , 30;
id columnid tableid content showid line ordinal
-13 13 1 188 1 5 0
15 15 1 188 1 1 0
+13 13 1 188 1 5 0
drop table t1;
create table t1 (id int(10) primary key);
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -726,7 +726,7 @@ WHERE
v.oxrootid ='d8c4177d09f8b11f5.52725521' AND
s.oxleft > v.oxleft AND s.oxleft < v.oxright;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 6 Using index condition
+1 SIMPLE v ALL OXLEFT,OXRIGHT,OXROOTID NULL NULL NULL 12 Using where
1 SIMPLE s ALL OXLEFT NULL NULL NULL 12 Range checked for each record (index map: 0x4)
SELECT s.oxid FROM t1 v, t1 s
WHERE
@@ -1050,10 +1050,10 @@ INSERT INTO `t1` VALUES
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
explain select * from t1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
@@ -1430,7 +1430,7 @@ SELECT * FROM t3 WHERE
a < 5 OR
a < 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index a a 10 NULL 23 Using where; Using index
+1 SIMPLE t3 range a a 5 NULL 9 Using where; Using index
DROP TABLE t1, t2, t3;
#
# Bug #47123: Endless 100% CPU loop with STRAIGHT_JOIN
@@ -1984,7 +1984,7 @@ insert into t1 values (0,0,0), (2,2,0), (1,1,1), (2,2,1);
explain
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index idx idx 15 NULL 4 Using where; Using index
+1 SIMPLE t1 range idx idx 5 NULL 2 Using where; Using index
select * from t1 force index (idx) where a >=1 and c <= 1 and a=b and b > 1;
a b c
2 2 0
@@ -3102,12 +3102,12 @@ insert into t2 select A.a + B.a*10 + C.a*100 from ten A, ten B,ten C where A.a +
# expected type=range, rows=1487 , reason=using index dives
analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 index a a 5 NULL 2000 2000.00 74.35 59.95 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 1487 1199.00 100.00 100.00 Using where; Using index
insert into t2 values (200),(201);
# expected type=range, rows=201 , reason=using index statistics
analyze SELECT * FROM t1 where a in (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,200,201);
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1 index a a 5 NULL 2000 2000.00 10.05 60.05 Using where; Using index
+1 SIMPLE t1 range a a 5 NULL 201 1201.00 100.00 100.00 Using where; Using index
drop table t1,ten,t2;
#
# End of 10.2 tests
diff --git a/mysql-test/main/range_vs_index_merge.result b/mysql-test/main/range_vs_index_merge.result
index f0bf2224c92..6b2c9a2f0bc 100644
--- a/mysql-test/main/range_vs_index_merge.result
+++ b/mysql-test/main/range_vs_index_merge.result
@@ -951,7 +951,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 PRIMARY,Population,Country,Name,CountryPopulation,CountryName CountryName 38 NULL 23 Using index condition; Using where
+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
EXPLAIN
SELECT * FROM City
WHERE ((Population > 101000 AND Population < 11000) OR
diff --git a/mysql-test/main/range_vs_index_merge_innodb.result b/mysql-test/main/range_vs_index_merge_innodb.result
index b30f8978f41..f69425fee8b 100644
--- a/mysql-test/main/range_vs_index_merge_innodb.result
+++ b/mysql-test/main/range_vs_index_merge_innodb.result
@@ -1085,7 +1085,7 @@ EXPLAIN SELECT Name, Country, Population FROM City WHERE
(Name='Samara' AND Country='RUS') OR
(Name='Seattle' AND Country='USA');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge Country,CountryPopulation,CountryName,CityName CountryName,CityName 38,35 NULL 27 Using sort_union(CountryName,CityName); Using where
+1 SIMPLE City range Country,CountryPopulation,CountryName,CityName CountryName 38 NULL 27 Using index condition
SELECT Name, Country, Population FROM City WHERE
(Name='Manila' AND Country='PHL') OR
(Name='Addis Abeba' AND Country='ETH') OR
@@ -1806,7 +1806,7 @@ SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,idx idx 10 NULL 2 Using where; Using index
+1 SIMPLE t1 range PRIMARY,idx idx 5 NULL 2 Using where; Using index
SELECT * FROM t1
WHERE t1.a>300 AND t1.c!=0 AND t1.b>=350 AND t1.b<=400 AND
(t1.c=0 OR t1.a=500);
diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result
index a803f832935..5ad252bb42d 100644
--- a/mysql-test/main/rowid_filter.result
+++ b/mysql-test/main/rowid_filter.result
@@ -886,7 +886,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|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
+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
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
@@ -915,7 +915,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -939,7 +939,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 PRIMARY|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 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
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
@@ -975,7 +975,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1050,7 +1050,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 PRIMARY 4 dbt3_s001.orders.o_orderkey 4 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
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
@@ -1079,7 +1079,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1095,7 +1095,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 PRIMARY 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 i_l_orderkey 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
@@ -1131,7 +1131,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1454,7 +1454,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 PRIMARY 4 dbt3_s001.orders.o_orderkey 4 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
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
@@ -1486,7 +1486,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1504,7 +1504,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_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
+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
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
@@ -1543,7 +1543,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1577,7 +1577,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 PRIMARY 4 dbt3_s001.orders.o_orderkey 4 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
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
@@ -1609,7 +1609,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1627,7 +1627,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_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
+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
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
@@ -1666,7 +1666,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1703,7 +1703,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 PRIMARY 4 dbt3_s001.orders.o_orderkey 4 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
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
@@ -1740,7 +1740,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1758,7 +1758,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 1.95 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
+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
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
@@ -1802,7 +1802,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1836,7 +1836,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 PRIMARY 4 dbt3_s001.orders.o_orderkey 4 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
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
@@ -1873,7 +1873,7 @@ EXPLAIN
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
@@ -1891,7 +1891,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 1.95 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
+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
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
@@ -1935,7 +1935,7 @@ ANALYZE
"i_l_orderkey",
"i_l_orderkey_quantity"
],
- "key": "PRIMARY",
+ "key": "i_l_orderkey",
"key_length": "4",
"used_key_parts": ["l_orderkey"],
"ref": ["dbt3_s001.orders.o_orderkey"],
diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result
index f0fa6736daa..ac4fe9f1534 100644
--- a/mysql-test/main/rowid_filter_innodb.result
+++ b/mysql-test/main/rowid_filter_innodb.result
@@ -567,8 +567,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 144 Using where; Using index
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+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 510 (10%) 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
@@ -579,20 +579,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": 144,
- "filtered": 100,
- "attached_condition": "orders.o_totalprice between 180000 and 230000",
- "using_index": true
- },
- "table": {
"table_name": "lineitem",
- "access_type": "ref",
+ "access_type": "range",
"possible_keys": [
"PRIMARY",
"i_l_shipdate",
@@ -600,13 +588,33 @@ EXPLAIN
"i_l_orderkey_quantity",
"i_l_quantity"
],
+ "key": "i_l_shipdate",
+ "key_length": "4",
+ "used_key_parts": ["l_shipDATE"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_l_quantity",
+ "used_key_parts": ["l_quantity"]
+ },
+ "rows": 605,
+ "selectivity_pct": 10.075
+ },
+ "rows": 510,
+ "filtered": 10.075,
+ "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": ["l_orderkey"],
- "ref": ["dbt3_s001.orders.o_orderkey"],
- "rows": 4,
- "filtered": 0.8557,
- "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 9.6,
+ "attached_condition": "orders.o_totalprice between 180000 and 230000"
}
}
}
@@ -616,8 +624,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 144 144.00 100.00 100.00 Using where; Using index
-1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity,i_l_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.62 0.86 1.68 Using where
+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 510 (10%) 60.00 (11%) 10.07 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.60 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
@@ -630,25 +638,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": 144,
- "r_rows": 144,
- "r_table_time_ms": "REPLACED",
- "r_other_time_ms": "REPLACED",
- "filtered": 100,
- "r_filtered": 100,
- "attached_condition": "orders.o_totalprice between 180000 and 230000",
- "using_index": true
- },
- "table": {
"table_name": "lineitem",
- "access_type": "ref",
+ "access_type": "range",
"possible_keys": [
"PRIMARY",
"i_l_shipdate",
@@ -656,18 +647,47 @@ ANALYZE
"i_l_orderkey_quantity",
"i_l_quantity"
],
+ "key": "i_l_shipdate",
+ "key_length": "4",
+ "used_key_parts": ["l_shipDATE"],
+ "rowid_filter": {
+ "range": {
+ "key": "i_l_quantity",
+ "used_key_parts": ["l_quantity"]
+ },
+ "rows": 605,
+ "selectivity_pct": 10.075,
+ "r_rows": 605,
+ "r_selectivity_pct": 11.765,
+ "r_buffer_size": "REPLACED",
+ "r_filling_time_ms": "REPLACED"
+ },
+ "r_loops": 1,
+ "rows": 510,
+ "r_rows": 60,
+ "r_table_time_ms": "REPLACED",
+ "r_other_time_ms": "REPLACED",
+ "filtered": 10.075,
+ "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": ["l_orderkey"],
- "ref": ["dbt3_s001.orders.o_orderkey"],
- "r_loops": 144,
- "rows": 4,
- "r_rows": 6.625,
+ "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.8557,
- "r_filtered": 1.6771,
- "attached_condition": "lineitem.l_shipDATE between '1997-01-01' and '1997-06-30' and lineitem.l_quantity > 45"
+ "filtered": 9.6,
+ "r_filtered": 26.667,
+ "attached_condition": "orders.o_totalprice between 180000 and 230000"
}
}
}
@@ -2095,8 +2115,8 @@ union
( select * from t1
where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a')));
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index_merge f1,f2 f1,f2 13,33 NULL 1 Using intersect(f1,f2); Using where
-2 UNION t1 index_merge f1,f2 f1,f2 13,33 NULL 1 Using intersect(f1,f2); Using where
+1 PRIMARY t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter
+2 UNION t1 ref|filter f1,f2 f1|f1 13|13 const 1 (2%) Using index condition; Using where; Using rowid filter
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
explain format=json ( select * from t1
where (f1 is null and f2 is null) and (f2 between 'a' and 'z' or f1 in ('a')))
@@ -2115,24 +2135,24 @@ EXPLAIN
"select_id": 1,
"table": {
"table_name": "t1",
- "access_type": "index_merge",
+ "access_type": "ref",
"possible_keys": ["f1", "f2"],
- "key_length": "13,33",
- "index_merge": {
- "intersect": {
- "range": {
- "key": "f1",
- "used_key_parts": ["f1"]
- },
- "range": {
- "key": "f2",
- "used_key_parts": ["f2"]
- }
- }
+ "key": "f1",
+ "key_length": "13",
+ "used_key_parts": ["f1"],
+ "ref": ["const"],
+ "rowid_filter": {
+ "range": {
+ "key": "f1",
+ "used_key_parts": ["f1"]
+ },
+ "rows": 1,
+ "selectivity_pct": 1.5873
},
"rows": 1,
"filtered": 1.5873,
- "attached_condition": "t1.f1 is null and t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')"
+ "index_condition": "t1.f1 is null",
+ "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')"
}
}
},
@@ -2142,24 +2162,24 @@ EXPLAIN
"operation": "UNION",
"table": {
"table_name": "t1",
- "access_type": "index_merge",
+ "access_type": "ref",
"possible_keys": ["f1", "f2"],
- "key_length": "13,33",
- "index_merge": {
- "intersect": {
- "range": {
- "key": "f1",
- "used_key_parts": ["f1"]
- },
- "range": {
- "key": "f2",
- "used_key_parts": ["f2"]
- }
- }
+ "key": "f1",
+ "key_length": "13",
+ "used_key_parts": ["f1"],
+ "ref": ["const"],
+ "rowid_filter": {
+ "range": {
+ "key": "f1",
+ "used_key_parts": ["f1"]
+ },
+ "rows": 1,
+ "selectivity_pct": 1.5873
},
"rows": 1,
"filtered": 1.5873,
- "attached_condition": "t1.f1 is null and t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')"
+ "index_condition": "t1.f1 is null",
+ "attached_condition": "t1.f2 is null and (t1.f2 between 'a' and 'z' or t1.f1 = 'a')"
}
}
}
@@ -2184,7 +2204,7 @@ id y x
explain extended select * from t1 join t2 on t1.id = t2.x where t2.y = 2 and t1.id = 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 100.00 Using index
-1 SIMPLE t2 index_merge x,y y,x 5,5 NULL 1 100.00 Using intersect(y,x); Using where; Using index
+1 SIMPLE t2 ref x,y y 5 const 2 100.00 Using where
Warnings:
Note 1003 select 1 AS `id`,`test`.`t2`.`y` AS `y`,`test`.`t2`.`x` AS `x` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`y` = 2 and `test`.`t2`.`x` = 1
drop table t1, t2;
@@ -2205,17 +2225,17 @@ count(*)
6
explain extended select count(*) from t1 where a in (22,83,11) and b=2;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ref b,a b 5 const 59 3.30 Using where
+1 SIMPLE t1 range b,a a 5 NULL 33 5.90 Using index condition; Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (22,83,11)
select * from t1 where a in (22,83,11) and b=2;
a b
11 2
11 2
-83 2
11 2
-83 2
22 2
+83 2
+83 2
set optimizer_switch='rowid_filter=on';
select count(*) from t1 where a in (22,83,11) and b=2;
count(*)
diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result
index ba5ec36430e..7547b5b1347 100644
--- a/mysql-test/main/select.result
+++ b/mysql-test/main/select.result
@@ -2782,10 +2782,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 max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
0.6158
@@ -3632,7 +3632,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where
-1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where
+1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter
EXPLAIN
SELECT t3.a FROM t1,t2,t3
WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND
@@ -3640,7 +3640,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where
-1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where
+1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter
DROP TABLE t1,t2,t3;
CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);
CREATE TABLE t2 ( f11 int PRIMARY KEY );
@@ -3717,7 +3717,7 @@ COUNT(*)
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
+1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -3731,7 +3731,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
+1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -4031,7 +4031,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
ON ( f1.b=f2.b AND f1.a<f2.a )
WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index
+1 SIMPLE f1 range inx inx 5 NULL 7 Using where; Using index
1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index
DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT);
@@ -5134,8 +5134,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 system PRIMARY NULL NULL NULL 1
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ref f22 f22 5 const 1
-1 SIMPLE t6 ref f61 f61 5 const 1 Using where
1 SIMPLE t4 ref f42 f42 5 const 1 Using index
+1 SIMPLE t6 ref f61 f61 5 const 1 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT t2.f23 FROM
(t1 LEFT JOIN (t2 JOIN t3 ON t2.f22=t3.f32) ON t1.f11=t3.f31)
diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result
index 2de5df60901..6a8174d124c 100644
--- a/mysql-test/main/select_jcl6.result
+++ b/mysql-test/main/select_jcl6.result
@@ -2793,10 +2793,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 max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
0.6158
@@ -3643,7 +3643,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan
-1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter
EXPLAIN
SELECT t3.a FROM t1,t2,t3
WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND
@@ -3651,7 +3651,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where; Rowid-ordered scan
-1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan; Using rowid filter
DROP TABLE t1,t2,t3;
CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);
CREATE TABLE t2 ( f11 int PRIMARY KEY );
@@ -3728,7 +3728,7 @@ COUNT(*)
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
+1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -3742,7 +3742,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
+1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -4042,7 +4042,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
ON ( f1.b=f2.b AND f1.a<f2.a )
WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index
+1 SIMPLE f1 range inx inx 5 NULL 7 Using where; Using index
1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index
DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT);
@@ -5145,9 +5145,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 system PRIMARY NULL NULL NULL 1
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ref f22 f22 5 const 1
-1 SIMPLE t6 ref f61 f61 5 const 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t4 ref f42 f42 5 const 1 Using index
-1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t6 ref f61 f61 5 const 1 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
SELECT t2.f23 FROM
(t1 LEFT JOIN (t2 JOIN t3 ON t2.f22=t3.f32) ON t1.f11=t3.f31)
LEFT JOIN
diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result
index ba5ec36430e..7547b5b1347 100644
--- a/mysql-test/main/select_pkeycache.result
+++ b/mysql-test/main/select_pkeycache.result
@@ -2782,10 +2782,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 max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
+1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
select max(key1) from t1 where key1 <= 0.6158;
max(key1)
0.6158
@@ -3632,7 +3632,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 range si si 5 NULL 2 Using index condition; Using where
-1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where
+1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter
EXPLAIN
SELECT t3.a FROM t1,t2,t3
WHERE t1.id = 8 AND (t2.i=t1.b OR t2.i=t1.e) AND t3.a=t2.a AND
@@ -3640,7 +3640,7 @@ t3.c IN ('bb','ee');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 range si,ai si 5 NULL 2 Using index condition; Using where
-1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where
+1 SIMPLE t3 eq_ref|filter PRIMARY,ci PRIMARY|ci 4|5 test.t2.a 1 (30%) Using where; Using rowid filter
DROP TABLE t1,t2,t3;
CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);
CREATE TABLE t2 ( f11 int PRIMARY KEY );
@@ -3717,7 +3717,7 @@ COUNT(*)
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
+1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (6%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null=3 IS NULL ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -3731,7 +3731,7 @@ CREATE UNIQUE INDEX idx1 ON t1(ID1_with_null,ID2_with_null);
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null IS NULL AND ID2_with_null=3 ;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ref idx1,idx2 idx2 4 const 2 Using where
+1 SIMPLE t1 ref|filter idx1,idx2 idx2|idx1 4|10 const 2 (7%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1
WHERE ID_better=1 AND ID1_with_null=3 AND ID2_with_null IS NULL ;
id select_type table type possible_keys key key_len ref rows Extra
@@ -4031,7 +4031,7 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
ON ( f1.b=f2.b AND f1.a<f2.a )
WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index
+1 SIMPLE f1 range inx inx 5 NULL 7 Using where; Using index
1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index
DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT);
@@ -5134,8 +5134,8 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 system PRIMARY NULL NULL NULL 1
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 Using index
1 SIMPLE t2 ref f22 f22 5 const 1
-1 SIMPLE t6 ref f61 f61 5 const 1 Using where
1 SIMPLE t4 ref f42 f42 5 const 1 Using index
+1 SIMPLE t6 ref f61 f61 5 const 1 Using where
1 SIMPLE t7 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT t2.f23 FROM
(t1 LEFT JOIN (t2 JOIN t3 ON t2.f22=t3.f32) ON t1.f11=t3.f31)
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index 4366ef6a564..f84d2eae05a 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -73,12 +73,12 @@ order by
s_acctbal desc, n_name, s_name, p_partkey;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 0.31 Using where; Using temporary; Using filesort
-1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where
+1 PRIMARY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where
1 PRIMARY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where
1 PRIMARY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where
1 PRIMARY region eq_ref PRIMARY PRIMARY 4 dbt3_s001.nation.n_regionkey 1 20.00 Using where
2 DEPENDENT SUBQUERY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where
-2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00
+2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00
2 DEPENDENT SUBQUERY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where
2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where
Warnings:
@@ -119,7 +119,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY part ALL PRIMARY NULL NULL NULL 200 2.08 Using where; Using join buffer (flat, BNL join)
1 PRIMARY partsupp eq_ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 8 dbt3_s001.part.p_partkey,dbt3_s001.supplier.s_suppkey 1 100.00 Using where
2 DEPENDENT SUBQUERY region ALL PRIMARY NULL NULL NULL 5 20.00 Using where
-2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00
+2 DEPENDENT SUBQUERY partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00
2 DEPENDENT SUBQUERY supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.partsupp.ps_suppkey 1 100.00 Using where
2 DEPENDENT SUBQUERY nation eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where
Warnings:
@@ -489,7 +489,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
1 PRIMARY nation eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1 100.00 Using where
2 MATERIALIZED part ALL PRIMARY NULL NULL NULL 200 100.00 Using where
-2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey PRIMARY 4 dbt3_s001.part.p_partkey 3 100.00 Using where
+2 MATERIALIZED partsupp ref PRIMARY,i_ps_partkey,i_ps_suppkey i_ps_partkey 4 dbt3_s001.part.p_partkey 3 100.00 Using where
4 DEPENDENT SUBQUERY lineitem ref i_l_shipdate,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey i_l_suppkey_partkey 10 dbt3_s001.partsupp.ps_partkey,dbt3_s001.partsupp.ps_suppkey 8 100.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.partsupp.ps_partkey' of SELECT #4 was resolved in SELECT #2
@@ -1850,7 +1850,7 @@ WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
-2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
+2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
@@ -1862,7 +1862,7 @@ WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
-2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
+2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (10%) Using where; Using rowid filter
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index 8f079993c1b..0d9a55a0bdb 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -1443,7 +1443,7 @@ EXPLAIN EXTENDED
SELECT * FROM t1, t2
WHERE a <> 'USARussian' AND b IS NULL;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ref PRIMARY,b b 5 const 2 66.67 Using where; Using index
+1 SIMPLE t1 range PRIMARY,b b 23 NULL 2 100.00 Using where; Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 14 100.00 Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`i` AS `i` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` <> 'USARussian' and `test`.`t1`.`b` is null
@@ -1860,7 +1860,7 @@ WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
-2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
+2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
@@ -1872,7 +1872,7 @@ WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
-2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
+2 DEPENDENT SUBQUERY t2 ref|filter a,b a|b 5|5 test.A.id 1 (19%) Using where; Using rowid filter
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result
index 3ff10cc2448..ba2e3ef268f 100644
--- a/mysql-test/main/stat_tables.result
+++ b/mysql-test/main/stat_tables.result
@@ -74,7 +74,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (12%) Using where; Using rowid filter
-1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
@@ -181,7 +181,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE supplier ref PRIMARY,i_s_nationkey i_s_nationkey 5 dbt3_s001.nation.n_nationkey 1
1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6
1 SIMPLE orders ref|filter PRIMARY,i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (12%) Using where; Using rowid filter
-1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue
from customer, orders, lineitem, supplier, nation, region
where c_custkey = o_custkey and l_orderkey = o_orderkey
@@ -214,10 +214,10 @@ order by o_year;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort
1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition
+1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
+1 SIMPLE orders eq_ref|filter PRIMARY,i_o_orderdate,i_o_custkey PRIMARY|i_o_orderdate 4|4 dbt3_s001.lineitem.l_orderkey 1 (27%) Using where; Using rowid filter
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
-1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
1 SIMPLE customer eq_ref PRIMARY,i_c_nationkey PRIMARY 4 dbt3_s001.orders.o_custkey 1 Using where
1 SIMPLE n1 eq_ref PRIMARY,i_n_regionkey PRIMARY 4 dbt3_s001.customer.c_nationkey 1 Using where
select o_year,
@@ -337,7 +337,7 @@ and o_orderkey=l_orderkey and p_partkey=l_partkey;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE part range PRIMARY,i_p_retailprice i_p_retailprice 9 NULL 1 Using index condition
1 SIMPLE orders ref PRIMARY,i_o_orderdate i_o_orderdate 4 const 1
-1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_orderkey,i_l_orderkey_quantity i_l_orderkey 4 dbt3_s001.orders.o_orderkey 4 Using where
select o_orderkey, p_partkey
from part, lineitem, orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result
index 2975c8ba686..0b50def19c2 100644
--- a/mysql-test/main/stat_tables_innodb.result
+++ b/mysql-test/main/stat_tables_innodb.result
@@ -246,7 +246,7 @@ order by o_year;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE region ALL PRIMARY NULL NULL NULL 5 Using where; Using temporary; Using filesort
1 SIMPLE part ALL PRIMARY NULL NULL NULL 200 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_suppkey_partkey 5 dbt3_s001.part.p_partkey 30 Using index condition
+1 SIMPLE lineitem ref PRIMARY,i_l_suppkey_partkey,i_l_partkey,i_l_suppkey,i_l_orderkey,i_l_orderkey_quantity i_l_partkey 5 dbt3_s001.part.p_partkey 30 Using where
1 SIMPLE supplier eq_ref PRIMARY,i_s_nationkey PRIMARY 4 dbt3_s001.lineitem.l_suppkey 1 Using where
1 SIMPLE n2 eq_ref PRIMARY PRIMARY 4 dbt3_s001.supplier.s_nationkey 1
1 SIMPLE orders eq_ref PRIMARY,i_o_orderdate,i_o_custkey PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result
index abf758469f0..1ee4718ef10 100644
--- a/mysql-test/main/subselect.result
+++ b/mysql-test/main/subselect.result
@@ -1503,7 +1503,7 @@ 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 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 100.00 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`
@@ -3176,7 +3176,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
-2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
+2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
SELECT a, a IN (SELECT a FROM t1) FROM t2;
a a IN (SELECT a FROM t1)
1 1
@@ -7040,8 +7040,8 @@ SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1
+2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result
index a3d7fda7abc..34e6e857d14 100644
--- a/mysql-test/main/subselect2.result
+++ b/mysql-test/main/subselect2.result
@@ -287,7 +287,7 @@ ORDER BY mirror_date ASC
) AS calculated_result;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
-2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort
+2 DERIVED t1 range date date 6 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort
SELECT * FROM (
SELECT node_uid, date, mirror_date, @result := 0 AS result
FROM t1
@@ -310,7 +310,7 @@ ORDER BY mirror_date ASC
) AS calculated_result;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
-2 DERIVED t1 ALL date NULL NULL NULL 3 Using where; Using filesort
+2 DERIVED t1 range date date 6 NULL 3 Using index condition; Using where; Using filesort
SELECT * FROM (
SELECT node_uid, date, mirror_date, @result := 0 AS result
FROM t1
diff --git a/mysql-test/main/subselect3.result b/mysql-test/main/subselect3.result
index 5c4544a1b05..299faadeff7 100644
--- a/mysql-test/main/subselect3.result
+++ b/mysql-test/main/subselect3.result
@@ -96,10 +96,10 @@ explain extended
select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00
-2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key
+2 DEPENDENT SUBQUERY t1 ALL a NULL NULL NULL 8 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where `test`.`t1`.`oref` = `test`.`t2`.`oref` having trigcond(`test`.`t1`.`a` is null))))) AS `Z` from `test`.`t2`
+Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`oref` = `test`.`t2`.`oref` and trigcond(<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a` or `test`.`t1`.`a` is null) having trigcond(`test`.`t1`.`a` is null)))) AS `Z` from `test`.`t2`
flush status;
select oref, a from t2 where a in (select a from t1 where oref=t2.oref);
oref a
diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result
index 4260676cc37..aebeb4e0cc1 100644
--- a/mysql-test/main/subselect3_jcl6.result
+++ b/mysql-test/main/subselect3_jcl6.result
@@ -99,10 +99,10 @@ explain extended
select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00
-2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 100.00 Using where; Full scan on NULL key
+2 DEPENDENT SUBQUERY t1 ALL a NULL NULL NULL 8 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.oref' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on a checking NULL where `test`.`t1`.`oref` = `test`.`t2`.`oref` having trigcond(`test`.`t1`.`a` is null))))) AS `Z` from `test`.`t2`
+Note 1003 /* select#1 */ select `test`.`t2`.`oref` AS `oref`,`test`.`t2`.`a` AS `a`,<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`oref`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`oref` = `test`.`t2`.`oref` and trigcond(<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a` or `test`.`t1`.`a` is null) having trigcond(`test`.`t1`.`a` is null)))) AS `Z` from `test`.`t2`
flush status;
select oref, a from t2 where a in (select a from t1 where oref=t2.oref);
oref a
diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result
index 3dc019cc6c1..82b75f5daad 100644
--- a/mysql-test/main/subselect4.result
+++ b/mysql-test/main/subselect4.result
@@ -1368,8 +1368,8 @@ GROUP BY SQ1_t1.f4));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
-3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary
-3 SUBQUERY SQ1_t3 index f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using temporary
+3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE
(SELECT f2 FROM t2
WHERE f4 <= ALL
diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result
index c5fa7ddc92c..5f38d2a5d35 100644
--- a/mysql-test/main/subselect_mat.result
+++ b/mysql-test/main/subselect_mat.result
@@ -105,7 +105,7 @@ explain extended
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where;
-2 MATERIALIZED t2i index it2i1,it2i3 it2i1 # NULL 5 100.00 Using where;
+2 MATERIALIZED t2i range it2i1,it2i3 it2i1 # NULL 5 100.00 Using where;
Warnings:
Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`>(<in_optimizer>(`test`.`t1i`.`a1`,`test`.`t1i`.`a1` in ( <materialize> (/* select#2 */ select `test`.`t2i`.`b1` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery2>`.`b1`))))
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
@@ -127,7 +127,7 @@ explain extended
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1i index NULL _it1_idx # NULL 3 100.00 Using where;
-2 MATERIALIZED t2i index it2i1,it2i3 it2i3 # NULL 5 100.00 Using where;
+2 MATERIALIZED t2i range it2i1,it2i3 it2i3 # NULL 5 100.00 Using where;
Warnings:
Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery2>`.`b1` and `test`.`t1i`.`a2` = `<subquery2>`.`b2`))))
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
@@ -340,7 +340,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1i index NULL # # # 3 100.00 #
3 MATERIALIZED t3i index NULL # # # 4 100.00 #
4 MATERIALIZED t2i index it2i2 # # # 5 100.00 #
-2 MATERIALIZED t2i index it2i1,it2i3 # # # 5 100.00 #
+2 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 #
Warnings:
Note 1003 /* select#1 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery2>`.`b1` and `test`.`t1i`.`a2` = `<subquery2>`.`b2`)))) and <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#3 */ select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (/* select#4 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where `test`.`t3i`.`c1` = `<subquery4>`.`b1` and `test`.`t3i`.`c2` = `<subquery4>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery3>`.`c1` and `test`.`t1i`.`a2` = `<subquery3>`.`c2`))))
select * from t1i
@@ -423,7 +423,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
7 UNION t1i index NULL # # # 3 100.00 #
9 MATERIALIZED t3i index NULL # # # 4 100.00 #
10 MATERIALIZED t2i index it2i2 # # # 5 100.00 #
-8 MATERIALIZED t2i index it2i1,it2i3 # # # 5 100.00 #
+8 MATERIALIZED t2i range it2i1,it2i3 # # # 5 100.00 #
NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL #
Warnings:
Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#2 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery3>`.`c2`)))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery4>`.`c2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery2>`.`b1` and `test`.`t1`.`a2` = `<subquery2>`.`b2`)))) and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),(`test`.`t1`.`a1`,`test`.`t1`.`a2`) in ( <materialize> (/* select#5 */ select `test`.`t3`.`c1`,`test`.`t3`.`c2` from `test`.`t3` where <expr_cache><`test`.`t3`.`c1`,`test`.`t3`.`c2`>(<in_optimizer>((`test`.`t3`.`c1`,`test`.`t3`.`c2`),(`test`.`t3`.`c1`,`test`.`t3`.`c2`) in ( <materialize> (/* select#6 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3`.`c1` in <temporary table> on distinct_key where `test`.`t3`.`c1` = `<subquery6>`.`b1` and `test`.`t3`.`c2` = `<subquery6>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1`.`a1` in <temporary table> on distinct_key where `test`.`t1`.`a1` = `<subquery5>`.`c1` and `test`.`t1`.`a2` = `<subquery5>`.`c2`))))) union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` where <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#8 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b1` > '0' ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery8>`.`b1` and `test`.`t1i`.`a2` = `<subquery8>`.`b2`)))) and <expr_cache><`test`.`t1i`.`a1`,`test`.`t1i`.`a2`>(<in_optimizer>((`test`.`t1i`.`a1`,`test`.`t1i`.`a2`),(`test`.`t1i`.`a1`,`test`.`t1i`.`a2`) in ( <materialize> (/* select#9 */ select `test`.`t3i`.`c1`,`test`.`t3i`.`c2` from `test`.`t3i` where <expr_cache><`test`.`t3i`.`c1`,`test`.`t3i`.`c2`>(<in_optimizer>((`test`.`t3i`.`c1`,`test`.`t3i`.`c2`),(`test`.`t3i`.`c1`,`test`.`t3i`.`c2`) in ( <materialize> (/* select#10 */ select `test`.`t2i`.`b1`,`test`.`t2i`.`b2` from `test`.`t2i` where `test`.`t2i`.`b2` > '0' ), <primary_index_lookup>(`test`.`t3i`.`c1` in <temporary table> on distinct_key where `test`.`t3i`.`c1` = `<subquery10>`.`b1` and `test`.`t3i`.`c2` = `<subquery10>`.`b2`)))) ), <primary_index_lookup>(`test`.`t1i`.`a1` in <temporary table> on distinct_key where `test`.`t1i`.`a1` = `<subquery9>`.`c1` and `test`.`t1i`.`a2` = `<subquery9>`.`c2`)))))
@@ -1142,7 +1142,7 @@ a
explain extended
select a from t1 group by a having a in (select c from t2 where d >= 20);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
+1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`))))
@@ -1154,7 +1154,7 @@ create index iab on t1(a, b);
explain extended
select a from t1 group by a having a in (select c from t2 where d >= 20);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
+1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`))))
@@ -1166,7 +1166,7 @@ explain extended
select a from t1 group by a
having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index
+1 PRIMARY t1 range NULL iab 4 NULL 8 100.00 Using index for group-by
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
@@ -1889,8 +1889,8 @@ WHERE alias4.c = alias3.b
);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2
-3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2 Using where
+3 MATERIALIZED alias4 ref c c 11 test.alias3.b 2 Using where; Using index
DROP TABLE t1,t2;
#
# BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
@@ -2276,7 +2276,7 @@ WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) );
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
-2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00
Warnings:
diff --git a/mysql-test/main/subselect_mat_cost.result b/mysql-test/main/subselect_mat_cost.result
index 083917cef7e..66d48b549c4 100644
--- a/mysql-test/main/subselect_mat_cost.result
+++ b/mysql-test/main/subselect_mat_cost.result
@@ -289,7 +289,7 @@ AND Code = Country;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY CountryLanguage range PRIMARY,Language Language 30 NULL 44 Using index condition; Rowid-ordered scan
1 PRIMARY Country eq_ref PRIMARY PRIMARY 3 world.CountryLanguage.Country 1 Using where
-3 MATERIALIZED CountryLanguage ref PRIMARY,Language Language 30 const 48 Using index condition
+3 DEPENDENT SUBQUERY CountryLanguage unique_subquery PRIMARY,Language PRIMARY 33 func,const 1 Using index; Using where
set statement optimizer_switch='rowid_filter=off' for
SELECT Country.Name
FROM Country, CountryLanguage
diff --git a/mysql-test/main/subselect_mat_cost_bugs.result b/mysql-test/main/subselect_mat_cost_bugs.result
index a18c5e608f1..34c0ccab620 100644
--- a/mysql-test/main/subselect_mat_cost_bugs.result
+++ b/mysql-test/main/subselect_mat_cost_bugs.result
@@ -196,8 +196,8 @@ ORDER BY field1 ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort
1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index
-3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
-3 DEPENDENT SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
+3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
2 DERIVED t2 ALL NULL NULL NULL NULL 2
SELECT alias2.f2 AS field1
FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1
@@ -316,7 +316,7 @@ explain
select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 DEPENDENT SUBQUERY t2 index_subquery key1,key2,key3 key1 10 func,const 1 Using where
+2 DEPENDENT SUBQUERY t2 ref key1,key2,key3 key3 5 const 1 Using where
select c1 from t1 where c1 in (select kp1 from t2 where kp2 = 10 and c2 = 4) or c1 > 7;
c1
set @@optimizer_switch='default';
diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result
index d8704730a92..1436f98d9f8 100644
--- a/mysql-test/main/subselect_no_exists_to_in.result
+++ b/mysql-test/main/subselect_no_exists_to_in.result
@@ -1507,7 +1507,7 @@ 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 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 100.00 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`
@@ -3179,7 +3179,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
-2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
+2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
SELECT a, a IN (SELECT a FROM t1) FROM t2;
a a IN (SELECT a FROM t1)
1 1
@@ -7040,8 +7040,8 @@ SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1
+2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result
index f411467fa66..8100c1da7e5 100644
--- a/mysql-test/main/subselect_no_mat.result
+++ b/mysql-test/main/subselect_no_mat.result
@@ -1510,7 +1510,7 @@ 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 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 100.00 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`
@@ -3181,7 +3181,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
-2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
+2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
SELECT a, a IN (SELECT a FROM t1) FROM t2;
a a IN (SELECT a FROM t1)
1 1
diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result
index 39306df943a..689363c6d22 100644
--- a/mysql-test/main/subselect_no_opts.result
+++ b/mysql-test/main/subselect_no_opts.result
@@ -3177,7 +3177,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
-2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
+2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
SELECT a, a IN (SELECT a FROM t1) FROM t2;
a a IN (SELECT a FROM t1)
1 1
@@ -7031,8 +7031,8 @@ SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1
+2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result
index 39149cf04b7..f6f468ba1ab 100644
--- a/mysql-test/main/subselect_no_scache.result
+++ b/mysql-test/main/subselect_no_scache.result
@@ -1509,7 +1509,7 @@ 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 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 100.00 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`
@@ -3182,7 +3182,7 @@ INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 3
-2 SUBQUERY t1 index_subquery a a 5 func 2 Using index; Full scan on NULL key
+2 SUBQUERY t1 index_subquery a a 5 func 3 Using index; Full scan on NULL key
SELECT a, a IN (SELECT a FROM t1) FROM t2;
a a IN (SELECT a FROM t1)
1 1
@@ -7046,8 +7046,8 @@ SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1
+2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result
index 464df7e6539..f9bbf2e00c4 100644
--- a/mysql-test/main/subselect_no_semijoin.result
+++ b/mysql-test/main/subselect_no_semijoin.result
@@ -1632,7 +1632,7 @@ Note 1003 /* select#1 */ select `test`.`t1`.`s1` AS `s1`,!<expr_cache><`test`.`t
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 index s1 s1 6 NULL 2 50.00 Using where; Using index
+2 MATERIALIZED t2 range s1 s1 6 NULL 1 100.00 Using where; Using index
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`
drop table t1,t2;
@@ -7031,8 +7031,8 @@ SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 2 Using where; Using index
-2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
-2 SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 test.t2.c 1
+2 SUBQUERY <subquery3> ALL distinct_key NULL NULL NULL 1
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
SELECT * FROM t1
WHERE a = (SELECT MAX(b) FROM t2 WHERE c IN (SELECT MAX(d) FROM t3)) OR a = 10;
diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result
index f3519e1d846..b4ad66458dc 100644
--- a/mysql-test/main/subselect_sj.result
+++ b/mysql-test/main/subselect_sj.result
@@ -2768,8 +2768,8 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where
-1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary
-1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary
+1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11
+1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2)
3 DERIVED t1 ALL NULL NULL NULL NULL 11
SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
@@ -2777,10 +2777,10 @@ a b a b
3 1 9 1
5 8 4 0
3 9 9 1
-2 4 6 8
2 4 4 0
-2 6 6 8
+2 4 6 8
2 6 4 0
+2 6 6 8
5 4 4 0
7 7 7 7
5 4 4 0
@@ -2927,8 +2927,8 @@ alias2.col_int_key = alias1.col_int_key
WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2
1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); End temporary
SELECT *
FROM t2
diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result
index 8045a810e3f..2d0df9a05d0 100644
--- a/mysql-test/main/subselect_sj2.result
+++ b/mysql-test/main/subselect_sj2.result
@@ -304,7 +304,7 @@ from t0 where a in
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 ALL NULL NULL NULL NULL 10
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 Using where
-2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index
+2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index
2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index
2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index
drop table t0, t1,t2,t3;
@@ -957,9 +957,9 @@ SELECT d FROM t2, t1
WHERE a = d AND ( pk < 2 OR d = 'z' )
);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL b NULL NULL NULL 19
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
-2 MATERIALIZED t2 index PRIMARY,d d 9 NULL 17 Using where; Using index
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
+1 PRIMARY t1 ref b b 4 test.t2.d 1
+2 MATERIALIZED t2 index_merge PRIMARY,d d,PRIMARY 4,4 NULL 2 Using sort_union(d,PRIMARY); Using where
2 MATERIALIZED t1 ref a a 5 test.t2.d 1 Using where; Using index
SELECT * FROM t1 WHERE b IN (
SELECT d FROM t2, t1
diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result
index 22310ab5361..f0e8e9b4881 100644
--- a/mysql-test/main/subselect_sj2_jcl6.result
+++ b/mysql-test/main/subselect_sj2_jcl6.result
@@ -315,7 +315,7 @@ from t0 where a in
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 ALL NULL NULL NULL NULL 10
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 Using where
-2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index
+2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index
2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index
2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index
drop table t0, t1,t2,t3;
@@ -970,9 +970,9 @@ SELECT d FROM t2, t1
WHERE a = d AND ( pk < 2 OR d = 'z' )
);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL b NULL NULL NULL 19
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
-2 MATERIALIZED t2 index PRIMARY,d d 9 NULL 17 Using where; Using index
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
+1 PRIMARY t1 ref b b 4 test.t2.d 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
+2 MATERIALIZED t2 index_merge PRIMARY,d d,PRIMARY 4,4 NULL 2 Using sort_union(d,PRIMARY); Using where
2 MATERIALIZED t1 ref a a 5 test.t2.d 1 Using where; Using index
SELECT * FROM t1 WHERE b IN (
SELECT d FROM t2, t1
diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result
index e2c9adbfc37..9b497ade58b 100644
--- a/mysql-test/main/subselect_sj2_mat.result
+++ b/mysql-test/main/subselect_sj2_mat.result
@@ -306,7 +306,7 @@ from t0 where a in
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 ALL NULL NULL NULL NULL 10
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func 1 Using where
-2 MATERIALIZED t1 index a a 5 NULL 10 Using where; Using index
+2 MATERIALIZED t1 range a a 5 NULL 10 Using where; Using index
2 MATERIALIZED t2 ref a a 5 test.t1.a 1 Using index
2 MATERIALIZED t3 ref a a 5 test.t1.a 1 Using index
drop table t0, t1,t2,t3;
@@ -959,9 +959,9 @@ SELECT d FROM t2, t1
WHERE a = d AND ( pk < 2 OR d = 'z' )
);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL b NULL NULL NULL 19
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
-2 MATERIALIZED t2 index PRIMARY,d d 9 NULL 17 Using where; Using index
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
+1 PRIMARY t1 ref b b 4 test.t2.d 1
+2 MATERIALIZED t2 index_merge PRIMARY,d d,PRIMARY 4,4 NULL 2 Using sort_union(d,PRIMARY); Using where
2 MATERIALIZED t1 ref a a 5 test.t2.d 1 Using where; Using index
SELECT * FROM t1 WHERE b IN (
SELECT d FROM t2, t1
@@ -1727,7 +1727,7 @@ WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
HAVING f1 != 'foo'
ORDER BY f1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index f1 f1 11 NULL 2 Using where; Using index
+1 PRIMARY t1 range f1 f1 11 NULL 2 Using where; Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 11 func 1
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
DROP TABLE t1,t2;
@@ -1932,20 +1932,20 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_3 WHERE t2_3.id_t2 = 18 OR t2
AND t3.id_product IN (SELECT id_product FROM t2 t2_4 WHERE t2_4.id_t2 = 34 OR t2_4.id_t2 = 23)
AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2_5.id_t2 = 28 OR t2_5.id_t2 = 26);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 12
-1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index
-1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where
+1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 18 Using index
+1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY <subquery6> eq_ref distinct_key distinct_key 4 func 1 Using where
-1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where
-1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where
+1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index
+1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join)
-3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 Using where
-5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where
-6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where
-2 MATERIALIZED t2_1 ref id_t2,id_product id_t2 5 const 51
+3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12
4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where
+6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where
+2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where
+5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where
set optimizer_switch='rowid_filter=default';
drop table t1,t2,t3,t4,t5;
set global innodb_stats_persistent= @innodb_stats_persistent_save;
diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result
index 02e9a833db6..2301a03f973 100644
--- a/mysql-test/main/subselect_sj_jcl6.result
+++ b/mysql-test/main/subselect_sj_jcl6.result
@@ -2779,8 +2779,8 @@ SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_1 ALL NULL NULL NULL NULL 11 Using where
-1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Start temporary
-1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11 Using where; End temporary
+1 PRIMARY t1_2 ALL NULL NULL NULL NULL 11
+1 PRIMARY <derived3> ref key0 key0 5 test.t1_1.a 2 Using where; FirstMatch(t1_2)
3 DERIVED t1 ALL NULL NULL NULL NULL 11
SELECT * FROM t1 AS t1_1, t1 AS t1_2
WHERE (t1_1.a, t1_2.a) IN ( SELECT a, b FROM v1 );
@@ -2788,10 +2788,10 @@ a b a b
3 1 9 1
5 8 4 0
3 9 9 1
-2 4 6 8
2 4 4 0
-2 6 6 8
+2 4 6 8
2 6 4 0
+2 6 6 8
5 4 4 0
7 7 7 7
5 4 4 0
@@ -2938,8 +2938,8 @@ alias2.col_int_key = alias1.col_int_key
WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2
-1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary; Using join buffer (flat, BNL join)
+1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); End temporary
SELECT *
FROM t2
diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result
index 6615eb41425..695c010692c 100644
--- a/mysql-test/main/subselect_sj_mat.result
+++ b/mysql-test/main/subselect_sj_mat.result
@@ -107,10 +107,11 @@ a1 a2
explain extended
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t2i index it2i1,it2i3 it2i1 # NULL 5 50.00 Using where; Using index; LooseScan
-1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00
+1 PRIMARY t1i range _it1_idx _it1_idx # NULL 3 100.00 Using where;
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key # func 1 100.00
+2 MATERIALIZED t2i range it2i1,it2i3 it2i1 # NULL 5 100.00 Using where;
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` > '0'
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t2i`.`b1` > '0'
select * from t1i where a1 in (select b1 from t2i where b1 > '0');
a1 a2
1 - 01 2 - 01
@@ -130,10 +131,11 @@ a1 a2
explain extended
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t2i index it2i1,it2i2,it2i3 it2i3 # NULL 5 50.00 Using where; Using index; LooseScan
-1 PRIMARY t1i ref _it1_idx _it1_idx # _ref_ 1 100.00
+1 PRIMARY t1i range _it1_idx _it1_idx # NULL 3 100.00 Using where;
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key # func,func 1 100.00
+2 MATERIALIZED t2i range it2i1,it2i2,it2i3 it2i3 # NULL 5 100.00 Using where;
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0'
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) where `test`.`t2i`.`b1` > '0'
select * from t1i where (a1, a2) in (select b1, b2 from t2i where b1 > '0');
a1 a2
1 - 01 2 - 01
@@ -350,12 +352,14 @@ where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
where (c1, c2) in (select b1, b2 from t2i where b2 > '0'));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t2i index it2i1,it2i2,it2i3 # # # 5 50.00 #
-1 PRIMARY t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 #
-1 PRIMARY t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 #
-1 PRIMARY t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 #
+1 PRIMARY t1i range it1i1,it1i2,it1i3 # # # 3 100.00 #
+1 PRIMARY <subquery3> eq_ref distinct_key # # # 1 100.00 #
+1 PRIMARY <subquery2> eq_ref distinct_key # # # 1 100.00 #
+3 MATERIALIZED t3i range it3i1,it3i2,it3i3 # # # 4 100.00 #
+3 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 #
+2 MATERIALIZED t2i range it2i1,it2i2,it2i3 # # # 5 100.00 #
Warnings:
-Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0'
+Note 1003 select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t2i`.`b1` = `test`.`t3i`.`c1` and `test`.`t2i`.`b2` = `test`.`t3i`.`c2` and `test`.`t2i`.`b1` > '0' and `test`.`t3i`.`c2` > '0'
select * from t1i
where (a1, a2) in (select b1, b2 from t2i where b1 > '0') and
(a1, a2) in (select c1, c2 from t3i
@@ -438,13 +442,15 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED t2 ALL NULL # # # 5 99.22 #
4 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
3 MATERIALIZED t3 ALL NULL # # # 4 100.00 #
-7 UNION t2i index it2i1,it2i2,it2i3 # # # 5 50.00 #
-7 UNION t1i ref it1i1,it1i2,it1i3 # # # 1 100.00 #
-7 UNION t3i ref it3i1,it3i2,it3i3 # # # 1 100.00 #
-7 UNION t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 #
+7 UNION t1i range it1i1,it1i2,it1i3 # # # 3 100.00 #
+7 UNION <subquery9> eq_ref distinct_key # # # 1 100.00 #
+7 UNION <subquery8> eq_ref distinct_key # # # 1 100.00 #
+9 MATERIALIZED t3i range it3i1,it3i2,it3i3 # # # 4 100.00 #
+9 MATERIALIZED t2i ref it2i1,it2i2,it2i3 # # # 1 100.00 #
+8 MATERIALIZED t2i range it2i1,it2i2,it2i3 # # # 5 100.00 #
NULL UNION RESULT <union1,7> ALL NULL # # # NULL NULL #
Warnings:
-Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery3>`.`c2`)))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery4>`.`c2`))))) and `test`.`t3`.`c2` > '0') union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t1i`.`a1` = `test`.`t2i`.`b1` and `test`.`t3i`.`c1` = `test`.`t2i`.`b1` and `test`.`t2i`.`b1` = `test`.`t2i`.`b1` and `test`.`t1i`.`a2` = `test`.`t2i`.`b2` and `test`.`t3i`.`c2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b2` = `test`.`t2i`.`b2` and `test`.`t2i`.`b1` > '0' and `test`.`t2i`.`b2` > '0')
+Note 1003 (/* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` semi join (`test`.`t2`) semi join (`test`.`t2i` join `test`.`t3`) where `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and (<expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#3 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%02' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery3>`.`c2`)))) or <expr_cache><`test`.`t2`.`b2`>(<in_optimizer>(`test`.`t2`.`b2`,`test`.`t2`.`b2` in ( <materialize> (/* select#4 */ select `test`.`t3`.`c2` from `test`.`t3` where `test`.`t3`.`c2` like '%03' ), <primary_index_lookup>(`test`.`t2`.`b2` in <temporary table> on distinct_key where `test`.`t2`.`b2` = `<subquery4>`.`c2`))))) and `test`.`t3`.`c2` > '0') union (/* select#7 */ select `test`.`t1i`.`a1` AS `a1`,`test`.`t1i`.`a2` AS `a2` from `test`.`t1i` semi join (`test`.`t2i`) semi join (`test`.`t2i` join `test`.`t3i`) where `test`.`t2i`.`b1` = `test`.`t3i`.`c1` and `test`.`t2i`.`b2` = `test`.`t3i`.`c2` and `test`.`t2i`.`b1` > '0' and `test`.`t3i`.`c2` > '0')
(select * from t1
where (a1, a2) in (select b1, b2 from t2
where b2 in (select c2 from t3 where c2 LIKE '%02') or
@@ -1175,7 +1181,7 @@ a
explain extended
select a from t1 group by a having a in (select c from t2 where d >= 20);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
+1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`))))
@@ -1187,7 +1193,7 @@ create index iab on t1(a, b);
explain extended
select a from t1 group by a having a in (select c from t2 where d >= 20);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index NULL it1a 4 NULL 7 100.00 Using index
+1 PRIMARY t1 range NULL it1a 4 NULL 8 100.00 Using index for group-by
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` group by `test`.`t1`.`a` having <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,`test`.`t1`.`a` in ( <materialize> (/* select#2 */ select `test`.`t2`.`c` from `test`.`t2` where `test`.`t2`.`d` >= 20 ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`c`))))
@@ -1199,7 +1205,7 @@ explain extended
select a from t1 group by a
having a in (select c from t2 where d >= some(select e from t3 where max(b)=e));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 index NULL iab 8 NULL 7 100.00 Using index
+1 PRIMARY t1 range NULL iab 4 NULL 8 100.00 Using index for group-by
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00 Using where
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 4 100.00 Using where
Warnings:
@@ -2312,7 +2318,7 @@ WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) );
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
-2 DEPENDENT SUBQUERY t2 index i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
+2 DEPENDENT SUBQUERY t2 range i2 i2 5 NULL 3 100.00 Using where; Using index; Using join buffer (flat, BNL join)
2 DEPENDENT SUBQUERY t3 ref i3 i3 5 test.t2.i2 2 100.00 Using index
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00
Warnings:
diff --git a/mysql-test/main/subselect_sj_nonmerged.result b/mysql-test/main/subselect_sj_nonmerged.result
index 4d9a70e6bba..cd32c815de8 100644
--- a/mysql-test/main/subselect_sj_nonmerged.result
+++ b/mysql-test/main/subselect_sj_nonmerged.result
@@ -47,8 +47,8 @@ id select_type table type possible_keys key key_len ref rows Extra
# Compare to this which really will have 50 record combinations:
explain select * from t3 where a in (select max(t2.a) from t1, t2 group by t2.b, t1.b);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 50
-1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index
+1 PRIMARY t3 index PRIMARY PRIMARY 8 NULL 100 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t3.a 1 Using where
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using temporary
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join)
SET @save_optimizer_switch=@@optimizer_switch;
@@ -57,8 +57,8 @@ SET optimizer_switch='outer_join_with_cache=off';
explain select * from t3
where a in (select max(t2.a) from t1 left join t2 on t1.a=t2.a group by t2.b, t1.b);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 50
-1 PRIMARY t3 eq_ref PRIMARY PRIMARY 8 <subquery2>.max(t2.a) 1 Using where; Using index
+1 PRIMARY t3 index PRIMARY PRIMARY 8 NULL 100 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t3.a 1 Using where
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 10 Using temporary
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 5 Using where
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/main/table_elim.result b/mysql-test/main/table_elim.result
index f054df036e9..7b0806c63bf 100644
--- a/mysql-test/main/table_elim.result
+++ b/mysql-test/main/table_elim.result
@@ -333,11 +333,11 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select t1.a from t1 left join t2 on t2.pk between 10 and 20;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
-1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 1 Using where; Using index
explain select t1.a from t1 left join t2 on t2.pk between 0.5 and 1.5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
-1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
explain select t1.a from t1 left join t2 on t2.pk between 10 and 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
@@ -408,7 +408,7 @@ select t1.*
from t1 left join t2 on t2.pk=3 or t2.pk= 4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
-1 SIMPLE t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index
explain
select t1.*
from t1 left join t2 on t2.pk=3 or t2.pk= 3;
@@ -419,7 +419,7 @@ select t1.*
from t1 left join t2 on (t2.pk=3 and t2.b=3) or (t2.pk= 4 and t2.b=3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
-1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where
drop table t1, t2;
#
# LPBUG#523593: Running RQG optimizer_no_subquery crashes MariaDB
diff --git a/mysql-test/main/type_bit.result b/mysql-test/main/type_bit.result
index 2c9b4230022..35a05388754 100644
--- a/mysql-test/main/type_bit.result
+++ b/mysql-test/main/type_bit.result
@@ -766,7 +766,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b));
INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0);
EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort
+1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
diff --git a/mysql-test/main/type_blob.result b/mysql-test/main/type_blob.result
index be9c1569301..f514f2169dd 100644
--- a/mysql-test/main/type_blob.result
+++ b/mysql-test/main/type_blob.result
@@ -625,7 +625,7 @@ id txt
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 6 Using where
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 3 Using where
explain select * from t1 FORCE INDEX (`txt_index`) where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 3 Using where
diff --git a/mysql-test/main/type_enum.result b/mysql-test/main/type_enum.result
index 02d71c6bd9f..ca909e1a2f2 100644
--- a/mysql-test/main/type_enum.result
+++ b/mysql-test/main/type_enum.result
@@ -1932,16 +1932,14 @@ ALTER TABLE t2 ADD PRIMARY KEY(c1);
SELECT t1.* FROM t1 JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
c1
a
-a
SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
c1
a
-a
# t2 should NOT be eliminated
EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
-1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 1 NULL 1 Using where; Using index
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (c1 SET('a') CHARACTER SET latin1 PRIMARY KEY);
INSERT INTO t1 VALUES ('a');
@@ -1959,16 +1957,14 @@ ALTER TABLE t2 ADD PRIMARY KEY(c1);
SELECT t1.* FROM t1 JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
c1
a
-a
SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
c1
a
-a
# t2 should NOT be eliminated
EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
-1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 1 NULL 1 Using where; Using index
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (c1 VARCHAR(10) CHARACTER SET latin1 PRIMARY KEY);
INSERT INTO t1 VALUES ('a');
@@ -1986,16 +1982,14 @@ ALTER TABLE t2 ADD PRIMARY KEY(c1);
SELECT t1.* FROM t1 JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
c1
a
-a
SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
c1
a
-a
# t2 should NOT be eliminated
EXPLAIN SELECT t1.* FROM t1 LEFT JOIN t2 ON t1.c1 COLLATE latin1_swedish_ci=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system NULL NULL NULL NULL 1
-1 SIMPLE t2 index PRIMARY PRIMARY 1 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY PRIMARY 1 NULL 1 Using where; Using index
DROP TABLE IF EXISTS t1,t2;
#
# MDEV-6991 GROUP_MIN_MAX optimization is erroneously applied in some cases
diff --git a/mysql-test/suite/gcol/r/gcol_bugfixes.result b/mysql-test/suite/gcol/r/gcol_bugfixes.result
index 3a859116cab..c750187e512 100644
--- a/mysql-test/suite/gcol/r/gcol_bugfixes.result
+++ b/mysql-test/suite/gcol/r/gcol_bugfixes.result
@@ -241,7 +241,7 @@ pk >= 8
HAVING x > '2000-02-06'
ORDER BY col_time_nokey, pk;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE c ALL PRIMARY,col_varchar_key,col_varchar_key_2 NULL NULL NULL 6 Using where
+1 SIMPLE c index_merge PRIMARY,col_varchar_key,col_varchar_key_2 col_varchar_key,PRIMARY 5,4 NULL 2 Using union(col_varchar_key,PRIMARY); Using where
SELECT COUNT(DISTINCT col_varchar_key) AS x
FROM c
WHERE col_varchar_key IN ('rr', 'rr') OR
diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result b/mysql-test/suite/gcol/r/gcol_keys_innodb.result
index a1cc26a8f06..2028a95a081 100644
--- a/mysql-test/suite/gcol/r/gcol_keys_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result
@@ -205,7 +205,7 @@ outr.col_varchar_nokey in ('c', 'x', 'i')
AND (outr.col_time_key IS NULL OR
outr.col_datetime_key = '2009-09-27');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE outr ALL col_time_key,col_datetime_key NULL NULL NULL 4 x
+1 SIMPLE outr index_merge col_time_key,col_datetime_key col_time_key,col_datetime_key 4,6 NULL 2 x
SELECT
outr.col_time_key AS x
FROM c AS outr
diff --git a/mysql-test/suite/gcol/r/gcol_select_innodb.result b/mysql-test/suite/gcol/r/gcol_select_innodb.result
index 6c5b6d8c47e..392fb0de7a2 100644
--- a/mysql-test/suite/gcol/r/gcol_select_innodb.result
+++ b/mysql-test/suite/gcol/r/gcol_select_innodb.result
@@ -89,8 +89,8 @@ a b c
2 -2 -2
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index
-1 PRIMARY t1 ALL c NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index
+1 PRIMARY t1 ref c c 5 test.t3.c 1
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
select * from t1 union select * from t2;
@@ -146,7 +146,7 @@ count(distinct c)
3
explain select count(distinct c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by (scanning)
+1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by
###
### filesort & range-based utils
###
diff --git a/mysql-test/suite/gcol/r/gcol_select_myisam.result b/mysql-test/suite/gcol/r/gcol_select_myisam.result
index c19ea3207ca..88623028b54 100644
--- a/mysql-test/suite/gcol/r/gcol_select_myisam.result
+++ b/mysql-test/suite/gcol/r/gcol_select_myisam.result
@@ -89,7 +89,7 @@ a b c
2 -2 -2
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index
+1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index
1 PRIMARY t1 ref c c 5 test.t3.c 1
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
@@ -146,7 +146,7 @@ count(distinct c)
3
explain select count(distinct c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by (scanning)
+1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by
###
### filesort & range-based utils
###
@@ -1121,7 +1121,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t2 AS t1 WHERE b NOT IN (SELECT b FROM t1 FORCE INDEX(b));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
-2 SUBQUERY t1 index_subquery b b 5 func 2 Using index; Full scan on NULL key
+2 SUBQUERY t1 index_subquery b b 5 func 3 Using index; Full scan on NULL key
DROP TABLE t1;
DROP TABLE t2, t3;
#
diff --git a/mysql-test/suite/heap/heap.result b/mysql-test/suite/heap/heap.result
index 5e6cfde8410..23c1069e54a 100644
--- a/mysql-test/suite/heap/heap.result
+++ b/mysql-test/suite/heap/heap.result
@@ -66,7 +66,7 @@ a
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index
+1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
drop table t1;
create table t1 (x int not null, y int not null, key x (x), unique y (y))
engine=heap;
diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result
index 8c1c8217b6a..5778ff0dd55 100644
--- a/mysql-test/suite/heap/heap_btree.result
+++ b/mysql-test/suite/heap/heap_btree.result
@@ -63,10 +63,13 @@ a
736494
802616
869751
+explain select * from t1 where a in (869751,736494,226312,802616);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index
+1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
drop table t1;
create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
engine=heap;
@@ -172,7 +175,7 @@ f1 f2
12 ted
drop table t1;
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
-insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("hello"),("hello"), ("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
explain select * from t1 where btn like "i%";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range btn btn 10 NULL 1 Using where
@@ -368,6 +371,7 @@ select 0+a from t1 where a=869751 or a=736494;
explain select 0+a from t1 where a=869751 or a=736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
+insert into t1 (a) select * from seq_1_to_100;
select 0+a from t1 where a in (869751,736494,226312,802616);
0+a
226312
diff --git a/mysql-test/suite/heap/heap_btree.test b/mysql-test/suite/heap/heap_btree.test
index 6e087c7ef24..d3fbe4cc0d2 100644
--- a/mysql-test/suite/heap/heap_btree.test
+++ b/mysql-test/suite/heap/heap_btree.test
@@ -1,3 +1,5 @@
+--source include/have_sequence.inc
+
#
# Test of heap tables.
#
@@ -41,7 +43,9 @@ alter table t1 add unique uniq_id using BTREE (a);
select * from t1 where a > 736494;
select * from t1 where a = 736494;
select * from t1 where a=869751 or a=736494;
+--sorted_result
select * from t1 where a in (869751,736494,226312,802616);
+explain select * from t1 where a in (869751,736494,226312,802616);
alter table t1 engine=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
drop table t1;
@@ -110,7 +114,7 @@ drop table t1;
#
create table t1 (btn char(10) not null, key using BTREE (btn)) engine=heap;
-insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("hello"),("hello"), ("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
explain select * from t1 where btn like "i%";
--replace_column 9 #
explain select * from t1 where btn like "h%";
@@ -269,12 +273,14 @@ DROP TABLE t1;
create table t1 (a bit(63) not null) engine=heap;
insert into t1 values (869751),(736494),(226312),(802616),(728912);
alter table t1 add unique uniq_id using BTREE (a);
+--sorted_result
select 0+a from t1 where a > 736494;
explain select 0+a from t1 where a > 736494;
select 0+a from t1 where a = 736494;
explain select 0+a from t1 where a = 736494;
select 0+a from t1 where a=869751 or a=736494;
explain select 0+a from t1 where a=869751 or a=736494;
+insert into t1 (a) select * from seq_1_to_100;
select 0+a from t1 where a in (869751,736494,226312,802616);
explain select 0+a from t1 where a in (869751,736494,226312,802616);
drop table t1;
diff --git a/mysql-test/suite/innodb/r/full_crc32_import.result b/mysql-test/suite/innodb/r/full_crc32_import.result
index b8ebbb73706..06da5716aae 100644
--- a/mysql-test/suite/innodb/r/full_crc32_import.result
+++ b/mysql-test/suite/innodb/r/full_crc32_import.result
@@ -5,6 +5,7 @@ CREATE TABLE t1
b blob,
c blob,
KEY (b(200))) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+BEGIN;
INSERT INTO t1 (b, c) values (repeat("ab", 200), repeat("bc", 200));
INSERT INTO t1 (b, c) values (repeat("bc", 200), repeat("cd", 200));
INSERT INTO t1 (b, c) values (repeat("cd", 200), repeat("ef", 200));
@@ -17,6 +18,7 @@ INSERT INTO t1 (b, c) values (repeat("ij", 200), repeat("kl", 200));
INSERT INTO t1 (b, c) values (repeat("jk", 200), repeat("lm", 200));
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
+COMMIT;
SELECT COUNT(*) FROM t1;
COUNT(*)
40
@@ -85,6 +87,7 @@ ST_GeomFromText('LINESTRING(15 15,24 10,31 20)'));
INSERT INTO t1(c2,c3) VALUES(
ST_GeomFromText('POINT(60 50)'),
ST_GeomFromText('LINESTRING(10 15,20 44,35 32)'));
+BEGIN;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
@@ -96,6 +99,7 @@ INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
+COMMIT;
FLUSH TABLE t1 FOR EXPORT;
# List before copying files
db.opt
diff --git a/mysql-test/suite/innodb/r/innodb-isolation.result b/mysql-test/suite/innodb/r/innodb-isolation.result
index a308f10a8a9..ce9c530ff44 100644
--- a/mysql-test/suite/innodb/r/innodb-isolation.result
+++ b/mysql-test/suite/innodb/r/innodb-isolation.result
@@ -963,15 +963,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 12 #
EXPLAIN SELECT c1, c2 FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index PRIMARY k2 5 NULL 12 #
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
EXPLAIN SELECT COUNT(c2) FROM t1 WHERE c1 > ((SELECT COUNT(*) FROM t1) / 2);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index PRIMARY k2 5 NULL 12 #
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 8 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1 > (SELECT AVG(c1) FROM t1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index PRIMARY k2 5 NULL 12 #
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 7 #
2 SUBQUERY t1 index NULL k2 5 NULL 12 #
#
# Make all indexes in t2 obsolete to the active repeatable read transaction
diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result
index acd66549d42..31db0622fe1 100644
--- a/mysql-test/suite/innodb/r/innodb_mysql.result
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result
@@ -361,13 +361,13 @@ EXPLAIN
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t1 range PRIMARY,name name 23 NULL 2 Using where; Using index
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index
EXPLAIN
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t1 range PRIMARY,name name 23 NULL 2 Using where; Using index
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using index
DROP TABLE t1,t2;
CREATE TABLE t1 (
@@ -405,7 +405,7 @@ DELETE FROM t1;
# Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746).
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range name name 44 NULL # Using where; Using index for group-by
+1 SIMPLE t1 ref name name 22 const # Using where; Using index
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
name dept
DROP TABLE t1;
@@ -1312,13 +1312,13 @@ EXPLAIN SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a;
id 1
select_type SIMPLE
table t1
-type index
+type range
possible_keys bkey
-key PRIMARY
-key_len 4
+key bkey
+key_len 5
ref NULL
rows 32
-Extra Using where
+Extra Using where; Using index; Using filesort
SELECT * FROM t1 WHERE b BETWEEN 1 AND 2 ORDER BY a;
a b
1 2
@@ -2367,12 +2367,12 @@ EXPLAIN SELECT c FROM foo2 WHERE b>2;;
id 1
select_type SIMPLE
table foo2
-type index
+type range
possible_keys b
key b
key_len 5
ref NULL
-rows 6
+rows 5
Extra Using where; Using index
EXPLAIN SELECT c FROM bar WHERE c>2;;
id 1
@@ -3067,7 +3067,7 @@ f1 f2 f3 f4
EXPLAIN SELECT * FROM t1 WHERE f2 = 1 AND f4 = TRUE
ORDER BY f1 DESC LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index f2,f4 PRIMARY 4 NULL 5 Using where
+1 SIMPLE t1 range f2,f4 f4 1 NULL 22 Using where
DROP TABLE t1;
#
# Bug#54117 crash in thr_multi_unlock, temporary table
diff --git a/mysql-test/suite/innodb/r/innodb_wl6326.result b/mysql-test/suite/innodb/r/innodb_wl6326.result
index 6f7ad8a3de4..96352630c1b 100644
--- a/mysql-test/suite/innodb/r/innodb_wl6326.result
+++ b/mysql-test/suite/innodb/r/innodb_wl6326.result
@@ -54,7 +54,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-4
+3
INSERT INTO t1 (a00) VALUES ('al');
INSERT INTO t1 (a00) VALUES ('am');
INSERT INTO t1 (a00) VALUES ('an');
@@ -68,7 +68,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-5
+4
INSERT INTO t1 (a00) VALUES ('as');
INSERT INTO t1 (a00) VALUES ('at');
INSERT INTO t1 (a00) VALUES ('au');
@@ -82,7 +82,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-6
+5
INSERT INTO t1 (a00) VALUES ('az');
INSERT INTO t1 (a00) VALUES ('ba');
INSERT INTO t1 (a00) VALUES ('bb');
@@ -96,7 +96,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-7
+6
INSERT INTO t1 (a00) VALUES ('bg');
INSERT INTO t1 (a00) VALUES ('bh');
INSERT INTO t1 (a00) VALUES ('bi');
@@ -110,7 +110,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-8
+7
INSERT INTO t1 (a00) VALUES ('bn');
INSERT INTO t1 (a00) VALUES ('bo');
INSERT INTO t1 (a00) VALUES ('bp');
@@ -124,7 +124,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-11
+8
INSERT INTO t1 (a00) VALUES ('bu');
INSERT INTO t1 (a00) VALUES ('bv');
INSERT INTO t1 (a00) VALUES ('bw');
@@ -152,7 +152,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-15
+13
INSERT INTO t1 (a00) VALUES ('cp');
INSERT INTO t1 (a00) VALUES ('cq');
INSERT INTO t1 (a00) VALUES ('cr');
@@ -208,7 +208,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT CLUST_INDEX_SIZE FROM information_schema.INNODB_SYS_TABLESTATS WHERE NAME = 'test/t1';
CLUST_INDEX_SIZE
-23
+21
INSERT INTO t1 (a00) VALUES ('em');
INSERT INTO t1 (a00) VALUES ('en');
INSERT INTO t1 (a00) VALUES ('eo');
diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result
index 4cfe85090b6..c382c1e8507 100644
--- a/mysql-test/suite/innodb/r/monitor.result
+++ b/mysql-test/suite/innodb/r/monitor.result
@@ -477,7 +477,7 @@ if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 2 NULL 2 2 NULL 2 enabled
+dml_reads 4 NULL 4 4 NULL 4 enabled
dml_inserts 1 NULL 1 1 NULL 1 enabled
dml_deletes 0 NULL 0 0 NULL 0 enabled
dml_updates 2 NULL 2 2 NULL 2 enabled
@@ -492,7 +492,7 @@ if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 4 NULL 4 4 NULL 4 enabled
+dml_reads 6 NULL 6 6 NULL 6 enabled
dml_inserts 1 NULL 1 1 NULL 1 enabled
dml_deletes 2 NULL 2 2 NULL 2 enabled
dml_updates 2 NULL 2 2 NULL 2 enabled
@@ -507,7 +507,7 @@ if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 4 NULL 4 0 NULL 0 enabled
+dml_reads 6 NULL 6 0 NULL 0 enabled
dml_inserts 1 NULL 1 0 NULL 0 enabled
dml_deletes 2 NULL 2 0 NULL 0 enabled
dml_updates 2 NULL 2 0 NULL 0 enabled
@@ -524,7 +524,7 @@ if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 6 NULL 6 2 NULL 2 enabled
+dml_reads 8 NULL 8 2 NULL 2 enabled
dml_inserts 3 NULL 3 2 NULL 2 enabled
dml_deletes 4 NULL 4 2 NULL 2 enabled
dml_updates 2 NULL 2 0 NULL 0 enabled
@@ -539,7 +539,7 @@ if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 6 NULL 6 2 NULL 2 enabled
+dml_reads 8 NULL 8 2 NULL 2 enabled
dml_inserts 3 NULL 3 2 NULL 2 enabled
dml_deletes 4 NULL 4 2 NULL 2 enabled
dml_updates 2 NULL 2 0 NULL 0 enabled
@@ -554,7 +554,7 @@ if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "dml%";
name max_count min_count count max_count_reset min_count_reset count_reset status
-dml_reads 6 NULL 6 2 NULL 2 disabled
+dml_reads 8 NULL 8 2 NULL 2 disabled
dml_inserts 3 NULL 3 2 NULL 2 disabled
dml_deletes 4 NULL 4 2 NULL 2 disabled
dml_updates 2 NULL 2 0 NULL 0 disabled
diff --git a/mysql-test/suite/innodb/r/temporary_table.result b/mysql-test/suite/innodb/r/temporary_table.result
index d7ea25fa117..871c4c62446 100644
--- a/mysql-test/suite/innodb/r/temporary_table.result
+++ b/mysql-test/suite/innodb/r/temporary_table.result
@@ -28,7 +28,7 @@ id select_type table type possible_keys key key_len ref rows Extra
alter table t1 add index sec_index(f);
explain select * from t1 where f > 1.29999;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL sec_index NULL NULL NULL 5 Using where
+1 SIMPLE t1 range sec_index sec_index 5 NULL 3 Using index condition
select * from t1 where f > 1.29999;
i f c
98 1.3 jaipur
diff --git a/mysql-test/suite/innodb/r/temporary_table_optimization.result b/mysql-test/suite/innodb/r/temporary_table_optimization.result
index c3325d86386..3459dbb7837 100644
--- a/mysql-test/suite/innodb/r/temporary_table_optimization.result
+++ b/mysql-test/suite/innodb/r/temporary_table_optimization.result
@@ -128,7 +128,7 @@ ERROR 23000: Duplicate entry '2.5' for key 'sec_index'
alter table t1 add index sec_index(t1_f);
explain select * from t1 where t1_f >= 2.5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL sec_index NULL NULL NULL 4 Using where
+1 SIMPLE t1 range sec_index sec_index 5 NULL 3 Using index condition
select * from t1 where t1_f >= 2.5;
t1_i t1_f
2 2.5
diff --git a/mysql-test/suite/innodb/t/full_crc32_import.test b/mysql-test/suite/innodb/t/full_crc32_import.test
index 2c11a2423e6..aa4db3f9bf7 100644
--- a/mysql-test/suite/innodb/t/full_crc32_import.test
+++ b/mysql-test/suite/innodb/t/full_crc32_import.test
@@ -15,6 +15,7 @@ CREATE TABLE t1
c blob,
KEY (b(200))) ENGINE=InnoDB ROW_FORMAT=COMPACT;
+BEGIN;
INSERT INTO t1 (b, c) values (repeat("ab", 200), repeat("bc", 200));
INSERT INTO t1 (b, c) values (repeat("bc", 200), repeat("cd", 200));
INSERT INTO t1 (b, c) values (repeat("cd", 200), repeat("ef", 200));
@@ -27,6 +28,7 @@ INSERT INTO t1 (b, c) values (repeat("ij", 200), repeat("kl", 200));
INSERT INTO t1 (b, c) values (repeat("jk", 200), repeat("lm", 200));
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
INSERT INTO t1 (b, c) SELECT b,c FROM t1 ORDER BY a;
+COMMIT;
SELECT COUNT(*) FROM t1;
FLUSH TABLE t1 FOR EXPORT;
@@ -95,6 +97,7 @@ INSERT INTO t1(c2,c3) VALUES(
ST_GeomFromText('POINT(60 50)'),
ST_GeomFromText('LINESTRING(10 15,20 44,35 32)'));
+BEGIN;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
@@ -106,6 +109,7 @@ INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
INSERT INTO t1(c2, c3) SELECT c2, c3 FROM t1;
+COMMIT;
FLUSH TABLE t1 FOR EXPORT;
--echo # List before copying files
diff --git a/mysql-test/suite/innodb/t/mdev-117.test b/mysql-test/suite/innodb/t/mdev-117.test
index 991221b6f6f..b29b2cd5bd5 100644
--- a/mysql-test/suite/innodb/t/mdev-117.test
+++ b/mysql-test/suite/innodb/t/mdev-117.test
@@ -22,8 +22,10 @@ SELECT col_int_key FROM t1;
DELETE FROM t1 WHERE col_int_key IN (1, 40000000);
--connection default
+--disable_warnings
--error 0,ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
--reap
+--enable_warnings
--disconnect con1
drop table t1;
diff --git a/mysql-test/suite/innodb_gis/r/rtree_estimate.result b/mysql-test/suite/innodb_gis/r/rtree_estimate.result
index edb37778f54..dafcc40aba8 100644
--- a/mysql-test/suite/innodb_gis/r/rtree_estimate.result
+++ b/mysql-test/suite/innodb_gis/r/rtree_estimate.result
@@ -30,7 +30,7 @@ ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g1);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL g NULL NULL NULL 3 Using where
+1 SIMPLE t1 range g g 34 NULL 2 Using where
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
@@ -75,14 +75,14 @@ POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g2);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL g NULL NULL NULL 3 Using where
+1 SIMPLE t1 range g g 34 NULL 2 Using where
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL g NULL NULL NULL 3 Using where
+1 SIMPLE t1 range g g 34 NULL 2 Using where
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result
index e8196d4da20..ad8b3b01dfe 100644
--- a/mysql-test/suite/maria/icp.result
+++ b/mysql-test/suite/maria/icp.result
@@ -409,7 +409,7 @@ WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240
ORDER BY c1
LIMIT 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using where
+1 SIMPLE t1 range PRIMARY,k1 PRIMARY 4 NULL 3 Using index condition; Using where; Rowid-ordered scan; Using filesort
DROP TABLE t1;
#
#
@@ -677,16 +677,18 @@ DROP TABLE t1;
#
CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b));
INSERT INTO t1 VALUES (1,4,'Ill');
+insert into t1 select seq+100,5,seq from seq_1_to_100;
CREATE TABLE t2 (a varchar(1024), KEY (a(512)));
INSERT INTO t2 VALUES
('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w');
+insert into t2 select seq from seq_1_to_100;
SET SESSION optimizer_switch='index_condition_pushdown=off';
EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
-1 SIMPLE t2 ref a a 515 const 1 Using where
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 101 Using where; Using filesort
+1 SIMPLE t2 ref a a 515 test.t1.a 10 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
b c
@@ -696,8 +698,8 @@ EXPLAIN
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
-1 SIMPLE t2 ref a a 515 const 1 Using where
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 101 Using where; Using filesort
+1 SIMPLE t2 ref a a 515 test.t1.a 10 Using where
SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
HAVING t1.c != 5 ORDER BY t1.c;
b c
diff --git a/mysql-test/suite/maria/maria.result b/mysql-test/suite/maria/maria.result
index 6c4ccbb6210..eaa4fa568a5 100644
--- a/mysql-test/suite/maria/maria.result
+++ b/mysql-test/suite/maria/maria.result
@@ -400,7 +400,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a a 4 test.t2.a 1
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 10 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
diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result
index af87b4a5455..1ac4bb32a49 100644
--- a/mysql-test/suite/vcol/r/vcol_select_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result
@@ -73,8 +73,8 @@ a b c
1 -1 -1
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 index c c 5 NULL 6 Using where; Using index
-1 PRIMARY t1 ALL c NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index
+1 PRIMARY t1 ref c c 5 test.t3.c 1
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
select * from t1 union select * from t2;
@@ -133,7 +133,7 @@ count(distinct c)
3
explain select count(distinct c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by (scanning)
+1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by
###
### filesort & range-based utils
###
diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result
index d7a579a3a77..fb6da695896 100644
--- a/mysql-test/suite/vcol/r/vcol_select_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result
@@ -73,8 +73,8 @@ a b c
1 -1 -1
explain select * from t1 where c in (select c from t3 where c between -2 and -1);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range c c 5 NULL 3 Using index condition
-1 PRIMARY t3 ref c c 5 test.t1.c 1 Using index
+1 PRIMARY t3 range c c 5 NULL 2 Using where; Using index
+1 PRIMARY t1 ref c c 5 test.t3.c 2
# select_type=UNION, type=system
# select_type=UNION RESULT, type=<union1,2>
select * from t1 union select * from t2;
@@ -133,7 +133,7 @@ count(distinct c)
3
explain select count(distinct c) from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by (scanning)
+1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by
###
### filesort & range-based utils
###
diff --git a/mysql-test/suite/versioning/r/cte.result b/mysql-test/suite/versioning/r/cte.result
index 30003146da7..7194b9abcf6 100644
--- a/mysql-test/suite/versioning/r/cte.result
+++ b/mysql-test/suite/versioning/r/cte.result
@@ -138,14 +138,13 @@ where e.mgr = a.emp_id
select name from emp where emp_id in (select emp_id from ancestors for system_time as of timestamp @ts_1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY emp ALL PRIMARY NULL NULL NULL 4 100.00 Using where
-1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 100.00
-4 MATERIALIZED <derived2> ALL NULL NULL NULL NULL 4 100.00
+1 PRIMARY <derived2> ref key0 key0 5 test.emp.emp_id 2 100.00 FirstMatch(emp)
2 DERIVED e ALL NULL NULL NULL NULL 4 100.00 Using where
3 RECURSIVE UNION e ALL mgr-fk NULL NULL NULL 4 100.00 Using where
3 RECURSIVE UNION <derived2> ref key0 key0 5 test.e.mgr 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME ALL `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME ALL `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `test`.`emp`.`name` AS `name` from `test`.`emp` FOR SYSTEM_TIME ALL semi join (`ancestors`) where `test`.`emp`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999'
+Note 1003 with recursive ancestors as (/* select#2 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME ALL `e` where `test`.`e`.`name` = 'bill' and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1` union /* select#3 */ select `test`.`e`.`emp_id` AS `emp_id`,`test`.`e`.`name` AS `name`,`test`.`e`.`mgr` AS `mgr`,`test`.`e`.`salary` AS `salary` from `test`.`emp` FOR SYSTEM_TIME ALL `e` join `ancestors` `a` where `a`.`emp_id` = `test`.`e`.`mgr` and `test`.`e`.`row_end` > @`ts_1` and `test`.`e`.`row_start` <= @`ts_1`)/* select#1 */ select `test`.`emp`.`name` AS `name` from `test`.`emp` FOR SYSTEM_TIME ALL semi join (`ancestors`) where `ancestors`.`emp_id` = `test`.`emp`.`emp_id` and `test`.`emp`.`row_end` = TIMESTAMP'2038-01-19 03:14:07.999999'
with recursive
ancestors
as
diff --git a/sql/filesort_utils.cc b/sql/filesort_utils.cc
index 5bd552f76be..27f37d1d507 100644
--- a/sql/filesort_utils.cc
+++ b/sql/filesort_utils.cc
@@ -52,9 +52,9 @@ double get_merge_many_buffs_cost_fast(ha_rows num_rows,
// Calculate CPU cost of sorting buffers.
total_cost=
- ( num_buffers * num_keys_per_buffer * log(1.0 + num_keys_per_buffer) +
- last_n_elems * log(1.0 + last_n_elems) )
- / TIME_FOR_COMPARE_ROWID;
+ ((num_buffers * num_keys_per_buffer * log(1.0 + num_keys_per_buffer) +
+ last_n_elems * log(1.0 + last_n_elems)) /
+ TIME_FOR_COMPARE_ROWID);
// Simulate behavior of merge_many_buff().
while (num_buffers >= MERGEBUFF2)
diff --git a/sql/handler.cc b/sql/handler.cc
index 437492fb2bf..c44e61ade87 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2818,8 +2818,8 @@ double handler::keyread_time(uint index, uint ranges, ha_rows rows)
double cost= (double)rows*len/(stats.block_size+1)*IDX_BLOCK_COPY_COST;
if (ranges)
{
- uint keys_per_block= (uint) (stats.block_size/2.0/len+1);
- ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1;
+ uint keys_per_block= (uint) (stats.block_size*3/4/len+1);
+ ulonglong blocks= (rows+ keys_per_block- 1)/keys_per_block;
cost+= blocks;
}
return cost;
@@ -2972,6 +2972,8 @@ int handler::ha_close(void)
/* Detach from ANALYZE tracker */
tracker= NULL;
+ /* We use ref as way to check that open succeded */
+ ref= 0;
DBUG_ASSERT(m_lock_type == F_UNLCK);
DBUG_ASSERT(inited == NONE);
diff --git a/sql/handler.h b/sql/handler.h
index cbc80267bdd..c3de2cb4752 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -2694,7 +2694,7 @@ public:
{
return IO_COEFF*io_count*avg_io_cost +
IO_COEFF*idx_io_count*idx_avg_io_cost +
- CPU_COEFF*cpu_cost +
+ CPU_COEFF*(cpu_cost + idx_cpu_cost) +
MEM_COEFF*mem_cost + IMPORT_COEFF*import_cost;
}
@@ -3258,6 +3258,11 @@ public:
DBUG_ASSERT(m_lock_type == F_UNLCK);
DBUG_ASSERT(inited == NONE);
}
+ /* To check if table has been properely opened */
+ bool is_open()
+ {
+ return ref != 0;
+ }
virtual handler *clone(const char *name, MEM_ROOT *mem_root);
bool clone_handler_for_update();
void delete_update_handler();
@@ -3461,19 +3466,28 @@ public:
reset_statistics();
}
virtual double scan_time()
- { return ulonglong2double(stats.data_file_length) / IO_SIZE + 2; }
+ {
+ return ((ulonglong2double(stats.data_file_length) / stats.block_size + 2) *
+ avg_io_cost());
+ }
virtual double key_scan_time(uint index)
{
return keyread_time(index, 1, records());
}
+ virtual double avg_io_cost()
+ {
+ return 1.0;
+ }
+
/**
The cost of reading a set of ranges from the table using an index
to access it.
@param index The index number.
- @param ranges The number of ranges to be read.
+ @param ranges The number of ranges to be read. If 0, it means that
+ we calculate separately the cost of reading the key.
@param rows Total number of rows to be read.
This method can be used to calculate the total cost of scanning a table
@@ -4912,6 +4926,7 @@ public:
ha_share= arg_ha_share;
return false;
}
+ void set_table(TABLE* table_arg) { table= table_arg; }
int get_lock_type() const { return m_lock_type; }
public:
/* XXX to be removed, see ha_partition::partition_ht() */
diff --git a/sql/item_func.cc b/sql/item_func.cc
index b75bae596e8..ead72007518 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -5901,7 +5901,7 @@ bool Item_func_match::init_search(THD *thd, bool no_order)
{
DBUG_ENTER("Item_func_match::init_search");
- if (!table->file->get_table()) // the handler isn't opened yet
+ if (!table->file->is_open())
DBUG_RETURN(0);
/* Check if init_search() has been called before */
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 18c821d2e63..a2d15ff424f 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -56,28 +56,67 @@
contain scan parameters.
*/
-ha_rows
+ha_rows
handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param, uint n_ranges_arg,
- uint *bufsz, uint *flags, Cost_estimate *cost)
+ uint *bufsz, uint *flags,
+ Cost_estimate *cost)
{
KEY_MULTI_RANGE range;
range_seq_t seq_it;
ha_rows total_rows= 0;
uint n_ranges=0;
- uint n_eq_ranges= 0;
- ulonglong total_touched_blocks= 0;
ha_rows max_rows= stats.records;
THD *thd= table->in_use;
- uint limit= thd->variables.eq_range_index_dive_limit;
- bool use_statistics_for_eq_range= eq_ranges_exceeds_limit(seq,
- seq_init_param,
- limit);
+ ulonglong io_blocks;
+
+ /*
+ Counter of blocks that contain range edges for those ranges
+ for which records_in_range() is called
+ */
+ ulonglong edge_blocks_cnt= 0;
+ /*
+ Counter of blocks that contain index tuples for those ranges
+ for which records_in_range() is called
+ */
+ ulonglong range_blocks_cnt= 0;
+ /*
+ The position of the block containing the last record of the previous range
+ for which the info about range position is provided
+ */
+ ulonglong prev_range_last_block= UNUSED_PAGE_NO;
+ /* The counter of records the staring from prev_range_last_block */
+ ulonglong prev_range_last_block_records= 0;
+ /*
+ The counter of single point ranges.
+ (For single point ranges we do not call records_in_range())
+ */
+ ulonglong single_point_ranges= 0;
+ /*
+ The counter of of single point ranges that we succeded to assign
+ to some blocks
+ */
+ ulonglong assigned_single_point_ranges= 0;
+ /*
+ Counter of single point ranges for which records_in_range in not
+ called and that are encountered between two ranges without such property
+ For example, let's have a subsequence of ranges
+ R1,r1,....rk,R2
+ where r1,...,rk are single point ranges for which records_in_range is
+ called while R1 and R2 are not such ranges.
+ Then single_point_ranges_delta will count ranges r1,...,rk.
+ */
+ ulonglong unassigned_single_point_ranges= 0;
+
uint len= table->key_info[keyno].key_length + table->file->ref_length;
if (table->file->is_clustering_key(keyno))
len= table->s->stored_rec_length;
/* Assume block is 75 % full */
- uint avg_block_records= ((uint) (table->file->stats.block_size*3/4))/len + 1;
+ uint avg_block_records= ((uint) (stats.block_size*3/4))/len + 1;
+ uint limit= thd->variables.eq_range_index_dive_limit;
+ bool use_statistics_for_eq_range= eq_ranges_exceeds_limit(seq,
+ seq_init_param,
+ limit);
DBUG_ENTER("multi_range_read_info_const");
/* Default MRR implementation doesn't need buffer */
@@ -90,10 +129,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
if (unlikely(thd->killed != 0))
DBUG_RETURN(HA_POS_ERROR);
-
+
n_ranges++;
- if (range.range_flag & EQ_RANGE)
- n_eq_ranges++;
key_range *min_endp, *max_endp;
if (range.range_flag & GEOM_FLAG)
{
@@ -108,67 +145,192 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
max_endp= range.end_key.length? &range.end_key : NULL;
}
int keyparts_used= my_count_bits(range.start_key.keypart_map);
- if (use_statistics_for_eq_range &&
- !(range.range_flag & NULL_RANGE) &&
- (range.range_flag & EQ_RANGE) &&
- table->key_info[keyno].actual_rec_per_key(keyparts_used - 1) > 0.5)
+
+ if ((range.range_flag & UNIQUE_RANGE) && !(range.range_flag & NULL_RANGE))
{
- if ((range.range_flag & UNIQUE_RANGE) && !(range.range_flag & NULL_RANGE))
- rows= 1; /* there can be at most one row */
- else
- rows=
- (ha_rows) table->key_info[keyno].actual_rec_per_key(keyparts_used-1);
+ rows= 1;
+ /*
+ In this case we do not call records_in_range() and as a result
+ do not get any info on the edge blocks for this range. However if it
+ happens that the range for which we have such info uses the same block
+ for its first record as the last range for which such info is
+ provided uses for its last record then this range can be assigned
+ later to one of the blocks used by other ranges.
+
+ Note that we don't have to increment edge_blocks_cnt or
+ range_blocks_cnt here.
+ */
+ single_point_ranges++;
+ }
+ else if (use_statistics_for_eq_range &&
+ !(range.range_flag & NULL_RANGE) &&
+ (range.range_flag & EQ_RANGE) &&
+ table->key_info[keyno].actual_rec_per_key(keyparts_used - 1) > 0.5)
+ {
+ rows= ((ha_rows) table->key_info[keyno].
+ actual_rec_per_key(keyparts_used-1));
+ range_blocks_cnt+= ((MY_MAX(rows, 1) - 1) / avg_block_records + 1);
}
else
{
page_range pages= unused_page_range;
- if ((range.range_flag & UNIQUE_RANGE) && !(range.range_flag & NULL_RANGE))
- rows= 1; /* there can be at most one row */
- else if (HA_POS_ERROR == (rows= this->records_in_range(keyno, min_endp,
- max_endp, &pages)))
+ if ((rows= this->records_in_range(keyno, min_endp, max_endp, &pages)) ==
+ HA_POS_ERROR)
{
/* Can't scan one range => can't do MRR scan at all */
total_rows= HA_POS_ERROR;
break;
}
+ if (pages.first_page == UNUSED_PAGE_NO)
+ {
+ /*
+ The engine does not provide info on the range position.
+ Place the range in a new block. Note that in this case
+ any new range will be placed in a new block.
+ */
+ ulonglong additional_blocks= ((MY_MAX(rows,1) - 1) / avg_block_records +
+ 1);
+ edge_blocks_cnt+= additional_blocks == 1 ? 1 : 2;
+ range_blocks_cnt+= additional_blocks;
+ }
+ else
+ {
+ /* The info on the range position is provided */
+ if (pages.first_page == prev_range_last_block)
+ {
+ /*
+ The new range starts in the same block that the last range
+ for which the position of the range was provided.
+ */
+ /*
+ First add records of single point ranges that can be placed
+ between these two ranges.
+ */
+ prev_range_last_block_records+= (single_point_ranges -
+ assigned_single_point_ranges);
+ assigned_single_point_ranges= single_point_ranges;
+ if (pages.first_page == pages.last_page)
+ {
+ /*
+ All records of the current range are in the same block
+ Note that the prev_range_last_block_records can be much larger
+ than max_records_in_block as the rows can be compressed!
+ */
+ prev_range_last_block_records+= rows;
+ DBUG_ASSERT(prev_range_last_block_records <
+ stats.block_size);
+ }
+ else
+ {
+ /*
+ The current range spans more than one block
+
+ Place part of the range records in 'prev_range_last_block'
+ and the remaining records in additional blocks.
+
+ We don't know where the first key was positioned in the
+ block, so we assume the range started in the middle of the
+ block.
+
+ Note that prev_range_last_block_records > avg_block_records
+ can be true in case of compressed rows.
+ */
+ ha_rows rem_rows= rows;
+
+ if (avg_block_records > prev_range_last_block_records)
+ {
+ ha_rows space_left_in_prev_block=
+ (avg_block_records - prev_range_last_block_records)/2;
+ rem_rows= 0;
+ if (rows > space_left_in_prev_block)
+ rem_rows= rows - space_left_in_prev_block;
+ }
+ /* Calculate how many additional blocks we need for rem_rows */
+ ulonglong additional_blocks= ((MY_MAX(rem_rows, 1) - 1) /
+ avg_block_records + 1);
+ edge_blocks_cnt++;
+ range_blocks_cnt+= additional_blocks;
+ prev_range_last_block= pages.last_page;
+ /* There is at least one row on last page */
+ prev_range_last_block_records= 1;
+ }
+ }
+ else
+ {
+ /*
+ The new range does not start in the same block that the last range
+ for which the position of the range was provided.
+ Note that rows may be 0!
+ */
+ ulonglong additional_blocks= ((MY_MAX(rows, 1) - 1) /
+ avg_block_records + 1);
+ edge_blocks_cnt+= additional_blocks == 1 ? 1 : 2;
+ range_blocks_cnt+= additional_blocks;
+ unassigned_single_point_ranges+= (single_point_ranges -
+ assigned_single_point_ranges);
+ assigned_single_point_ranges= single_point_ranges;
+ prev_range_last_block= pages.last_page;
+ /* There is at least one row on last page */
+ prev_range_last_block_records= 1;
+ }
+ }
}
- total_rows += rows;
- total_touched_blocks+= (rows / avg_block_records +1);
+ total_rows+= rows;
}
-
+ /*
+ Count the number of io_blocks that where not yet read and thus not cached.
+ The number of equal read blocks that where not read are:
+
+ (single_point_ranges - assigned_single_point_ranges).
+
+ We don't add these to io_blocks as we don't want to penalize equal
+ readss (if we did, a range that would read 5 rows would be
+ regarded as better than one equal read).
+
+ Better to assume we have done a records_in_range() for the equal
+ range and it's also cached.
+ */
+ io_blocks= (range_blocks_cnt - edge_blocks_cnt);
+ unassigned_single_point_ranges+= (single_point_ranges -
+ assigned_single_point_ranges);
+
if (total_rows != HA_POS_ERROR)
{
set_if_smaller(total_rows, max_rows);
+
/* The following calculation is the same as in multi_range_read_info(): */
*flags |= HA_MRR_USE_DEFAULT_IMPL;
cost->reset();
- cost->avg_io_cost= 1; /* assume random seeks */
- cost->idx_avg_io_cost= 1;
+ cost->avg_io_cost= cost->idx_avg_io_cost= avg_io_cost();
+
if (!is_clustering_key(keyno))
{
- cost->idx_io_count= total_touched_blocks +
- keyread_time(keyno, 0, total_rows);
- cost->cpu_cost= cost->idx_cpu_cost=
- (double) total_rows / TIME_FOR_COMPARE_IDX +
- (2 * n_ranges - n_eq_ranges) * IDX_LOOKUP_COST;
+ cost->idx_io_count= (double) io_blocks;
+ cost->idx_cpu_cost= (keyread_time(keyno, 0, total_rows) +
+ n_ranges * IDX_LOOKUP_COST);
if (!(*flags & HA_MRR_INDEX_ONLY))
- {
- cost->io_count= read_time(keyno, 0, total_rows);
- cost->cpu_cost+= (double) total_rows / TIME_FOR_COMPARE;
- }
+ cost->cpu_cost= read_time(keyno, 0, total_rows);
}
else
{
- cost->io_count= read_time(keyno, n_ranges, (uint) total_rows);
- cost->cpu_cost= (double) total_rows / TIME_FOR_COMPARE + 0.01;
+ /*
+ Clustered index
+ If all index dives are to a few blocks, then limit the
+ ranges used by read_time to the number of dives.
+ */
+ io_blocks+= unassigned_single_point_ranges;
+ cost->idx_cpu_cost= n_ranges * IDX_LOOKUP_COST;
+ uint limited_ranges= (uint) MY_MIN((ulonglong) n_ranges, io_blocks);
+ cost->cpu_cost= read_time(keyno, limited_ranges, total_rows);
}
+ cost->cpu_cost+= (rows2double(total_rows) / TIME_FOR_COMPARE +
+ MULTI_RANGE_READ_SETUP_COST);
}
DBUG_PRINT("statistics",
("key: %s rows: %llu total_cost: %.3f io_blocks: %llu "
"idx_io_count: %.3f cpu_cost: %.3f io_count: %.3f",
table->s->keynames.type_names[keyno],
- (ulonglong) total_rows, cost->total_cost(),
- (ulonglong) total_touched_blocks,
+ (ulonglong) total_rows, cost->total_cost(), (ulonglong) io_blocks,
cost->idx_io_count, cost->cpu_cost, cost->io_count));
DBUG_RETURN(total_rows);
}
@@ -209,7 +371,7 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
*/
ha_rows handler::multi_range_read_info(uint keyno, uint n_ranges, uint n_rows,
- uint key_parts, uint *bufsz,
+ uint key_parts, uint *bufsz,
uint *flags, Cost_estimate *cost)
{
/*
@@ -222,25 +384,26 @@ ha_rows handler::multi_range_read_info(uint keyno, uint n_ranges, uint n_rows,
*flags |= HA_MRR_USE_DEFAULT_IMPL;
cost->reset();
- cost->avg_io_cost= 1; /* assume random seeks */
-
/* Produce the same cost as non-MRR code does */
if (!pk_is_clustering_key(keyno))
{
- cost->idx_io_count= n_ranges + keyread_time(keyno, 0, n_rows);
- cost->cpu_cost= cost->idx_cpu_cost=
- (double) n_rows / TIME_FOR_COMPARE_IDX + n_ranges * IDX_LOOKUP_COST;
+ /*
+ idx_io_count could potentially be increased with the number of
+ index leaf blocks we have to read for finding n_rows.
+ */
+ cost->idx_io_count= n_ranges;
+ cost->idx_cpu_cost= (keyread_time(keyno, 0, n_rows) +
+ n_ranges * IDX_LOOKUP_COST);
if (!(*flags & HA_MRR_INDEX_ONLY))
{
- cost->io_count= read_time(keyno, 0, n_rows);
- cost->cpu_cost+= (double) n_rows / TIME_FOR_COMPARE;
+ cost->cpu_cost= read_time(keyno, 0, n_rows);
}
}
else
{
- cost->io_count= read_time(keyno, n_ranges, (uint)n_rows);
- cost->cpu_cost= (double) n_rows / TIME_FOR_COMPARE + 0.01;
+ cost->cpu_cost= read_time(keyno, n_ranges, (uint)n_rows);
}
+ cost->cpu_cost+= rows2double(n_rows) / TIME_FOR_COMPARE;
return 0;
}
@@ -1184,9 +1347,9 @@ int DsMrr_impl::setup_two_handlers()
We get here when the access alternates betwen MRR scan(s) and non-MRR
scans.
- Calling primary_file->index_end() will invoke dsmrr_close() for this object,
- which will delete secondary_file. We need to keep it, so put it away and don't
- let it be deleted:
+ Calling primary_file->index_end() will invoke dsmrr_close() for this
+ object, which will delete secondary_file. We need to keep it, so put it
+ away and don't let it be deleted:
*/
if (primary_file->inited == handler::INDEX)
{
@@ -1912,6 +2075,9 @@ void get_sort_and_sweep_cost(TABLE *table, ha_rows nrows, Cost_estimate *cost)
We define half_rotation_cost as DISK_SEEK_BASE_COST=0.9.
+ If handler::avg_io_cost() < 1.0, then we will trust the handler
+ when it comes to the average cost (this is for example true for HEAP).
+
@param table Table to be accessed
@param nrows Number of rows to retrieve
@param interrupted TRUE <=> Assume that the disk sweep will be
@@ -1927,10 +2093,10 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
cost->reset();
if (table->file->pk_is_clustering_key(table->s->primary_key))
{
- cost->io_count= table->file->read_time(table->s->primary_key,
+ cost->cpu_cost= table->file->read_time(table->s->primary_key,
(uint) nrows, nrows);
}
- else
+ else if ((cost->avg_io_cost= table->file->avg_io_cost()) >= 0.999)
{
double n_blocks=
ceil(ulonglong2double(table->file->stats.data_file_length) / IO_SIZE);
@@ -1958,5 +2124,3 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted,
/* **************************************************************************
* DS-MRR implementation ends
***************************************************************************/
-
-
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index b0ae444fd7a..7390345ed29 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -2671,9 +2671,15 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
scan_time= read_time= DBL_MAX;
else
{
- scan_time= (double) records / TIME_FOR_COMPARE + 1;
- read_time= (double) head->file->scan_time() + scan_time + 1.1;
- if (limit < records)
+ scan_time= rows2double(records) / TIME_FOR_COMPARE;
+ /*
+ The 2 is there to prefer range scans to full table scans.
+ This is mainly to make the test suite happy as many tests has
+ very few rows. In real life tables has more than a few rows and the
+ +2 has no practical effect.
+ */
+ read_time= (double) head->file->scan_time() + scan_time + 2;
+ if (limit < records && read_time < (double) records + scan_time + 1 )
{
read_time= (double) records + scan_time + 1; // Force to use index
notnull_cond= NULL;
@@ -2815,8 +2821,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
if (!force_quick_range && !head->covering_keys.is_clear_all())
{
int key_for_use= find_shortest_key(head, &head->covering_keys);
- double key_read_time= head->file->key_scan_time(key_for_use) +
- (double) records / TIME_FOR_COMPARE_IDX;
+ double key_read_time= (head->file->key_scan_time(key_for_use) +
+ rows2double(records) / TIME_FOR_COMPARE);
DBUG_PRINT("info", ("'all'+'using index' scan will be using key %d, "
"read time %g", key_for_use, key_read_time));
@@ -5158,8 +5164,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
Add one ROWID comparison for each row retrieved on non-CPK scan. (it
is done in QUICK_RANGE_SELECT::row_in_ranges)
*/
- double rid_comp_cost= static_cast<double>(non_cpk_scan_records) /
- TIME_FOR_COMPARE_ROWID;
+ double rid_comp_cost= (rows2double(non_cpk_scan_records) /
+ TIME_FOR_COMPARE_ROWID);
imerge_cost+= rid_comp_cost;
trace_best_disjunct.add("cost_of_mapping_rowid_in_non_clustered_pk_scan",
rid_comp_cost);
@@ -5465,7 +5471,7 @@ typedef struct st_common_index_intersect_info
{
PARAM *param; /* context info for range optimizations */
uint key_size; /* size of a ROWID element stored in Unique object */
- uint compare_factor; /* 1/compare - cost to compare two ROWIDs */
+ double compare_factor; /* 1/compare - cost to compare two ROWIDs */
size_t max_memory_size; /* maximum space allowed for Unique objects */
ha_rows table_cardinality; /* estimate of the number of records in table */
double cutoff_cost; /* discard index intersects with greater costs */
@@ -6160,7 +6166,7 @@ bool check_index_intersect_extension(PARTIAL_INDEX_INTERSECT_INFO *curr,
{
uint *buff_elems= common_info->buff_elems;
uint key_size= common_info->key_size;
- uint compare_factor= common_info->compare_factor;
+ double compare_factor= common_info->compare_factor;
size_t max_memory_size= common_info->max_memory_size;
records_sent_to_unique+= ext_index_scan_records;
@@ -14232,7 +14238,8 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
DBUG_ENTER("cost_group_min_max");
table_records= table->stat_records();
- keys_per_block= (uint) (table->file->stats.block_size / 2 /
+ /* Assume block is 75 % full */
+ keys_per_block= (uint) (table->file->stats.block_size * 3 / 4 /
(index_info->key_length + table->file->ref_length)
+ 1);
num_blocks= (ha_rows)(table_records / keys_per_block) + 1;
@@ -14298,20 +14305,21 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
b-tree the number of comparisons will be larger.
TODO: This cost should be provided by the storage engine.
*/
- const double tree_traversal_cost=
+ const double tree_traversal_cost=
ceil(log(static_cast<double>(table_records))/
log(static_cast<double>(keys_per_block))) *
- 1/double(2*TIME_FOR_COMPARE);
+ 1/(2*TIME_FOR_COMPARE);
const double cpu_cost= num_groups *
- (tree_traversal_cost + 1/double(TIME_FOR_COMPARE_IDX));
+ (tree_traversal_cost + 1/TIME_FOR_COMPARE_IDX);
*read_cost= io_cost + cpu_cost;
*records= num_groups;
DBUG_PRINT("info",
- ("table rows: %lu keys/block: %u keys/group: %lu result rows: %lu blocks: %lu",
- (ulong)table_records, keys_per_block, (ulong) keys_per_group,
+ ("table rows: %lu keys/block: %u keys/group: %lu "
+ "result rows: %lu blocks: %lu",
+ (ulong) table_records, keys_per_block, (ulong) keys_per_group,
(ulong) *records, (ulong) num_blocks));
DBUG_VOID_RETURN;
}
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 607d9a2d95a..38779619b82 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -1420,9 +1420,10 @@ void get_delayed_table_estimates(TABLE *table,
/* Calculate cost of scanning the temptable */
double data_size= COST_MULT(item->jtbm_record_count,
hash_sj_engine->tmp_table->s->reclength);
- /* Do like in handler::read_time */
- *scan_time= data_size/IO_SIZE + 2;
-}
+ /* Do like in handler::scan_time() */
+ *scan_time= ((data_size/table->file->stats.block_size+2) *
+ table->file->avg_io_cost());
+}
/**
@@ -3144,7 +3145,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join,
prefix_rec_count= COST_MULT(prefix_rec_count, curpos.records_read);
prefix_cost= COST_ADD(prefix_cost, curpos.read_time);
prefix_cost= COST_ADD(prefix_cost,
- prefix_rec_count / (double) TIME_FOR_COMPARE);
+ prefix_rec_count / TIME_FOR_COMPARE);
//TODO: take into account join condition selectivity here
}
diff --git a/sql/sql_const.h b/sql/sql_const.h
index a3f0e35ac47..3f053a1606d 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -204,11 +204,12 @@
instead of reading with keys. The number says how many evaluation of the
WHERE clause is comparable to reading one extra row from a table.
*/
-#define TIME_FOR_COMPARE 5 // 5 compares == one read
-#define TIME_FOR_COMPARE_IDX 20
+#define TIME_FOR_COMPARE 5.0 // 5 WHERE compares == one read
+#define TIME_FOR_COMPARE_IDX 20.0
#define IDX_BLOCK_COPY_COST ((double) 1 / TIME_FOR_COMPARE)
#define IDX_LOOKUP_COST ((double) 1 / 8)
+#define MULTI_RANGE_READ_SETUP_COST (IDX_BLOCK_COPY_COST/10)
/**
Number of comparisons of table rowids equivalent to reading one row from a
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index d5120d95420..e546f3cfeca 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -4255,7 +4255,7 @@ void select_insert::abort_result_set()
table will be assigned with view table structure, but that table will
not be opened really (it is dummy to check fields types & Co).
*/
- if (table && table->file->get_table())
+ if (table && table->file->is_open())
{
bool changed, transactional_table;
/*
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 24e158694c5..f7660054b74 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -232,7 +232,7 @@ static bool test_if_cheaper_ordering(const JOIN_TAB *tab,
uint *saved_best_key_parts= NULL);
static int test_if_order_by_key(JOIN *join,
ORDER *order, TABLE *table, uint idx,
- uint *used_key_parts= NULL);
+ uint *used_key_parts);
static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,
ha_rows select_limit, bool no_changes,
const key_map *map);
@@ -7196,7 +7196,7 @@ double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint,
{
TABLE *table= s->table;
double sel= table->cond_selectivity;
- double table_records= (double)table->stat_records();
+ double table_records= rows2double(s->records);
dbl_records= table_records * sel;
return dbl_records;
}
@@ -7227,6 +7227,61 @@ double matching_candidates_in_table(JOIN_TAB *s, bool with_found_constraint,
}
+/*
+ Calculate the cost of reading a set of rows trough an index
+
+ Logically this is identical to the code in multi_range_read_info_const()
+ excepts the function also takes into account io_blocks and multiple
+ ranges.
+
+ One main difference between the functions is that
+ multi_range_read_info_const() adds a very small cost per range
+ (IDX_LOOKUP_COST) and also MULTI_RANGE_READ_SETUP_COST, to ensure that
+ 'ref' is preferred slightly over ranges.
+*/
+
+double cost_for_index_read(const THD *thd, const TABLE *table, uint key,
+ ha_rows records, ha_rows worst_seeks)
+{
+ DBUG_ENTER("cost_for_index_read");
+ double cost;
+ handler *file= table->file;
+
+ set_if_smaller(records, (ha_rows) thd->variables.max_seeks_for_key);
+ if (file->is_clustering_key(key))
+ cost= file->read_time(key, 1, records);
+ else
+ if (table->covering_keys.is_set(key))
+ cost= file->keyread_time(key, 1, records);
+ else
+ cost= ((file->keyread_time(key, 0, records) +
+ file->read_time(key, 1, MY_MIN(records, worst_seeks))));
+
+ DBUG_PRINT("statistics", ("cost: %.3f", cost));
+ DBUG_RETURN(cost);
+}
+
+
+/*
+ Adjust cost from table->quick_costs calculated by
+ multi_range_read_info_const() to be comparable with cost_for_index_read()
+
+ This functions is needed because best_access_patch doesn't add
+ TIME_FOR_COMPARE to it's costs until very late.
+ Preferably we should fix so that all costs are comparably.
+ (All compared costs should include TIME_FOR_COMPARE for all found
+ rows).
+*/
+
+double adjust_quick_cost(double quick_cost, ha_rows records)
+{
+ double cost= (quick_cost - MULTI_RANGE_READ_SETUP_COST -
+ rows2double(records)/TIME_FOR_COMPARE);
+ DBUG_ASSERT(cost > 0.0);
+ return cost;
+}
+
+
/**
Find the best access path for an extension of a partial execution
plan and add this path to the plan.
@@ -7448,10 +7503,16 @@ best_access_path(JOIN *join,
(!(key_flags & HA_NULL_PART_KEY) || // (2)
all_key_parts == notnull_part)) // (3)
{
+
+ /* TODO: Adjust cost for covering and clustering key */
type= JT_EQ_REF;
trace_access_idx.add("access_type", join_type_str[type])
.add("index", keyinfo->name);
- tmp = prev_record_reads(join_positions, idx, found_ref);
+ if (!found_ref && table->quick_keys.is_set(key))
+ tmp= adjust_quick_cost(table->quick_costs[key], 1);
+ else
+ tmp= table->file->avg_io_cost();
+ tmp*= prev_record_reads(join_positions, idx, found_ref);
records=1.0;
}
else
@@ -7482,6 +7543,9 @@ best_access_path(JOIN *join,
{
records= (double) table->quick_rows[key];
trace_access_idx.add("used_range_estimates", true);
+ tmp= adjust_quick_cost(table->quick_costs[key],
+ table->quick_rows[key]);
+ goto got_cost;
}
else
{
@@ -7515,12 +7579,11 @@ best_access_path(JOIN *join,
*/
if (table->quick_keys.is_set(key) &&
(const_part &
- (((key_part_map)1 << table->quick_key_parts[key])-1)) ==
+ (((key_part_map)1 << table->quick_key_parts[key])-1)) ==
(((key_part_map)1 << table->quick_key_parts[key])-1) &&
table->quick_n_ranges[key] == 1 &&
records > (double) table->quick_rows[key])
{
-
records= (double) table->quick_rows[key];
trace_access_idx.add("used_range_estimates", true);
}
@@ -7540,13 +7603,9 @@ best_access_path(JOIN *join,
}
}
/* Limit the number of matched rows */
- tmp= records;
- set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);
- if (table->covering_keys.is_set(key))
- tmp= table->file->keyread_time(key, 1, (ha_rows) tmp);
- else
- tmp= table->file->read_time(key, 1,
- (ha_rows) MY_MIN(tmp,s->worst_seeks));
+ tmp= cost_for_index_read(thd, table, key, (ha_rows) records,
+ (ha_rows) s->worst_seeks);
+ got_cost:
tmp= COST_MULT(tmp, record_count);
}
}
@@ -7608,8 +7667,11 @@ best_access_path(JOIN *join,
table->quick_key_parts[key] == max_key_part && //(C2)
table->quick_n_ranges[key] == 1 + MY_TEST(ref_or_null_part)) //(C3)
{
- tmp= records= (double) table->quick_rows[key];
+ records= (double) table->quick_rows[key];
+ tmp= adjust_quick_cost(table->quick_costs[key],
+ table->quick_rows[key]);
trace_access_idx.add("used_range_estimates", true);
+ goto got_cost2;
}
else
{
@@ -7632,24 +7694,23 @@ best_access_path(JOIN *join,
cheaper in some cases ?
TODO: figure this out and adjust the plan choice if needed.
*/
- if (!found_ref && table->quick_keys.is_set(key) && // (1)
- table->quick_key_parts[key] > max_key_part && // (2)
- records < (double)table->quick_rows[key]) // (3)
- {
- trace_access_idx.add("used_range_estimates", true);
- records= (double)table->quick_rows[key];
- }
- else
+ if (table->quick_keys.is_set(key))
{
- if (table->quick_keys.is_set(key) &&
- table->quick_key_parts[key] < max_key_part)
+ if (table->quick_key_parts[key] >= max_key_part) // (2)
+ {
+ if (!found_ref && // (1)
+ records < (double) table->quick_rows[key]) // (3)
+ {
+ trace_access_idx.add("used_range_estimates", true);
+ records= (double) table->quick_rows[key];
+ }
+ }
+ else /* (table->quick_key_parts[key] < max_key_part) */
{
- trace_access_idx.add("chosen", false);
- cause= "range uses more keyparts";
+ trace_access_idx.add("chosen", true);
+ cause= "range uses less keyparts";
}
}
-
- tmp= records;
}
else
{
@@ -7673,27 +7734,25 @@ best_access_path(JOIN *join,
rec_per_key=(double) s->records/rec+1;
if (!s->records)
- tmp = 0;
+ records= 0;
else if (rec_per_key/(double) s->records >= 0.01)
- tmp = rec_per_key;
+ records= rec_per_key;
else
{
double a=s->records*0.01;
if (keyinfo->user_defined_key_parts > 1)
- tmp= (max_key_part * (rec_per_key - a) +
+ records= (max_key_part * (rec_per_key - a) +
a*keyinfo->user_defined_key_parts - rec_per_key)/
(keyinfo->user_defined_key_parts-1);
else
- tmp= a;
- set_if_bigger(tmp,1.0);
+ records= a;
+ set_if_bigger(records, 1.0);
}
- records = (ulong) tmp;
}
if (ref_or_null_part)
{
- /* We need to do two key searches to find key */
- tmp *= 2.0;
+ /* We need to do two key searches to find row */
records *= 2.0;
}
@@ -7712,22 +7771,21 @@ best_access_path(JOIN *join,
if (table->quick_keys.is_set(key) &&
table->quick_key_parts[key] <= max_key_part &&
const_part &
- ((key_part_map)1 << table->quick_key_parts[key]) &&
+ ((key_part_map)1 << table->quick_key_parts[key]) &&
table->quick_n_ranges[key] == 1 + MY_TEST(ref_or_null_part &
const_part) &&
records > (double) table->quick_rows[key])
{
- tmp= records= (double) table->quick_rows[key];
+ records= (double) table->quick_rows[key];
}
}
/* Limit the number of matched rows */
+ tmp= records;
set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key);
- if (table->covering_keys.is_set(key))
- tmp= table->file->keyread_time(key, 1, (ha_rows) tmp);
- else
- tmp= table->file->read_time(key, 1,
- (ha_rows) MY_MIN(tmp,s->worst_seeks));
+ tmp= cost_for_index_read(thd, table, key, (ha_rows) tmp,
+ (ha_rows) s->worst_seeks);
+ got_cost2:
tmp= COST_MULT(tmp, record_count);
}
else
@@ -7760,10 +7818,10 @@ best_access_path(JOIN *join,
}
trace_access_idx.add("rows", records).add("cost", tmp);
- if (tmp + 0.0001 < best_time - records/(double) TIME_FOR_COMPARE)
+ if (tmp + 0.0001 < best_time - records/TIME_FOR_COMPARE)
{
trace_access_idx.add("chosen", true);
- best_time= COST_ADD(tmp, records/(double) TIME_FOR_COMPARE);
+ best_time= COST_ADD(tmp, records/TIME_FOR_COMPARE);
best= tmp;
best_records= records;
best_key= start_key;
@@ -7806,7 +7864,7 @@ best_access_path(JOIN *join,
use_cond_selectivity);
tmp= s->quick ? s->quick->read_time : s->scan_time();
- double cmp_time= (s->records - rnd_records)/(double) TIME_FOR_COMPARE;
+ double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE;
tmp= COST_ADD(tmp, cmp_time);
/* We read the table as many times as join buffer becomes full. */
@@ -7897,7 +7955,7 @@ best_access_path(JOIN *join,
access (see first else-branch below), but we don't take it into
account here for range/index_merge access. Find out why this is so.
*/
- double cmp_time= (s->found_records - rnd_records)/(double) TIME_FOR_COMPARE;
+ double cmp_time= (s->found_records - rnd_records)/TIME_FOR_COMPARE;
tmp= COST_MULT(record_count,
COST_ADD(s->quick->read_time, cmp_time));
@@ -7944,7 +8002,7 @@ best_access_path(JOIN *join,
- read the whole table record
- skip rows which does not satisfy join condition
*/
- double cmp_time= (s->records - rnd_records)/(double) TIME_FOR_COMPARE;
+ double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE;
tmp= COST_MULT(record_count, COST_ADD(tmp,cmp_time));
}
else
@@ -7960,7 +8018,7 @@ best_access_path(JOIN *join,
we read the table (see flush_cached_records for details). Here we
take into account cost to read and skip these records.
*/
- double cmp_time= (s->records - rnd_records)/(double) TIME_FOR_COMPARE;
+ double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE;
tmp= COST_ADD(tmp, cmp_time);
}
}
@@ -7987,10 +8045,10 @@ best_access_path(JOIN *join,
trace_access_scan.add("cost", tmp);
if (best == DBL_MAX ||
- COST_ADD(tmp, record_count/(double) TIME_FOR_COMPARE*rnd_records) <
+ COST_ADD(tmp, record_count/TIME_FOR_COMPARE*rnd_records) <
(best_key->is_for_hash_join() ? best_time :
COST_ADD(best - best_filter_cmp_gain,
- record_count/(double) TIME_FOR_COMPARE*records)))
+ record_count/TIME_FOR_COMPARE*records)))
{
/*
If the table has a range (s->quick is set) make_join_select()
@@ -8542,7 +8600,7 @@ optimize_straight_join(JOIN *join, table_map join_tables)
: 0;
read_time+= COST_ADD(read_time - filter_cmp_gain,
COST_ADD(position->read_time,
- record_count / (double) TIME_FOR_COMPARE));
+ record_count / TIME_FOR_COMPARE));
advance_sj_state(join, join_tables, idx, &record_count, &read_time,
&loose_scan_pos);
@@ -8735,7 +8793,7 @@ greedy_search(JOIN *join,
record_count= COST_MULT(record_count, join->positions[idx].records_read);
read_time= COST_ADD(read_time,
COST_ADD(join->positions[idx].read_time,
- record_count / (double) TIME_FOR_COMPARE));
+ record_count / TIME_FOR_COMPARE));
remaining_tables&= ~(best_table->table->map);
--size_remain;
@@ -8845,7 +8903,7 @@ void JOIN::get_partial_cost_and_fanout(int end_tab_idx,
record_count= COST_MULT(record_count, tab->records_read);
read_time= COST_ADD(read_time,
COST_ADD(tab->read_time,
- record_count / (double) TIME_FOR_COMPARE));
+ record_count / TIME_FOR_COMPARE));
if (tab->emb_sj_nest)
sj_inner_fanout= COST_MULT(sj_inner_fanout, tab->records_read);
}
@@ -9484,7 +9542,7 @@ best_extension_by_limited_search(JOIN *join,
COST_ADD(position->read_time -
filter_cmp_gain,
current_record_count /
- (double) TIME_FOR_COMPARE));
+ TIME_FOR_COMPARE));
if (unlikely(thd->trace_started()))
{
@@ -16889,7 +16947,7 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
reopt_remaining_tables &= ~rs->table->map;
rec_count= COST_MULT(rec_count, pos.records_read);
cost= COST_ADD(cost, pos.read_time);
- cost= COST_ADD(cost, rec_count / (double) TIME_FOR_COMPARE);
+ cost= COST_ADD(cost, rec_count / TIME_FOR_COMPARE);
//TODO: take into account join condition selectivity here
double pushdown_cond_selectivity= 1.0;
table_map real_table_bit= rs->table->map;
@@ -18606,6 +18664,7 @@ bool Create_tmp_table::finalize(THD *thd,
delete table->file;
goto err;
}
+ table->file->set_table(table);
if (!m_using_unique_constraint)
share->reclength+= m_group_null_items; // null flag is stored separately
@@ -18630,6 +18689,7 @@ bool Create_tmp_table::finalize(THD *thd,
share->reclength+= whole_null_pack_length;
if (!share->reclength)
share->reclength= 1; // Dummy select
+ share->stored_rec_length= share->reclength;
/* Use packed rows if there is blobs or a lot of space to gain */
if (share->blob_fields ||
(string_total_length() >= STRING_TOTAL_LENGTH_TO_PACK_ROWS &&
@@ -22864,8 +22924,7 @@ static int test_if_order_by_key(JOIN *join,
}
ok:
- if (used_key_parts != NULL)
- *used_key_parts= key_parts;
+ *used_key_parts= key_parts;
DBUG_RETURN(reverse);
}
@@ -22959,12 +23018,13 @@ test_if_subkey(ORDER *order, TABLE *table, uint ref, uint ref_key_parts,
*/
for (nr= 0 ; nr < table->s->keys ; nr++)
{
+ uint not_used;
if (usable_keys->is_set(nr) &&
table->key_info[nr].key_length < min_length &&
table->key_info[nr].user_defined_key_parts >= ref_key_parts &&
is_subkey(table->key_info[nr].key_part, ref_key_part,
ref_key_part_end) &&
- test_if_order_by_key(NULL, order, table, nr))
+ test_if_order_by_key(NULL, order, table, nr, &not_used))
{
min_length= table->key_info[nr].key_length;
best= nr;
@@ -23665,6 +23725,14 @@ skipped_filesort:
{
delete save_quick;
save_quick= NULL;
+
+ /*
+ 'delete save_quick' disabled key reads. Enable key read if the new
+ index is an covering key
+ */
+ if (select->quick && !select->head->no_keyread &&
+ select->head->covering_keys.is_set(select->quick->index))
+ select->head->file->ha_start_keyread(select->quick->index);
}
if (orig_cond_saved && !changed_key)
tab->set_cond(orig_cond);
@@ -23679,6 +23747,9 @@ use_filesort:
{
delete select->quick;
select->quick= save_quick;
+ if (select->quick && !select->head->no_keyread &&
+ select->head->covering_keys.is_set(select->quick->index))
+ select->head->file->ha_start_keyread(select->quick->index);
}
if (orig_cond_saved)
tab->set_cond(orig_cond);
@@ -28024,14 +28095,9 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab,
if (ref_rows > 0)
{
- double tmp= (double)ref_rows;
- /* Reuse the cost formula from best_access_path: */
- set_if_smaller(tmp, (double) tab->join->thd->variables.max_seeks_for_key);
- if (table->covering_keys.is_set(keynr))
- tmp= table->file->keyread_time(keynr, 1, (ha_rows) tmp);
- else
- tmp= table->file->read_time(keynr, 1,
- (ha_rows) MY_MIN(tmp,tab->worst_seeks));
+ double tmp= cost_for_index_read(tab->join->thd, table, keynr,
+ ref_rows,
+ (ha_rows) tab->worst_seeks);
if (tmp < best_cost)
{
best_cost= tmp;
@@ -28496,7 +28562,9 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
*new_select_limit= has_limit ? best_select_limit : table_records;
if (new_used_key_parts != NULL)
*new_used_key_parts= best_key_parts;
-
+ table->file->ha_end_keyread();
+ if (is_best_covering && !table->no_keyread)
+ table->file->ha_start_keyread(best_key);
DBUG_RETURN(TRUE);
}
diff --git a/sql/table.cc b/sql/table.cc
index 811ea28b49c..6d3adc4d67c 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -9185,8 +9185,8 @@ void TABLE_LIST::set_lock_type(THD *thd, enum thr_lock_type lock)
/* we call it only when table is opened and it is "leaf" table*/
DBUG_ASSERT(table);
lock_type= lock;
- /* table->file->get_table() can be 0 for derived tables */
- if (table->file && table->file->get_table())
+ /* If not derived tables */
+ if (table->file && table->file->is_open())
table->file->set_lock_type(lock);
if (is_merged_derived())
{
diff --git a/sql/uniques.cc b/sql/uniques.cc
index 4e327a4cc09..60918ea534e 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -161,7 +161,7 @@ inline double log2_n_fact(double x)
static double get_merge_buffers_cost(uint *buff_elems, uint elem_size,
uint *first, uint *last,
- uint compare_factor)
+ double compare_factor)
{
uint total_buf_elems= 0;
for (uint *pbuf= first; pbuf <= last; pbuf++)
@@ -206,7 +206,7 @@ static double get_merge_buffers_cost(uint *buff_elems, uint elem_size,
static double get_merge_many_buffs_cost(uint *buffer,
uint maxbuffer, uint max_n_elems,
uint last_n_elems, int elem_size,
- uint compare_factor)
+ double compare_factor)
{
int i;
double total_cost= 0.0;
@@ -306,7 +306,7 @@ static double get_merge_many_buffs_cost(uint *buffer,
double Unique::get_use_cost(uint *buffer, size_t nkeys, uint key_size,
size_t max_in_memory_size,
- uint compare_factor,
+ double compare_factor,
bool intersect_fl, bool *in_memory)
{
size_t max_elements_in_tree;
diff --git a/sql/uniques.h b/sql/uniques.h
index 663d5c1682a..a78e626907f 100644
--- a/sql/uniques.h
+++ b/sql/uniques.h
@@ -72,13 +72,14 @@ public:
bool get(TABLE *table);
/* Cost of searching for an element in the tree */
- inline static double get_search_cost(ulonglong tree_elems, uint compare_factor)
+ inline static double get_search_cost(ulonglong tree_elems,
+ double compare_factor)
{
return log((double) tree_elems) / (compare_factor * M_LN2);
}
static double get_use_cost(uint *buffer, size_t nkeys, uint key_size,
- size_t max_in_memory_size, uint compare_factor,
+ size_t max_in_memory_size, double compare_factor,
bool intersect_fl, bool *in_memory);
inline static int get_cost_calc_buff_size(size_t nkeys, uint key_size,
size_t max_in_memory_size)
diff --git a/storage/connect/mysql-test/connect/r/mysql_index.result b/storage/connect/mysql-test/connect/r/mysql_index.result
index fb68f4843bd..54acc7be08d 100644
--- a/storage/connect/mysql-test/connect/r/mysql_index.result
+++ b/storage/connect/mysql-test/connect/r/mysql_index.result
@@ -52,8 +52,8 @@ id msg
SELECT * FROM t2 WHERE id >= 3;
id msg
3 Trois
-5 Cinq
4 Four
+5 Cinq
6 Six
SELECT * FROM t2 WHERE id < 3;
id msg
diff --git a/storage/connect/mysql-test/connect/t/mysql_index.test b/storage/connect/mysql-test/connect/t/mysql_index.test
index 2aa26b79053..cb4a332cdf8 100644
--- a/storage/connect/mysql-test/connect/t/mysql_index.test
+++ b/storage/connect/mysql-test/connect/t/mysql_index.test
@@ -50,6 +50,7 @@ SELECT * FROM t2 WHERE id = 3;
SELECT * FROM t2 WHERE id IN (2,4);
SELECT * FROM t2 WHERE id IN (2,4) AND msg = 'Two';
SELECT * FROM t2 WHERE id > 4;
+--sorted_result
SELECT * FROM t2 WHERE id >= 3;
SELECT * FROM t2 WHERE id < 3;
SELECT * FROM t2 WHERE id < 2 OR id > 4;
diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h
index 67b9ac9524a..50d3c0afb6c 100644
--- a/storage/heap/ha_heap.h
+++ b/storage/heap/ha_heap.h
@@ -65,9 +65,11 @@ public:
double scan_time()
{ return (double) (stats.records+stats.deleted) / 20.0+10; }
double read_time(uint index, uint ranges, ha_rows rows)
- { return (double) rows / 20.0+1; }
+ { return (double) (rows +1)/ 20.0; }
double keyread_time(uint index, uint ranges, ha_rows rows)
- { return (double) rows / 20.0+1; }
+ { return (double) (rows + ranges) / 20.0 ; }
+ double avg_io_cost()
+ { return 0.05; } /* 1/20 */
int open(const char *name, int mode, uint test_if_locked);
int close(void);
void set_keys_for_scanning(void);
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index eb197f59925..ed9c5404a7f 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1091,7 +1091,8 @@ ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const
double ha_maria::scan_time()
{
if (file->s->data_file_type == BLOCK_RECORD)
- return ulonglong2double(stats.data_file_length - file->s->block_size) / MY_MAX(file->s->block_size / 2, IO_SIZE) + 2;
+ return (ulonglong2double(stats.data_file_length - file->s->block_size) /
+ file->s->block_size) + 2;
return handler::scan_time();
}
diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result b/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result
index 199edf9d758..a1a123e7d5f 100644
--- a/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result
+++ b/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_index_not_equal.result
@@ -14,5 +14,5 @@ COUNT(*)
2
SHOW STATUS LIKE 'mroonga_count_skip';
Variable_name Value
-Mroonga_count_skip 0
+Mroonga_count_skip 2
DROP TABLE users;
diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_primary_key_not_equal.result b/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_primary_key_not_equal.result
index 1b253a8edc6..64761c9565d 100644
--- a/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_primary_key_not_equal.result
+++ b/storage/mroonga/mysql-test/mroonga/storage/r/optimization_count_skip_primary_key_not_equal.result
@@ -13,5 +13,5 @@ COUNT(*)
4
SHOW STATUS LIKE 'mroonga_count_skip';
Variable_name Value
-Mroonga_count_skip 0
+Mroonga_count_skip 1
DROP TABLE users;
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index e6137fac482..6519a2301e1 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -2089,7 +2089,8 @@ int ha_myisam::info(uint flag)
ref_length= misam_info.reflength;
share->db_options_in_use= misam_info.options;
- stats.block_size= myisam_block_size; /* record block size */
+ /* record block size. We adjust with IO_SIZE to not make it too small */
+ stats.block_size= MY_MAX(myisam_block_size, IO_SIZE);
if (table_share->tmp_table == NO_TMP_TABLE)
mysql_mutex_lock(&table_share->LOCK_share);
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result
index 6507aa43ae1..b8cb4157d37 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/group_min_max.result
@@ -1808,10 +1808,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using where; Using index
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by
@@ -1978,10 +1978,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_2 147 NULL 17 Using where; Using index for group-by; Using temporary; Using filesort
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'b' group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
explain select distinct a1 from t1 where a1 in ('a', 'd') and a2 = 'e' group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 5 Using where; Using index for group-by
+1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 130 NULL 5 Using where; Using index for group-by
explain select distinct a1,a2,b from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_2 146 NULL # Using index for group-by
@@ -2131,7 +2131,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 17 Using where; Using index for group-by
explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_2 147 NULL 9 Using index for group-by
select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
a1 a2 b concat(min(c), max(c))
a a a a111d111
@@ -2285,7 +2285,7 @@ c
d
explain select a1 from t1 where a2 = 'b' group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_2 130 NULL 5 Using where; Using index for group-by
select a1 from t1 where a2 = 'b' group by a1;
a1
a
@@ -2294,7 +2294,7 @@ c
d
explain select distinct a1 from t1 where a2 = 'b';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using where; Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_2 130 NULL 5 Using where; Using index for group-by
select distinct a1 from t1 where a2 = 'b';
a1
a
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result b/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result
index efc6ccde500..4f285134c00 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/handler_basic.result
@@ -34,6 +34,7 @@ Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
+SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1;
SELECT * FROM t1 WHERE b=6;
id a b
6 NULL 6
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result
index efe4eaf2141..d96c40127a8 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/index_merge_rocksdb2.result
@@ -63,7 +63,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL i1 NULL NULL NULL # Using where
explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t0 ref i1,i2,i3 i3 4 const # Using where
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
explain select * from t0 use index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
@@ -121,11 +121,11 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t0 where
(key1 < 3 or key2 < 3) and (key3 < 70);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t0 range i1,i2,i3 i3 4 NULL # Using index condition; Using where
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
explain select * from t0 where
(key1 < 3 or key2 < 3) and (key3 < 1000);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t0 range i1,i2,i3 i3 4 NULL # Using index condition; Using where
+1 SIMPLE t0 index_merge i1,i2,i3 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
explain select * from t0 where
((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3))
or
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
index ce3d7d9147e..feeabd7ee79 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/records_in_range.result
@@ -67,7 +67,7 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 700
explain extended select a,b from t1 where a = 700;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ref ka ka 5 const 15000 100.00
+1 SIMPLE t1 ALL ka NULL NULL NULL 20000 75.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`a` = 700
explain extended select a from t1 where a in (700, 800);
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result
index 99d6bbe45b9..ca6ed6d5d18 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/type_float_indexes.result
@@ -114,7 +114,7 @@ INSERT INTO t1 (f,r,d,dp,pk) VALUES
(4644,1422.22,466664.999,0.5,5);
EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL d 9 NULL # Using index
+1 SIMPLE t1 range NULL d 9 NULL # Using index for group-by
SELECT DISTINCT d FROM t1 ORDER BY d;
d
-1
@@ -177,7 +177,7 @@ INSERT INTO t1 (f,r,d,dp,pk) VALUES
(1.2345,0,0,0,6);
EXPLAIN SELECT DISTINCT f FROM t1 ORDER BY f;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL f 5 NULL # Using index
+1 SIMPLE t1 range NULL f 5 NULL # Using index for group-by
SELECT DISTINCT f FROM t1 ORDER BY f;
f
-1
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test
index 7b1652c759b..22b5d69780d 100644
--- a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test
+++ b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test
@@ -28,6 +28,7 @@ SELECT * FROM t1 WHERE id=8;
SHOW SESSION STATUS LIKE 'Handler_read%';
FLUSH STATUS;
+SET GLOBAL rocksdb_force_flush_memtable_and_lzero_now=1;
SELECT * FROM t1 WHERE b=6;
SHOW SESSION STATUS LIKE 'Handler_read%';
diff --git a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result
index e646bc9bf38..194a6b31cba 100644
--- a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result
+++ b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result
@@ -87,7 +87,7 @@ a b c a
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on ((t1.`a` = t0.`a`) and (t0.`a` is not null)) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on ((t3.`b` = t2.`b`) and (t2.`b` is not null)) where 1 order by t0.`a` desc
+select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on (t1.`a` = t0.`a`) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on (t3.`b` = t2.`b`) where 1 order by t0.`a` desc
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result
index f3c6e189444..e6720c1113f 100644
--- a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result
+++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result
@@ -87,7 +87,7 @@ NULL NULL NULL 3
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null) and (t3.`b` is not null)) where 1 order by t3.`a` desc
+select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
diff --git a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result
index a05781cb6d6..a0b44c95cee 100644
--- a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result
+++ b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result
@@ -87,7 +87,7 @@ NULL c 2000-01-03 00:00:00 3
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join `auto_test_remote`.`ta_r_auto_inc` t2 on ((t2.`b` = t3.`b`) and (t3.`b` is not null)) left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc
+select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join `auto_test_remote`.`ta_r_auto_inc` t2 on (t2.`b` = t3.`b`) left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result
index 48cd9c2c75f..0ee74cae7a3 100644
--- a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result
+++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result
@@ -87,7 +87,7 @@ NULL c 2000-01-03 00:00:00 3
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
-select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t3.`b` is not null)) where 1 order by t3.`a` desc
+select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`)) where 1 order by t3.`a` desc
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a;
a b date_format(c, '%Y-%m-%d %H:%i:%s')
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
index f85845232dd..cb8cb1c68bb 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
@@ -27,7 +27,7 @@ a b c d
11 110 1100 11000
explain select * from t1 where c > 850;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
+1 SIMPLE t1 range c c 5 NULL NULL; Using where
select * from t1 where c > 850;
a b c d
9 90 900 9000
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
index 4c2fc08cd48..b01aaef6ee7 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
@@ -53,7 +53,7 @@ a b
11 110
explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
+1 SIMPLE t1 range c c 4 NULL NULL; Using where; Using index
select a,c from t1 where c > 350;
a c
4 400
@@ -160,7 +160,7 @@ a b
11 110
explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
+1 SIMPLE t1 range c c 4 NULL NULL; Using where; Using index
select a,c from t1 where c > 350;
a c
4 400
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
index 6b458b36585..4309b622293 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
@@ -22,5 +22,5 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
explain select a from t1 where c > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index c c 5 NULL NULL; Using where; Using index
+1 SIMPLE t1 range c c 5 NULL NULL; Using where; Using index
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
index 2dcb65cee10..137f2a930ca 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
@@ -38,7 +38,7 @@ max(a)
3
explain select a,b from z1 where a < 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
+1 SIMPLE z1 range a a 5 NULL 9 Using where; Using index
select max(a) from z1 where a < 3;
max(a)
1
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_bit.result b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
index 76a032d99c4..5ef5783d866 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_bit.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
@@ -675,7 +675,7 @@ INSERT INTO t1(a) VALUES
(65535),(65525),(65535),(65535),(65535),(65535),(65535),(65535),(65535),(65535);
EXPLAIN SELECT 1 FROM t1 GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL a 3 NULL 10 Using index
+1 SIMPLE t1 range NULL a 3 NULL 11 Using index for group-by
SELECT 1 FROM t1 GROUP BY a;
1
1
@@ -759,7 +759,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b));
INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0);
EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort
+1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_datetime.result b/storage/tokudb/mysql-test/tokudb/r/type_datetime.result
index dbe93b37271..61aec6f9ea7 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_datetime.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_datetime.result
@@ -105,7 +105,7 @@ date numfacture expedition
0000-00-00 00:00:00 1212 0001-00-00 00:00:00
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL expedition NULL NULL NULL 2 Using where
+1 SIMPLE t1 ref expedition expedition 5 const 2
drop table t1;
create table t1 (a datetime not null, b datetime not null);
insert into t1 values (now(), now());
diff --git a/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result b/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result
index 80402df665d..88f28362119 100644
--- a/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result
+++ b/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result
@@ -20,7 +20,7 @@ z a b c
999 4 40 400
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
+1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
select* from foo where b > 10;
z a b c
999 2 20 200
@@ -40,7 +40,7 @@ a b c
4 40 400
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
+1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
select* from foo where b > 10;
a b c
2 20 200
@@ -59,7 +59,7 @@ a b c z
4 40 400 NULL
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
+1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
select* from foo where b > 10;
a b c z
2 20 200 NULL
@@ -94,7 +94,7 @@ a b c
3 30 300
4 40 400
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
+1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
a b c
2 20 200
3 30 300
@@ -110,7 +110,7 @@ a b c
4 40 400
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
+1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
select* from foo where b > 10;
a b c
2 20 200
@@ -154,7 +154,7 @@ a b c g
4 40 400 NULL
5 50 500 NULL
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 5 NULL 5 Using where; Using index
+1 SIMPLE foo range b b 5 NULL 3 Using where; Using index
set autocommit=on;
explain select * from foo;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/storage/tokudb/mysql-test/tokudb_alter_table/r/hcr3.result b/storage/tokudb/mysql-test/tokudb_alter_table/r/hcr3.result
index b7aefaa4b8d..5e044461d84 100644
--- a/storage/tokudb/mysql-test/tokudb_alter_table/r/hcr3.result
+++ b/storage/tokudb/mysql-test/tokudb_alter_table/r/hcr3.result
@@ -43,7 +43,7 @@ foo CREATE TABLE `foo` (
) ENGINE=TokuDB DEFAULT CHARSET=latin1
explain select bb from foo FORCE INDEX (b) where bb > 5;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index b b 9 NULL 1 Using where; Using index
+1 SIMPLE foo range b b 9 NULL 1 Using where; Using index
select bb from foo FORCE INDEX (b) where bb > 5;
bb
10
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/2383.result b/storage/tokudb/mysql-test/tokudb_bugs/r/2383.result
index bda2cceb7ba..fce13e39504 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/2383.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/2383.result
@@ -10,7 +10,7 @@ create table foo (a char (255), key (a))charset=utf8;
insert into foo values (repeat('A', 255));
explain select a from foo where a > "a";
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo index a a 766 NULL 1 Using where; Using index
+1 SIMPLE foo range a a 766 NULL 1 Using where; Using index
select a from foo where a > "a";
a
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result b/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result
index 50e5b1940b0..0dd05170252 100644
--- a/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result
+++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/mrr.result
@@ -33,7 +33,7 @@ explain
SELECT t3.task_id, t3.field FROM
t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index PRIMARY,ymtasks_type ymtasks_type 2 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY,ymtasks_type ymtasks_type 2 NULL 2 Using where; Using index
1 SIMPLE t3 ref ymtasksoptions_task ymtasksoptions_task 4 test.t2.task_id 1
SELECT t3.task_id, t3.field FROM
t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11);
@@ -84,7 +84,7 @@ explain
SELECT t3.task_id, t3.field FROM
t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index PRIMARY,ymtasks_type ymtasks_type 2 NULL 2 Using where; Using index
+1 SIMPLE t2 range PRIMARY,ymtasks_type ymtasks_type 2 NULL 2 Using where; Using index
1 SIMPLE t3 ref ymtasksoptions_task ymtasksoptions_task 4 test.t2.task_id 1 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
SELECT t3.task_id, t3.field FROM
t3,t2 WHERE t3.task_id=t2.task_id AND t2.type NOT IN (8,11);