summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-12-02 01:40:10 +0300
committerSergei Petrunia <psergey@askmonty.org>2014-12-02 01:40:10 +0300
commit0000695025dea9740842ea57a5d79cd56d880405 (patch)
treea3dab25aa3464ce8619cf87f4775cc6bdfba9230 /sql
parenta35b05399ef20de3c0d5e521a62b5e297c6ccd1e (diff)
downloadmariadb-git-0000695025dea9740842ea57a5d79cd56d880405.tar.gz
EXPLAIN FORMAT=JSON
Add support for semi-join strategies: FirstMatch, DuplicateWeedout, LooseScan.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_explain.cc23
-rw-r--r--sql/sql_explain.h5
-rw-r--r--sql/sql_select.cc7
3 files changed, 32 insertions, 3 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index c4f8002494f..7e6c1c6cf5c 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -732,7 +732,13 @@ void Explain_basic_join::print_explain_json(Explain_query *query,
writer->add_member("select_id").add_ll(select_id);
for (uint i=0; i< n_join_tabs; i++)
{
+ if (join_tabs[i]->start_dups_weedout)
+ writer->add_member("duplicates_removal").start_object();
+
join_tabs[i]->print_explain_json(query, writer, is_analyze);
+
+ if (join_tabs[i]->end_dups_weedout)
+ writer->end_object();
}
print_explain_json_for_children(query, writer, is_analyze);
writer->end_object();
@@ -1089,9 +1095,7 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t
write_item(writer, pushed_index_cond);
break;
case ET_USING_WHERE:
- if (where_cond)
{
- writer->add_member("attached_condition");
/*
We are printing the condition that is checked when scanning this
table.
@@ -1099,7 +1103,11 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t
- in other cases, it is where_cond.
*/
Item *item= bka_type.is_using_jbuf()? cache_cond: where_cond;
- write_item(writer, item);
+ if (item)
+ {
+ writer->add_member("attached_condition");
+ write_item(writer, item);
+ }
}
break;
case ET_USING_INDEX:
@@ -1110,6 +1118,15 @@ void Explain_table_access::tag_to_json(Json_writer *writer, enum explain_extra_t
break;
case ET_USING_JOIN_BUFFER:
/* Do nothing. Join buffer is handled differently */
+ case ET_START_TEMPORARY:
+ case ET_END_TEMPORARY:
+ /* Handled as "duplicates_removal: { ... } */
+ break;
+ case ET_FIRST_MATCH:
+ writer->add_member("first_match").add_str(firstmatch_table_name.c_ptr());
+ break;
+ case ET_LOOSESCAN:
+ writer->add_member("loose_scan").add_bool(true);
break;
default:
DBUG_ASSERT(0);
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index 20e2f856840..68ef59c732d 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -539,6 +539,8 @@ public:
Explain_table_access() :
derived_select_number(0),
non_merged_sjm_number(0),
+ start_dups_weedout(false),
+ end_dups_weedout(false),
where_cond(NULL),
cache_cond(NULL),
pushed_index_cond(NULL),
@@ -615,6 +617,9 @@ public:
EXPLAIN_BKA_TYPE bka_type;
StringBuffer<32> firstmatch_table_name;
+
+ bool start_dups_weedout;
+ bool end_dups_weedout;
/*
Note: lifespan of WHERE condition is less than lifespan of this object.
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 511e7106bd5..985b743eaad 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -23641,9 +23641,16 @@ void JOIN_TAB::save_explain_data(Explain_table_access *eta, table_map prefix_tab
}
if (tab->first_weedout_table)
+ {
+ eta->start_dups_weedout= true;
eta->push_extra(ET_START_TEMPORARY);
+ }
if (tab->check_weed_out_table)
+ {
eta->push_extra(ET_END_TEMPORARY);
+ eta->end_dups_weedout= true;
+ }
+
else if (tab->do_firstmatch)
{
if (tab->do_firstmatch == /*join->join_tab*/ first_top_tab - 1)