-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
planner: add EXPLAIN FORMAT=JSON #20482
Conversation
@breeswish @zz-jason may I ask your opinion on these two questions in the description? |
Agree. Golang JSON encoder is escaped for HTML purpose and we don't need it.
We should change it (in future PRs). It is also the foundation of enabling more data to be visualized in TiDB Dashboard, for example, an interactive and nice plan view from slow query and statement page. My own preference is to use Protobuf, whose structure is JSON serializable and also allow TiDB Dashboard to parse binary directly. @crazycs520 PTAL, we have talked about this previously. |
Agree.
@qw4990 do you have any idea? |
I agree with it. Actually, I also meet this problem in another project where I want to parse and compare plans. |
This is now ready to review. The tests are just failing waiting on the parser PR to merge. |
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tk.MustExec("CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, t1_id INT)") | ||
|
||
var js core.JSONOperatorRow | ||
result := tk.MustQuery("EXPLAIN FORMAT=JSON SELECT t1.* FROM t1 INNER JOIN t2 ON t1.id=t2.t1_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more cases to cover more operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qw4990 I was worried about test stability as statistics and operator auto-naming can change. What I arrived at, was to use a regular expression. PTAL again, thx :-)
… explain-format-json
2 similar comments
We can revisit this when #20520 is complete. |
What problem does this PR solve?
Issue Number: Fixes #20378
What is changed and how it works?
What's Changed:
This implements
EXPLAIN FORMAT=JSON
.Because the
operatorInfo
is built by concatenating strings at a much lower level (planner/core/explain.go:37 - dataAccessor interface), it is just returned as a string (not ideal). I have forked #20520 to convert the delimiter to a;
.Here is an example:
Related changes
Check List
Tests
Side effects
Release note