summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/explain_json.result27
-rw-r--r--mysql-test/t/explain_json.test12
-rw-r--r--sql/sql_explain.cc3
-rw-r--r--sql/sql_explain.h11
4 files changed, 53 insertions, 0 deletions
diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result
index c159161a8bd..42c273e7209 100644
--- a/mysql-test/r/explain_json.result
+++ b/mysql-test/r/explain_json.result
@@ -665,4 +665,31 @@ EXPLAIN
}
set optimizer_switch=@tmp;
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;
diff --git a/mysql-test/t/explain_json.test b/mysql-test/t/explain_json.test
index 20c5359e646..5b6a0e135eb 100644
--- a/mysql-test/t/explain_json.test
+++ b/mysql-test/t/explain_json.test
@@ -134,5 +134,17 @@ select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b);
set optimizer_switch=@tmp;
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;
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 1bfcc1156d3..f2be3777da8 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1144,6 +1144,9 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t
case ET_LOOSESCAN:
writer->add_member("loose_scan").add_bool(true);
break;
+ case ET_USING_MRR:
+ writer->add_member("mrr_type").add_str(mrr_type.c_ptr());
+ break;
default:
DBUG_ASSERT(0);
}
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index 352be32bbcd..5e96cd78657 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -450,13 +450,24 @@ enum explain_extra_tag
};
+/*
+ Explain data structure describing join buffering use.
+*/
+
class EXPLAIN_BKA_TYPE
{
public:
EXPLAIN_BKA_TYPE() : join_alg(NULL) {}
bool incremental;
+
+ /*
+ NULL if no join buferring used.
+ Other values: BNL, BNLH, BKA, BKAH.
+ */
const char *join_alg;
+
+ /* Information about MRR usage. */
StringBuffer<64> mrr_type;
bool is_using_jbuf() { return (join_alg != NULL); }