Skip to content
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

Merged
merged 4 commits into from
Mar 21, 2021

Conversation

morningman
Copy link
Contributor

@morningman morningman commented Mar 6, 2021

Proposed changes

Add command:

  1. EXPLAIN GRAPGH SELECT ...
  2. SHOW QUERY PROFILE "..."

Document will be added in next PR.
Details can be seem in #5474

Types of changes

  • New feature (non-breaking change which adds functionality)

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 construction
and tree printer.

@EmmyMiao87
Copy link
Contributor

Can't his tool directly reference jar? Do we have to buckle the code into our own code base?

@morningman
Copy link
Contributor Author

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.

morningman-cmy and others added 3 commits March 11, 2021 23:00
Add command:
1. EXPLAIN GRAPGH SELECT ...
2. SHOW QUERY PROFILE "..."

Document will be added in next PR

Change-Id: Ifd9365e10b1f9ff4fdf8ae0556343783d97545f0
@morningman
Copy link
Contributor Author

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.

@EmmyMiao87 Done

@EmmyMiao87 EmmyMiao87 linked an issue Mar 15, 2021 that may be closed by this pull request
RESULT = query;
:}
| describe_command insert_stmt:stmt
{:
stmt.getQueryStmt().setIsExplain(true);
stmt.getQueryStmt().setIsExplain(new ExplainOptions(true, false));
RESULT = stmt;
:}
;
Copy link
Contributor

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

Copy link
Contributor Author

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update comment.

Copy link
Contributor Author

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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]");
Copy link
Contributor

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

Copy link
Contributor Author

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";
Copy link
Contributor

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.

Copy link
Contributor Author

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@EmmyMiao87 EmmyMiao87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EmmyMiao87 EmmyMiao87 added the area/profile Issues or PRs related to the profile label Mar 19, 2021
@morningman morningman merged commit b9d92e0 into apache:master Mar 21, 2021
EmmyMiao87 pushed a commit to EmmyMiao87/incubator-doris that referenced this pull request Apr 21, 2021
Add command:
1. EXPLAIN GRAPGH SELECT ...
2. SHOW QUERY PROFILE "..."

Document will be added in next PR

Change-Id: Ifd9365e10b1f9ff4fdf8ae0556343783d97545f0
@morningman morningman mentioned this pull request Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/profile Issues or PRs related to the profile kind/improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Visualize the query plan and query profile
4 participants