Commit befacafd authored by Sergey Petrunya's avatar Sergey Petrunya

[SHOW] EXPLAIN UPDATE/DELETE, code re-structuring

- Let Query Plan Footprint store join buffer type 
  in binary form, not string.
- Same for LooseScan type.
parent 5422098b
......@@ -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:
......
......@@ -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;
......
......@@ -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; }
};
......
......@@ -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);
}
......
......@@ -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);
};
......@@ -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)
......
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