Commit d4ce8272 authored by Sergey Petrunya's avatar Sergey Petrunya

Amend the previous cset:

Make EXPLAIN better at displaying MRR/BKA:
- Update all .result files
- Extra comments
parent 997445bc
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 <non-vcol expr>
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 <non-vcol expr> ORDER BY <non-indexed vcol>
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 <non-indexed vcol expr> ORDER BY <indexed vcol>
select * from t3 where b between -2 and -1 order by c;
a b c
......
......@@ -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 <non-vcol expr>
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 <non-indexed vcol expr>
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 <non-vcol expr> ORDER BY <indexed vcol>
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 <non-indexed vcol expr> ORDER BY <non-vcol>
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 <non-indexed vcol expr> ORDER BY <non-indexed vcol>
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 <non-indexed vcol expr> ORDER BY <indexed vcol>
select * from t3 where b between -2 and -1 order by c;
a b c
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment