diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2015-03-24 16:17:41 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2015-03-24 16:17:41 +0300 |
commit | 77e16ce7d65793451c640014b342d23a28fc1060 (patch) | |
tree | 4a488e2e8ab1cba7d60293681cee7accf4cc2469 /sql/sql_explain.cc | |
parent | b273e4a5c0e2342cf407d451466df164adfb36c6 (diff) | |
download | mariadb-git-77e16ce7d65793451c640014b342d23a28fc1060.tar.gz |
MDEV-7648: Extra data in ANALYZE FORMAT=JSON $stmt
Switch from relying on PERFORMANCE_SCHEMA to using our
own hooks for counting the time spent reading rows from
tables.
Diffstat (limited to 'sql/sql_explain.cc')
-rw-r--r-- | sql/sql_explain.cc | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 873ed74a1a2..9d82f4fe19f 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1295,8 +1295,11 @@ void Explain_table_access::print_explain_json(Explain_query *query, else writer->add_null(); - op_tracker.end_tracking(); - op_tracker.print_json(writer); + if (op_tracker.get_loops()) + { + writer->add_member("r_total_time_ms"). + add_double(op_tracker.get_time_ms()); + } } /* `filtered` */ @@ -1979,40 +1982,3 @@ void create_explain_query_if_not_exists(LEX *lex, MEM_ROOT *mem_root) create_explain_query(lex, mem_root); } -////////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////////// - -void Table_op_tracker::start_tracking(TABLE *table) -{ - //TODO: will this compile without P_S ? - start_count= end_count= 0; - if ((psi_table= table->file->m_psi)) - { - PSI_CALL_get_table_current_stats(psi_table, &start_count, &start_sum); - } -} - - -void Table_op_tracker::end_tracking() -{ - if (psi_table) - { - PSI_CALL_get_table_current_stats(psi_table, &end_count, &end_sum); - } -} - -void Table_op_tracker::print_json(Json_writer *writer) -{ - if (start_count != end_count) - { - /* - We have time in picoseconds, we want to print in milli-seconds - picosecond is sec* 10^ -12 - millisecond is sec * 10^-3 - */ - double ms= double(end_sum - start_sum) / 1e9; - writer->add_member("r_total_time_ms").add_double(ms); - } -} - |