1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-6995: EXPLAIN JSON and ORDER BY, GROUP BY, etc

- Make ANALYZE correctly remember and report filesort() calls
- Temp.table use is collected but only basic info is reported.
This commit is contained in:
Sergei Petrunia
2015-06-06 00:32:27 +03:00
parent f7002c05ae
commit 93fc04ff1d
6 changed files with 339 additions and 46 deletions

View File

@ -23,7 +23,7 @@
#include "sql_select.h"
#include "my_json_writer.h"
void Filesort_tracker::print_json(Json_writer *writer)
void Filesort_tracker::print_json_members(Json_writer *writer)
{
const char *varied_str= "(varied across executions)";
writer->add_member("r_loops").add_ll(r_loops);
@ -60,3 +60,56 @@ void Filesort_tracker::print_json(Json_writer *writer)
}
}
/*
Report that we are doing a filesort.
@return
Tracker object to be used with filesort
*/
Filesort_tracker *Sort_and_group_tracker::report_sorting()
{
DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS);
if (total_actions)
{
/* This is not the first execution. Check */
if (qep_actions[cur_action] != EXPL_ACTION_FILESORT)
{
varied_executions= true;
cur_action++;
if (!dummy_fsort_tracker)
dummy_fsort_tracker= new (current_thd->mem_root) Filesort_tracker();
return dummy_fsort_tracker;
}
return qep_actions_data[cur_action++].filesort_tracker;
}
Filesort_tracker *fs_tracker= new(current_thd->mem_root)Filesort_tracker();
qep_actions_data[cur_action].filesort_tracker= fs_tracker;
qep_actions[cur_action++]= EXPL_ACTION_FILESORT;
return fs_tracker;
}
void Sort_and_group_tracker::report_tmp_table(TABLE *tbl)
{
DBUG_ASSERT(cur_action < MAX_QEP_ACTIONS);
if (total_actions)
{
/* This is not the first execution. Check if the steps match. */
// todo: should also check that tmp.table kinds are the same.
if (qep_actions[cur_action] != EXPL_ACTION_TEMPTABLE)
varied_executions= true;
}
if (!varied_executions)
{
qep_actions[cur_action]= EXPL_ACTION_TEMPTABLE;
// qep_actions_data[cur_action]= ....
}
cur_action++;
}