Commit 9cac7649 authored by Sergei Petrunia's avatar Sergei Petrunia

EXPLAIN FORMAT=JSON: Support range+MRR plans (when MRR is used but BKA is not)

parent 8fb2c80f
...@@ -665,4 +665,31 @@ EXPLAIN ...@@ -665,4 +665,31 @@ EXPLAIN
} }
set optimizer_switch=@tmp; set optimizer_switch=@tmp;
drop table t1,t2; drop table t1,t2;
#
# MRR for range access (no BKA, just MRR)
#
create table t1 (a int, b int, key(a));
insert into t1 select tbl1.a+10*tbl2.a, 12345 from t0 tbl1, t0 tbl2;
set @tmp= @@optimizer_switch;
set optimizer_switch='mrr=on,mrr_sort_keys=on';
explain format=json select * from t1 where a < 3;
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t1",
"access_type": "range",
"possible_keys": ["a"],
"key": "a",
"key_length": "5",
"used_key_parts": ["a"],
"rows": 1,
"filtered": 100,
"index_condition": "(t1.a < 3)",
"mrr_type": "Rowid-ordered scan"
}
}
}
drop table t1;
drop table t0; drop table t0;
...@@ -134,5 +134,17 @@ select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b); ...@@ -134,5 +134,17 @@ select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b);
set optimizer_switch=@tmp; set optimizer_switch=@tmp;
drop table t1,t2; drop table t1,t2;
--echo #
--echo # MRR for range access (no BKA, just MRR)
--echo #
create table t1 (a int, b int, key(a));
insert into t1 select tbl1.a+10*tbl2.a, 12345 from t0 tbl1, t0 tbl2;
set @tmp= @@optimizer_switch;
set optimizer_switch='mrr=on,mrr_sort_keys=on';
explain format=json select * from t1 where a < 3;
drop table t1;
drop table t0; drop table t0;
...@@ -1144,6 +1144,9 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t ...@@ -1144,6 +1144,9 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t
case ET_LOOSESCAN: case ET_LOOSESCAN:
writer->add_member("loose_scan").add_bool(true); writer->add_member("loose_scan").add_bool(true);
break; break;
case ET_USING_MRR:
writer->add_member("mrr_type").add_str(mrr_type.c_ptr());
break;
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
} }
......
...@@ -450,13 +450,24 @@ enum explain_extra_tag ...@@ -450,13 +450,24 @@ enum explain_extra_tag
}; };
/*
Explain data structure describing join buffering use.
*/
class EXPLAIN_BKA_TYPE class EXPLAIN_BKA_TYPE
{ {
public: public:
EXPLAIN_BKA_TYPE() : join_alg(NULL) {} EXPLAIN_BKA_TYPE() : join_alg(NULL) {}
bool incremental; bool incremental;
/*
NULL if no join buferring used.
Other values: BNL, BNLH, BKA, BKAH.
*/
const char *join_alg; const char *join_alg;
/* Information about MRR usage. */
StringBuffer<64> mrr_type; StringBuffer<64> mrr_type;
bool is_using_jbuf() { return (join_alg != NULL); } bool is_using_jbuf() { return (join_alg != NULL); }
......
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