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

Add executor runtime info for explain for connection statement #18233

Closed
crazycs520 opened this issue Jun 28, 2020 · 3 comments · Fixed by #19183
Closed

Add executor runtime info for explain for connection statement #18233

crazycs520 opened this issue Jun 28, 2020 · 3 comments · Fixed by #19183
Assignees
Labels
feature/accepted This feature request is accepted by product managers help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/execution SIG execution type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@crazycs520
Copy link
Contributor

crazycs520 commented Jun 28, 2020

This is a subtask of #17692

background

Currently, you can use explain for connection statement to check the plan information of the running sql, such as below:

 explain for connection 168;
+---------------------------+------------+-----------+------------------------+---------------------------------------------------------+
| id                        | estRows    | task      | access object          | operator info                                           |
+---------------------------+------------+-----------+------------------------+---------------------------------------------------------+
| HashAgg_11                | 1.00       | root      |                        | funcs:count(1)->Column#7                                |
| └─HashJoin_14             | 9659664.00 | root      |                        | CARTESIAN inner join, other cond:ne(test.t.b, test.t.b) |
|   ├─IndexReader_19(Build) | 3108.00    | root      |                        | index:IndexFullScan_18                                  |
|   │ └─IndexFullScan_18    | 3108.00    | cop[tikv] | table:t2, index:idx(b) | keep order:false                                        |
|   └─IndexReader_17(Probe) | 3108.00    | root      |                        | index:IndexFullScan_16                                  |
|     └─IndexFullScan_16    | 3108.00    | cop[tikv] | table:t1, index:idx(b) | keep order:false                                        |
+---------------------------+------------+-----------+------------------------+---------------------------------------------------------+

Feature Request

Add executor runtime info for explain for connection statement, such as below:

+---------------------------+------------+---------+-----------+------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------+------------------+---------+
| id                        | estRows    | actRows | task      | access object          | execution info                                                                  | operator info                                           | memory           | disk    |
+---------------------------+------------+---------+-----------+------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------+------------------+---------+
| HashAgg_11                | 1.00       | 1       | root      |                        | time:2.75491619s, loops:2, PartialConcurrency:4, FinalConcurrency:4             | funcs:count(1)->Column#7                                | 0 Bytes          | N/A     |
| └─HashJoin_14             | 9659664.00 | 9656556 | root      |                        | time:2.39850105s, loops:9432, Concurrency:5, probe collision:0, build:434.295µs | CARTESIAN inner join, other cond:ne(test.t.b, test.t.b) | 32.9375 KB       | 0 Bytes |
|   ├─IndexReader_19(Build) | 3108.00    | 3108    | root      |                        | time:690.901112ms, loops:5, rpc num: 1, rpc time:1.134724315s, proc keys:6190   | index:IndexFullScan_18                                  | 24.5615234375 KB | N/A     |
|   │ └─IndexFullScan_18    | 3108.00    | 3108    | cop[tikv] | table:t2, index:idx(b) | time:117ms, loops:8                                                             | keep order:false                                        | N/A              | N/A     |
|   └─IndexReader_17(Probe) | 3108.00    | 3108    | root      |                        | time:732.663444ms, loops:5, rpc num: 1, rpc time:1.134706548s, proc keys:6190   | index:IndexFullScan_16                                  | 24.5634765625 KB | N/A     |
|     └─IndexFullScan_16    | 3108.00    | 3108    | cop[tikv] | table:t1, index:idx(b) | time:117ms, loops:8                                                             | keep order:false                                        | N/A              | N/A     |
+---------------------------+------------+---------+-----------+------------------------+---------------------------------------------------------------------------------+---------------------------------------------------------+------------------+---------+

Actually the upper result it the result of explain analyze xxx.

Currently, TiDB doesn't collect the executor runtime information by default, but you can enable it by set the variable:

set tidb_enable_collect_execution_info=1;

Then TiDB will record the executor runtime information in the StatementContext.RuntimeStatsColl of the session. So you can add this runtime information in explain for connection statement.

Describe alternatives you've considered:

We can refer to the implementation of ExplainExec.generateExplainInfo, to avoid duplicate code.

Teachability, Documentation, Adoption, Migration Strategy:

@crazycs520 crazycs520 added the type/feature-request Categorizes issue or PR as related to a new feature. label Jun 28, 2020
@crazycs520 crazycs520 added sig/execution SIG execution help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jun 28, 2020
@scsldb scsldb added the feature/reviewing This feature request is reviewing by product managers label Jul 16, 2020
@zz-jason
Copy link
Member

@crazycs520 Could you describe more about the use case of this feature?

@zz-jason
Copy link
Member

Could we enable runtime statistics by default?

@zz-jason zz-jason removed their assignment Jul 23, 2020
@zz-jason zz-jason removed the feature/reviewing This feature request is reviewing by product managers label Jul 23, 2020
@hesper-guo
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/accepted This feature request is accepted by product managers help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/execution SIG execution type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants