-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Profile] Visualize the query plan and query profile #5475
Conversation
f198ad7
to
0e7cbd2
Compare
Can't his tool directly reference jar? Do we have to buckle the code into our own code base? |
OK, I will wait it to make to new release. |
Add command: 1. EXPLAIN GRAPGH SELECT ... 2. SHOW QUERY PROFILE "..." Document will be added in next PR Change-Id: Ifd9365e10b1f9ff4fdf8ae0556343783d97545f0
c704929
to
9b54958
Compare
@EmmyMiao87 Done |
RESULT = query; | ||
:} | ||
| describe_command insert_stmt:stmt | ||
{: | ||
stmt.getQueryStmt().setIsExplain(true); | ||
stmt.getQueryStmt().setIsExplain(new ExplainOptions(true, false)); | ||
RESULT = stmt; | ||
:} | ||
; |
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.
Change KW_DESCRIBE
to KW_EXPLAIN
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.
KW_DESCRIBE means both "desc" and "explain",
see fe/fe-core/src/main/jflex/sql_scanner.flex
@@ -36,9 +36,7 @@ | |||
private String clusterName; | |||
|
|||
// True if this QueryStmt is the top level query from an EXPLAIN <query> |
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 update comment.
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.
ok
} | ||
|
||
private void buildForPlanNode(PlanNode planNode, PlanTreeNode parent) { | ||
StringBuilder sb = new StringBuilder(); |
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.
Why not print the plan node directly?
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.
ok
PlanTreeNode sinkNode = null; | ||
if (sink != null) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("[").append(sink.getExchNodeId().asInt()).append(": DATA SINK]"); |
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.
DATA SINK or Result Sink
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.
Change to sink's class name
|
||
public class PlanTreeBuilder { | ||
|
||
private static final String EXCHANGE_NODE = "EXCHANGE"; |
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.
Use final params in Exchange Node.
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.
Move this to ExchangeNode
public class PlanTreeBuilder { | ||
|
||
private static final String EXCHANGE_NODE = "EXCHANGE"; | ||
private static final String MERGING_EXCHANGE_NODE = "MERGING-EXCHANGE"; |
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.
Same as above
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.
Done
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
Add command: 1. EXPLAIN GRAPGH SELECT ... 2. SHOW QUERY PROFILE "..." Document will be added in next PR Change-Id: Ifd9365e10b1f9ff4fdf8ae0556343783d97545f0
Proposed changes
Add command:
Document will be added in next PR.
Details can be seem in #5474
Types of changes
Other
I introduced a tree printer class from https://github.com/davidsusu/tree-printer
This is a greet tree printer, but it release version has a NPE bug.
So I can't just add maven dependency of it, but has to add all its source codes in
our repo and fix the bug.
I will also send a PR to
davidsusu/tree-printer
, and once it merged and release a new version.I will remove the source code of the tree printer in Doris and use its maven dependency.
Update:
Using tree-printer 1.2 instead of source code
For Reviewer:
The file in package:
fe/fe-common/src/main/java/org/apache/doris/common/treeprinter/
are from
davidsusu/tree-printer
, no need to review.Add a new statement:
SHOW QUERY PROFILE "/"
;Files under
fe/fe-core/src/main/java/org/apache/doris/common/profile/
are for tree constructionand tree printer.