diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index b8d02ecbc78..22e3462bc98 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -1219,7 +1219,7 @@ count(*) 623 explain select * from t1 where c between 1 and 2500; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range c c 5 NULL # Using index condition; Using MRR +1 SIMPLE t1 range c c 5 NULL # Using index condition; Rowid-ordered scan update t1 set c=a; explain select * from t1 where c between 1 and 2500; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/r/maria.result index 472515ddb55..e0f1175d845 100644 --- a/mysql-test/suite/maria/r/maria.result +++ b/mysql-test/suite/maria/r/maria.result @@ -389,10 +389,10 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref a a 4 test.t2.a 3 explain select * from t1 where a=0 or a=2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Using MRR +1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Rowid-ordered scan 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 4 Using index condition; Using MRR +1 SIMPLE t1 range a a 4 NULL 4 Using index condition; Rowid-ordered scan explain select * from t1 where c=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref c,c_2 c 5 const 1 diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index 91fc6643af4..4213aecf85d 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -144,7 +144,7 @@ explain select * from t1,t2 where t1.b=t2.c and d <= 100; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where -1 SIMPLE t2 ref idx idx 5 test.t1.b 2 Using where; Using join buffer (flat, BKA join) +1 SIMPLE t2 ref idx idx 5 test.t1.b 2 Using where; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan select * from t1,t2 where t1.b=t2.c and d <= 100; a b c d v 4 20 20 100 101 diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result index 68a9b2a7a63..a54a2f828b5 100644 --- a/mysql-test/suite/vcol/r/vcol_select_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result @@ -44,7 +44,7 @@ a b c 1 -1 -1 explain select * from t3 where c>=-1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan # select_type=SIMPLE, type=ref select * from t1,t3 where t1.c=t3.c and t3.c=-1; a b c a b c @@ -141,7 +141,7 @@ a b c 2 -2 -2 explain select * from t3 where c >= -2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan # SELECT * FROM tbl_name WHERE select * from t3 where a between 1 and 2; a b c @@ -165,7 +165,7 @@ a b c 2 -2 -2 explain select * from t3 where c between -2 and -1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where a between 1 and 2 order by b; a b c @@ -205,7 +205,7 @@ a b c 1 -1 -1 explain select * from t3 where c between -2 and -1 order by b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR; Using filesort +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where b between -2 and -1 order by c; a b c diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result index a5d24a32693..dd169602654 100644 --- a/mysql-test/suite/vcol/r/vcol_select_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result @@ -44,7 +44,7 @@ a b c 1 -1 -1 explain select * from t3 where c>=-1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Rowid-ordered scan # select_type=SIMPLE, type=ref select * from t1,t3 where t1.c=t3.c and t3.c=-1; a b c a b c @@ -141,7 +141,7 @@ a b c 1 -1 -1 explain select * from t3 where c >= -2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Rowid-ordered scan # SELECT * FROM tbl_name WHERE select * from t3 where a between 1 and 2; a b c @@ -149,7 +149,7 @@ a b c 1 -1 -1 explain select * from t3 where a between 1 and 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Rowid-ordered scan # SELECT * FROM tbl_name WHERE select * from t3 where b between -2 and -1; a b c @@ -165,7 +165,7 @@ a b c 1 -1 -1 explain select * from t3 where c between -2 and -1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where a between 1 and 2 order by c; a b c @@ -173,7 +173,7 @@ a b c 1 -1 -1 explain select * from t3 where a between 1 and 2 order by c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Using MRR; Using filesort +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Rowid-ordered scan; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where b between -2 and -1 order by a; a b c @@ -189,7 +189,7 @@ a b c 2 -2 -2 explain select * from t3 where c between -2 and -1 order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using where; Using MRR; Using filesort +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using where; Rowid-ordered scan; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where b between -2 and -1 order by b; a b c @@ -205,7 +205,7 @@ a b c 1 -1 -1 explain select * from t3 where c between -2 and -1 order by b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR; Using filesort +1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Rowid-ordered scan; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where b between -2 and -1 order by c; a b c diff --git a/sql/handler.h b/sql/handler.h index 36cb81017c6..12413d6238a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1358,6 +1358,22 @@ void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, */ #define HA_MRR_MATERIALIZED_KEYS 256 +/* + The following bits are reserved for use by MRR implementation. The intended + use scenario: + + * sql layer calls handler->multi_range_read_info[_const]() + - MRR implementation figures out what kind of scan it will perform, saves + the result in *mrr_mode parameter. + * sql layer remembers what was returned in *mrr_mode + + * the optimizer picks the query plan (which may or may not include the MRR + scan that was estimated by the multi_range_read_info[_const] call) + + * if the query is an EXPLAIN statement, sql layer will call + handler->multi_range_read_explain_info(mrr_mode) to get a text description + of the picked MRR scan; the description will be a part of EXPLAIN output. +*/ #define HA_MRR_IMPLEMENTATION_FLAG1 512 #define HA_MRR_IMPLEMENTATION_FLAG2 1024 #define HA_MRR_IMPLEMENTATION_FLAG3 2048