summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/opt_qpf.cc15
-rw-r--r--sql/opt_qpf.h14
-rw-r--r--sql/opt_range.h6
-rw-r--r--sql/sql_join_cache.cc35
-rw-r--r--sql/sql_join_cache.h7
-rw-r--r--sql/sql_select.cc5
6 files changed, 45 insertions, 37 deletions
diff --git a/sql/opt_qpf.cc b/sql/opt_qpf.cc
index 34b1a213207..6316fc0f0e9 100644
--- a/sql/opt_qpf.cc
+++ b/sql/opt_qpf.cc
@@ -489,7 +489,17 @@ void QPF_table_access::append_tag_name(String *str, enum Extra_tag tag)
case ET_USING_JOIN_BUFFER:
{
str->append(extra_tag_text[tag]);
- str->append(join_buffer_type);
+
+ str->append(STRING_WITH_LEN(" ("));
+ const char *buffer_type= bka_type.incremental ? "incremental" : "flat";
+ str->append(buffer_type);
+ str->append(STRING_WITH_LEN(", "));
+ str->append(bka_type.join_alg);
+ str->append(STRING_WITH_LEN(" join"));
+ str->append(STRING_WITH_LEN(")"));
+ if (bka_type.mrr_type.length())
+ str->append(bka_type.mrr_type);
+
break;
}
case ET_FIRST_MATCH:
@@ -507,7 +517,8 @@ void QPF_table_access::append_tag_name(String *str, enum Extra_tag tag)
case ET_USING_INDEX_FOR_GROUP_BY:
{
str->append(extra_tag_text[tag]);
- str->append(loose_scan_type);
+ if (loose_scan_is_scanning)
+ str->append(" (scanning)");
break;
}
default:
diff --git a/sql/opt_qpf.h b/sql/opt_qpf.h
index b82f004ff7f..67f6b591e92 100644
--- a/sql/opt_qpf.h
+++ b/sql/opt_qpf.h
@@ -272,6 +272,15 @@ enum Extra_tag
};
+typedef struct st_qpf_bka_type
+{
+ bool incremental;
+ const char *join_alg;
+ StringBuffer<64> mrr_type;
+
+} QPF_BKA_TYPE;
+
+
/*
Query Plan Footprint for a JOIN_TAB.
*/
@@ -329,7 +338,7 @@ public:
StringBuffer<64> quick_info;
// Valid if ET_USING_INDEX_FOR_GROUP_BY is present
- StringBuffer<64> loose_scan_type;
+ bool loose_scan_is_scanning;
// valid with ET_RANGE_CHECKED_FOR_EACH_RECORD
key_map range_checked_map;
@@ -338,7 +347,8 @@ public:
StringBuffer<64> mrr_type;
// valid with ET_USING_JOIN_BUFFER
- StringBuffer<64> join_buffer_type;
+ //StringBuffer<64> join_buffer_type;
+ QPF_BKA_TYPE bka_type;
//TABLE *firstmatch_table;
StringBuffer<64> firstmatch_table_name;
diff --git a/sql/opt_range.h b/sql/opt_range.h
index ddaa5c5e59a..e67274c19a6 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -944,11 +944,7 @@ public:
void dbug_dump(int indent, bool verbose);
#endif
bool is_agg_distinct() { return have_agg_distinct; }
- virtual void append_loose_scan_type(String *str)
- {
- if (is_index_scan)
- str->append(STRING_WITH_LEN(" (scanning)"));
- }
+ bool loose_scan_is_scanning() { return is_index_scan; }
};
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 9fca8730cb5..7710db5c7ba 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -2568,34 +2568,26 @@ finish:
none
*/
-void JOIN_CACHE::print_explain_comment(String *str)
+void JOIN_CACHE::save_qpf(struct st_qpf_bka_type *qpf)
{
- str->append(STRING_WITH_LEN(" ("));
- const char *buffer_type= prev_cache ? "incremental" : "flat";
- str->append(buffer_type);
- str->append(STRING_WITH_LEN(", "));
-
- const char *join_alg="";
+ qpf->incremental= test(prev_cache);
+
switch (get_join_alg()) {
case BNL_JOIN_ALG:
- join_alg= "BNL";
+ qpf->join_alg= "BNL";
break;
case BNLH_JOIN_ALG:
- join_alg= "BNLH";
+ qpf->join_alg= "BNLH";
break;
case BKA_JOIN_ALG:
- join_alg= "BKA";
+ qpf->join_alg= "BKA";
break;
case BKAH_JOIN_ALG:
- join_alg= "BKAH";
+ qpf->join_alg= "BKAH";
break;
default:
DBUG_ASSERT(0);
}
-
- str->append(join_alg);
- str->append(STRING_WITH_LEN(" join"));
- str->append(STRING_WITH_LEN(")"));
}
/**
@@ -2621,18 +2613,17 @@ static void add_mrr_explain_info(String *str, uint mrr_mode, handler *file)
}
}
-
-void JOIN_CACHE_BKA::print_explain_comment(String *str)
+void JOIN_CACHE_BKA::save_qpf(struct st_qpf_bka_type *qpf)
{
- JOIN_CACHE::print_explain_comment(str);
- add_mrr_explain_info(str, mrr_mode, join_tab->table->file);
+ JOIN_CACHE::save_qpf(qpf);
+ add_mrr_explain_info(&qpf->mrr_type, mrr_mode, join_tab->table->file);
}
-void JOIN_CACHE_BKAH::print_explain_comment(String *str)
+void JOIN_CACHE_BKAH::save_qpf(struct st_qpf_bka_type *qpf)
{
- JOIN_CACHE::print_explain_comment(str);
- add_mrr_explain_info(str, mrr_mode, join_tab->table->file);
+ JOIN_CACHE::save_qpf(qpf);
+ add_mrr_explain_info(&qpf->mrr_type, mrr_mode, join_tab->table->file);
}
diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h
index 6953f6881ee..75589c3395f 100644
--- a/sql/sql_join_cache.h
+++ b/sql/sql_join_cache.h
@@ -63,6 +63,7 @@ typedef struct st_cache_field {
class JOIN_TAB_SCAN;
+struct st_qpf_bka_type;
/*
JOIN_CACHE is the base class to support the implementations of
@@ -657,7 +658,7 @@ public:
enum_nested_loop_state join_records(bool skip_last);
/* Add a comment on the join algorithm employed by the join cache */
- virtual void print_explain_comment(String *str);
+ virtual void save_qpf(struct st_qpf_bka_type *qpf);
THD *thd();
@@ -1335,7 +1336,7 @@ public:
/* Check index condition of the joined table for a record from BKA cache */
bool skip_index_tuple(range_id_t range_info);
- void print_explain_comment(String *str);
+ void save_qpf(struct st_qpf_bka_type *qpf);
};
@@ -1426,5 +1427,5 @@ public:
/* Check index condition of the joined table for a record from BKAH cache */
bool skip_index_tuple(range_id_t range_info);
- void print_explain_comment(String *str);
+ void save_qpf(struct st_qpf_bka_type *qpf);
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ed1cb35c29a..763c719f250 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -22907,7 +22907,7 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
QUICK_GROUP_MIN_MAX_SELECT *qgs=
(QUICK_GROUP_MIN_MAX_SELECT *) tab->select->quick;
qpt->push_extra(ET_USING_INDEX_FOR_GROUP_BY);
- qgs->append_loose_scan_type(&qpt->loose_scan_type);
+ qpt->loose_scan_is_scanning= qgs->loose_scan_is_scanning();
}
else
qpt->push_extra(ET_USING_INDEX);
@@ -22979,9 +22979,8 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
if (tab->cache)
{
qpt->push_extra(ET_USING_JOIN_BUFFER);
- tab->cache->print_explain_comment(&qpt->join_buffer_type);
+ tab->cache->save_qpf(&qpt->bka_type);
}
-
}
if (saved_join_tab)