[MDEV-6109] EXPLAIN JSON Created: 2014-04-15 Updated: 2014-12-04 Resolved: 2014-12-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | 10.1.2 |
| Type: | Task | Priority: | Critical |
| Reporter: | Sergei Golubchik | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | optimizer | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Sergei Petrunia [ 2014-05-15 ] | |||||||||||||||
|
MySQL Workbench parses output of EXPLAIN FORMAT=JSON, see plugins/wb.query.analysis/explain_renderer.py. The code there makes some assumptions about the form of JSON structures. It is not immediately apparent what exactly the assumptions are. | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-05-21 ] | |||||||||||||||
|
MySQL Workbench 6.1.4 choked on every EXPLAIN FORMAT=JSON output for query with subqueries that I've tried (using the latest 5.6). Last Friday, they have released Workbench 6.1.6 which is able to process subqueries. However, it still makes some strong assumptions about the the data format. | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-05-21 ] | |||||||||||||||
|
Tasks 1. Figure out the expected JSON form (decide whether we try to follow it or not) | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-05-23 ] | |||||||||||||||
|
It looks like in MySQL 5.6, EXPLAIN FORMAT=JSON relies on optimizer_trace. The JSON is produced here: (gdb) wher Check the function arguments: bool table_base_ctx::format_body(Opt_trace_context *json, Opt_trace_object *obj) | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-05-27 ] | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-08-12 ] | |||||||||||||||
|
Debugging a query...the following happens: 1. Query plan is created #2 happens before #3 and #4. This means, we can save everything in EXPLAIN data structures. However, #5 happens after #3 and #4, which means some details about the query plans are not accessible when printing EXPLAIN into slow query log. | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-08-12 ] | |||||||||||||||
|
Possible solutions: | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-08-12 ] | |||||||||||||||
|
Looking at MySQL:
Tabular EXPLAIN shows: EXPLAIN FORMAT=JSON shows: So, "key" in tabular and json output are not the same. | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-08-12 ] | |||||||||||||||
|
Another interesting column is JSON's used_key_parts. It seems to be present only when a single index is used. | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-08-14 ] | |||||||||||||||
|
Came up with some reasonable JSON output for access to single table.
Looking at MySQL:
== Subqueries ==
== ORDER/GROUP BY ==
it's possible to get it with using_filesort=false, which means we're scanning an index that produces the desired ordering. ordering_operation always embeds the nested_loop node. | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-11-28 ] | |||||||||||||||
|
How MySQL-5.6 displays semi-join subquery plans: FirstMatch:
Duplicate Elimination:
SJ-Materialization looks barely distinguishable from derived table:
LooseScan The table being scanned has:
| |||||||||||||||
| Comment by roberto spadim [ 2014-12-01 ] | |||||||||||||||
|
hi guys, i started reading this mdev (thank you implementing this feature with mariadb!), i don't know if it's possible, but optimizer explain why it choise one index instead of another? check | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-12-02 ] | |||||||||||||||
|
I think this should be resolved outside of this MDEV. Within the scope of this MDEV, we limit ourselves to printing basically EXPLAIN or ANALYZE-stmt output in JSON form, with more details. Will reply on | |||||||||||||||
| Comment by roberto spadim [ 2014-12-02 ] | |||||||||||||||
|
ok no problem | |||||||||||||||
| Comment by Sergei Petrunia [ 2014-12-02 ] | |||||||||||||||
|
Pushed into 10.1 tree |