ANALYZE FORMAT=JSON shows r_total_time_ms. This is the time spent executing the query. It doesn't include the time spent doing query optimization.
Here's an example: The query execution takes 30 seconds, and I've stopped it in the optimizer for 50 seconds:
Note the client show the query took 1 min 20 sec, while query_block.r_total_time_ms=20 sec.
In some cases, query optimization itself can take a while, so we should report that time as well.
Starting from 10.9, there is SHOW ANALYZE FORMAT=JSON. It has r_query_time_in_progress_ms which counts the query execution time from the start of the query.
- Let's define "query optimization time" as the time spent between the calls to Explain_query::Explain_query() and Explain_query::query_plan_ready().
- Time can be tracked by using an Exec_time_tracker object. Make it a member of Explain_query.
- Do not track the time if the statement is not an ANALYZE statement (like it's done in other counters).
- JSON to be emitted: