Commit b05383cb authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-7835: ANALYZE FORMAT=JSON should show buffer sizes

parent 69719446
......@@ -143,6 +143,7 @@ ANALYZE
"attached_condition": "(tbl2.b < 60)"
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"r_filtered": 100
}
......@@ -180,6 +181,7 @@ ANALYZE
"attached_condition": "(tbl2.b < 60)"
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"attached_condition": "(tbl1.c > tbl2.c)",
"r_filtered": 15.833
......
......@@ -365,6 +365,7 @@ EXPLAIN
"attached_condition": "(tbl2.b < 5)"
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"attached_condition": "(tbl2.a = tbl1.a)"
}
......@@ -618,6 +619,7 @@ EXPLAIN
"filtered": 100
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL"
}
}
......@@ -651,6 +653,7 @@ EXPLAIN
"first_match": "t2"
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"attached_condition": "((t1.b = t2.b) and (t1.a = t2.a))"
}
......@@ -687,6 +690,7 @@ EXPLAIN
"filtered": 100
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"attached_condition": "((t1.b = t2.b) and (t1.a = t2.a))"
}
......@@ -799,6 +803,7 @@ EXPLAIN
"filtered": 100
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"attached_condition": "((t2.b <> outer_t1.a) and trigcond(((<cache>(outer_t1.a) = t1.a) or isnull(t1.a))))"
}
......@@ -849,6 +854,7 @@ EXPLAIN
"filtered": 100
},
"buffer_type": "flat",
"buffer_size": "128Kb",
"join_type": "BNL",
"attached_condition": "(tbl2.b = tbl1.b)"
}
......
......@@ -130,6 +130,27 @@ void Json_writer::add_ll(longlong val)
}
/* Add a memory size, printing in Kb, Kb, Gb if necessary */
void Json_writer::add_size(longlong val)
{
char buf[64];
if (val < 1024)
my_snprintf(buf, sizeof(buf), "%ld", val);
else if (val < 1024*1024*16)
{
/* Values less than 16MB are specified in KB for precision */
size_t len= my_snprintf(buf, sizeof(buf), "%ld", val/1024);
strcpy(buf + len, "Kb");
}
else
{
size_t len= my_snprintf(buf, sizeof(buf), "%ld", val/(1024*1024));
strcpy(buf + len, "Mb");
}
add_str(buf);
}
void Json_writer::add_double(double val)
{
char buf[64];
......
......@@ -108,6 +108,7 @@ class Json_writer
void add_str(const String &str);
void add_ll(longlong val);
void add_size(longlong val);
void add_double(double val);
void add_bool(bool val);
void add_null();
......
......@@ -1360,6 +1360,7 @@ void Explain_table_access::print_explain_json(Explain_query *query,
writer->end_object(); // "block-nl-join"
writer->add_member("buffer_type").add_str(bka_type.incremental?
"incremental":"flat");
writer->add_member("buffer_size").add_size(bka_type.join_buffer_size);
writer->add_member("join_type").add_str(bka_type.join_alg);
if (bka_type.mrr_type.length())
writer->add_member("mrr_type").add_str(bka_type.mrr_type);
......
......@@ -511,6 +511,8 @@ class EXPLAIN_BKA_TYPE
public:
EXPLAIN_BKA_TYPE() : join_alg(NULL) {}
size_t join_buffer_size;
bool incremental;
/*
......
......@@ -2582,6 +2582,8 @@ void JOIN_CACHE::save_explain_data(EXPLAIN_BKA_TYPE *explain)
{
explain->incremental= MY_TEST(prev_cache);
explain->join_buffer_size= get_join_buffer_size();
switch (get_join_alg()) {
case BNL_JOIN_ALG:
explain->join_alg= "BNL";
......
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