diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2015-06-06 00:32:27 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2015-06-06 00:32:27 +0300 |
commit | 93fc04ff1dc613a9ad75ccc57988a6b57b94b6cb (patch) | |
tree | 09e49d64b7faf8cbd843b4875b9c167cd26aed17 /sql/sql_analyze_stmt.cc | |
parent | f7002c05ae4e4a09bc6859ccc568064cfd6bb268 (diff) | |
download | mariadb-git-93fc04ff1dc613a9ad75ccc57988a6b57b94b6cb.tar.gz |
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.
Diffstat (limited to 'sql/sql_analyze_stmt.cc')
-rw-r--r-- | sql/sql_analyze_stmt.cc | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/sql/sql_analyze_stmt.cc b/sql/sql_analyze_stmt.cc index 4874c33a544..d2eb46298f1 100644 --- a/sql/sql_analyze_stmt.cc +++ b/sql/sql_analyze_stmt.cc @@ -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++; +} + |