summaryrefslogtreecommitdiff
path: root/sql/sql_explain.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-11-29 03:07:24 +0300
committerSergei Petrunia <psergey@askmonty.org>2014-11-29 03:07:24 +0300
commite235bb864d2b8daae3dc7061249f59fb0127bdc5 (patch)
treee8b48285ac8e14a5e0c004ccdcba6d60d3bc71ca /sql/sql_explain.cc
parent0b5d989c894a14ebcb786940fafd025e31523d8b (diff)
downloadmariadb-git-e235bb864d2b8daae3dc7061249f59fb0127bdc5.tar.gz
ANALYZE FORMAT=JSON: better output and tests
- Print r_loops - Always print r_* members. Print NULL values if no scans took place - Added testcases.
Diffstat (limited to 'sql/sql_explain.cc')
-rw-r--r--sql/sql_explain.cc44
1 files changed, 38 insertions, 6 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 4dce48e5944..72973825f51 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -815,10 +815,14 @@ void Explain_index_use::set_pseudo_key(MEM_ROOT *root, const char* key_name_arg)
}
+/*
+ Given r_filtered% from join buffer condition and join condition, produce a
+ combined r_filtered% number. This is needed for tabular EXPLAIN output which
+ has only one cell for r_filtered value.
+*/
+
double Explain_table_access::get_r_filtered()
{
- //psergey-todo: modify this to produce separate filtered% for both parts of
- //WHERE.
double r_filtered= tracker.get_filtered_after_where();
if (bka_type.is_using_jbuf())
r_filtered *= jbuf_tracker.get_filtered_after_where();
@@ -1156,15 +1160,27 @@ void Explain_table_access::print_explain_json(Explain_query *query,
writer->end_array();
}
+ /* r_loops (not present in tabular output) */
+ if (is_analyze)
+ {
+ writer->add_member("r_loops").add_ll(tracker.get_loops());
+ }
+
/* `rows` */
if (rows_set)
writer->add_member("rows").add_ll(rows);
/* `r_rows` */
- if (is_analyze && tracker.has_scans())
+ if (is_analyze)
{
- ha_rows avg_rows= tracker.get_avg_rows();
- writer->add_member("r_rows").add_ll(avg_rows);
+ writer->add_member("r_rows");
+ if (tracker.has_scans())
+ {
+ ha_rows avg_rows= tracker.get_avg_rows();
+ writer->add_ll(avg_rows);
+ }
+ else
+ writer->add_null();
}
/* `filtered` */
@@ -1173,7 +1189,13 @@ void Explain_table_access::print_explain_json(Explain_query *query,
/* `r_filtered` */
if (is_analyze)
- writer->add_member("r_filtered").add_double(get_r_filtered());
+ {
+ writer->add_member("r_filtered");
+ if (tracker.has_scans())
+ writer->add_double(tracker.get_filtered_after_where()*100.0);
+ else
+ writer->add_null();
+ }
for (int i=0; i < (int)extra_tags.elements(); i++)
{
@@ -1193,6 +1215,16 @@ void Explain_table_access::print_explain_json(Explain_query *query,
writer->add_member("attached_condition");
write_item(writer, where_cond);
}
+
+ if (is_analyze)
+ {
+ //writer->add_member("r_loops").add_ll(jbuf_tracker.get_loops());
+ writer->add_member("r_filtered");
+ if (jbuf_tracker.has_scans())
+ writer->add_double(jbuf_tracker.get_filtered_after_where()*100.0);
+ else
+ writer->add_null();
+ }
}
if (derived_select_number)