[MDEV-27021] Extend SHOW EXPLAIN to support SHOW ANALYZE [FORMAT=JSON] Created: 2021-11-11 Updated: 2024-01-22 Resolved: 2022-04-29 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | 10.9.1 |
| Type: | Task | Priority: | Major |
| Reporter: | Sergei Petrunia | Assignee: | Alice Sherepa |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Preview_10.9 | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
SHOW EXPLAIN allows one to view EXPLAIN of a currently executing query. However, it doesn't handle this use case: A really huge query runs for a long time and never finishes. Since it never finishes, one cannot view ANALYZE output. Adding "LIMIT N" to the top query is of limited help. Suggested solution: extend SHOW EXPLAIN to report SHOW ANALYZE FORMAT=JSON data of the query that's currently running. |
| Comments |
| Comment by Sergei Petrunia [ 2022-01-28 ] | ||||||||
|
Review input: https://lists.launchpad.net/maria-developers/msg13078.html . The tabular form is basically done, need to do the FORMAT=JSON part. | ||||||||
| Comment by Sergei Petrunia [ 2022-02-08 ] | ||||||||
|
Trying the FORMAT=JSON on a test query: https://gist.github.com/spetrunia/69fb0c48b3b5412a546575f02d3b3de7 Ok this gives some clue about query execution. Things that I would like to see but do not see
| ||||||||
| Comment by Sergei Petrunia [ 2022-02-08 ] | ||||||||
|
A select is in its first execution looks like so:
compare to select that has never been executed:
... | ||||||||
| Comment by Oleg Smirnov [ 2022-02-09 ] | ||||||||
|
1. How would you like to see the clear indication?
2. How to name this field and where to place it? Is it OK to place it in the top of the output like this: | ||||||||
| Comment by Sergei Petrunia [ 2022-02-11 ] | ||||||||
|
oleg.smirnov, good questions.. I'm still trying to figure out answer for these... | ||||||||
| Comment by Sergei Petrunia [ 2022-02-11 ] | ||||||||
|
Looking at a query that does filesort first, and then join with the second table: (diff'ing first SHOW ANALYZE output against the second) | ||||||||
| Comment by Sergei Petrunia [ 2022-02-11 ] | ||||||||
|
Here's an example : https://gist.github.com/spetrunia/664a80db9110b02e0a91642e8aa987df
I'm not sure if we should call this incorrect, but looking at it as a user, it doesn't look very intuitive... | ||||||||
| Comment by Sergei Petrunia [ 2022-02-14 ] | ||||||||
|
Indeed, r_total_time_ms shows up due to this logic in Explain_select::print_explain_json:
The code assumes that is_analyze=true means that there is timing information. The first idea off the top of the head: check if time_tracker.cycles==0 (wrap this into a call like time_tracker.have_timings()) and don't print r_*time_ms in this case. | ||||||||
| Comment by Sergei Petrunia [ 2022-02-14 ] | ||||||||
As agreed on Slack: Let it be r_time_in_progress_ms at the top level. For non-ANALYZE execution, there's a question of where to get the query start time. Please check where INFORMATION_SCHEMA.PROCESSLIST gets it from. | ||||||||
| Comment by Oleg Smirnov [ 2022-02-16 ] | ||||||||
|
Pushed a new commit addressing the issues discussed. {{commit a335245bbf9c49327d8b34ac30e3ad49822a5aa3 (HEAD 1. Add explicit indication that the output is produced by psergei, please review. | ||||||||
| Comment by Oleg Smirnov [ 2022-02-16 ] | ||||||||
|
By the way, I haven't fixed test cases yet, so some tests will fail. Once we're happy with the results I'll fix the test cases accordingly. | ||||||||
| Comment by Sergei Petrunia [ 2022-03-01 ] | ||||||||
|
The last patch is ok. I've requested small fix in comments. After that, we can pass it to testing. | ||||||||
| Comment by Nuno [ 2022-04-16 ] | ||||||||
|
Hey Here's a related post: "extend explain output to include "attached_condition"" Thanks! |