mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
[SHOW] EXPLAIN UPDATE/DELETE, code re-structuring
- Let Query Plan Footprint store join buffer type in binary form, not string. - Same for LooseScan type.
This commit is contained in:
@ -489,7 +489,17 @@ void QPF_table_access::append_tag_name(String *str, enum Extra_tag tag)
|
|||||||
case ET_USING_JOIN_BUFFER:
|
case ET_USING_JOIN_BUFFER:
|
||||||
{
|
{
|
||||||
str->append(extra_tag_text[tag]);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case ET_FIRST_MATCH:
|
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:
|
case ET_USING_INDEX_FOR_GROUP_BY:
|
||||||
{
|
{
|
||||||
str->append(extra_tag_text[tag]);
|
str->append(extra_tag_text[tag]);
|
||||||
str->append(loose_scan_type);
|
if (loose_scan_is_scanning)
|
||||||
|
str->append(" (scanning)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
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.
|
Query Plan Footprint for a JOIN_TAB.
|
||||||
*/
|
*/
|
||||||
@ -329,7 +338,7 @@ public:
|
|||||||
StringBuffer<64> quick_info;
|
StringBuffer<64> quick_info;
|
||||||
|
|
||||||
// Valid if ET_USING_INDEX_FOR_GROUP_BY is present
|
// 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
|
// valid with ET_RANGE_CHECKED_FOR_EACH_RECORD
|
||||||
key_map range_checked_map;
|
key_map range_checked_map;
|
||||||
@ -338,7 +347,8 @@ public:
|
|||||||
StringBuffer<64> mrr_type;
|
StringBuffer<64> mrr_type;
|
||||||
|
|
||||||
// valid with ET_USING_JOIN_BUFFER
|
// valid with ET_USING_JOIN_BUFFER
|
||||||
StringBuffer<64> join_buffer_type;
|
//StringBuffer<64> join_buffer_type;
|
||||||
|
QPF_BKA_TYPE bka_type;
|
||||||
|
|
||||||
//TABLE *firstmatch_table;
|
//TABLE *firstmatch_table;
|
||||||
StringBuffer<64> firstmatch_table_name;
|
StringBuffer<64> firstmatch_table_name;
|
||||||
|
@ -944,11 +944,7 @@ public:
|
|||||||
void dbug_dump(int indent, bool verbose);
|
void dbug_dump(int indent, bool verbose);
|
||||||
#endif
|
#endif
|
||||||
bool is_agg_distinct() { return have_agg_distinct; }
|
bool is_agg_distinct() { return have_agg_distinct; }
|
||||||
virtual void append_loose_scan_type(String *str)
|
bool loose_scan_is_scanning() { return is_index_scan; }
|
||||||
{
|
|
||||||
if (is_index_scan)
|
|
||||||
str->append(STRING_WITH_LEN(" (scanning)"));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2568,34 +2568,26 @@ finish:
|
|||||||
none
|
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(" ("));
|
qpf->incremental= test(prev_cache);
|
||||||
const char *buffer_type= prev_cache ? "incremental" : "flat";
|
|
||||||
str->append(buffer_type);
|
|
||||||
str->append(STRING_WITH_LEN(", "));
|
|
||||||
|
|
||||||
const char *join_alg="";
|
|
||||||
switch (get_join_alg()) {
|
switch (get_join_alg()) {
|
||||||
case BNL_JOIN_ALG:
|
case BNL_JOIN_ALG:
|
||||||
join_alg= "BNL";
|
qpf->join_alg= "BNL";
|
||||||
break;
|
break;
|
||||||
case BNLH_JOIN_ALG:
|
case BNLH_JOIN_ALG:
|
||||||
join_alg= "BNLH";
|
qpf->join_alg= "BNLH";
|
||||||
break;
|
break;
|
||||||
case BKA_JOIN_ALG:
|
case BKA_JOIN_ALG:
|
||||||
join_alg= "BKA";
|
qpf->join_alg= "BKA";
|
||||||
break;
|
break;
|
||||||
case BKAH_JOIN_ALG:
|
case BKAH_JOIN_ALG:
|
||||||
join_alg= "BKAH";
|
qpf->join_alg= "BKAH";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBUG_ASSERT(0);
|
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::save_qpf(struct st_qpf_bka_type *qpf)
|
||||||
void JOIN_CACHE_BKA::print_explain_comment(String *str)
|
|
||||||
{
|
{
|
||||||
JOIN_CACHE::print_explain_comment(str);
|
JOIN_CACHE::save_qpf(qpf);
|
||||||
add_mrr_explain_info(str, mrr_mode, join_tab->table->file);
|
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);
|
JOIN_CACHE::save_qpf(qpf);
|
||||||
add_mrr_explain_info(str, mrr_mode, join_tab->table->file);
|
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;
|
class JOIN_TAB_SCAN;
|
||||||
|
|
||||||
|
struct st_qpf_bka_type;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
JOIN_CACHE is the base class to support the implementations of
|
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);
|
enum_nested_loop_state join_records(bool skip_last);
|
||||||
|
|
||||||
/* Add a comment on the join algorithm employed by the join cache */
|
/* 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();
|
THD *thd();
|
||||||
|
|
||||||
@ -1335,7 +1336,7 @@ public:
|
|||||||
/* Check index condition of the joined table for a record from BKA cache */
|
/* Check index condition of the joined table for a record from BKA cache */
|
||||||
bool skip_index_tuple(range_id_t range_info);
|
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 */
|
/* Check index condition of the joined table for a record from BKAH cache */
|
||||||
bool skip_index_tuple(range_id_t range_info);
|
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 *qgs=
|
||||||
(QUICK_GROUP_MIN_MAX_SELECT *) tab->select->quick;
|
(QUICK_GROUP_MIN_MAX_SELECT *) tab->select->quick;
|
||||||
qpt->push_extra(ET_USING_INDEX_FOR_GROUP_BY);
|
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
|
else
|
||||||
qpt->push_extra(ET_USING_INDEX);
|
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)
|
if (tab->cache)
|
||||||
{
|
{
|
||||||
qpt->push_extra(ET_USING_JOIN_BUFFER);
|
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)
|
if (saved_join_tab)
|
||||||
|
Reference in New Issue
Block a user