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

executor: Add the HashAggExec runtime information (#20577) #21304

Closed

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #20577 to release-4.0


What problem does this PR solve?

Problem Summary:
Currently, the runtime stats of IndexMergeReaderExecutor is hard to understand, here is an example:

mysql> explain analyze SELECT /*+ HASH_AGG() */ count(*) FROM t1 WHERE a > 10;
+----------------------------+---------+---------+-----------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+--------------+------+
| id                         | estRows | actRows | task      | access object        | execution info                                                                                                                           | operator info                     | memory       | disk |
+----------------------------+---------+---------+-----------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+--------------+------+
| HashAgg_11                 | 1.00    | 1       | root      |                      | time:487.272µs, loops:2, test, PartialConcurrency:5, FinalConcurrency:5                                                                  | funcs:count(Column#5)->Column#4   | 3.6328125 KB | N/A  |
| └─IndexReader_12           | 1.00    | 1       | root      |                      | time:430.392µs, loops:2, cop_task: {num: 1, max:406.608µs, proc_keys: 0, rpc_num: 1, rpc_time: 378.445µs, copr_cache_hit_ratio: 1.00}    | index:HashAgg_6                   | 201 Bytes    | N/A  |
|   └─HashAgg_6              | 1.00    | 1       | cop[tikv] |                      | time:21ms, loops:10                                                                                                                      | funcs:count(1)->Column#5          | N/A          | N/A  |
|     └─IndexRangeScan_9     | 3333.33 | 9999    | cop[tikv] | table:t1, index:a(a) | time:21ms, loops:10                                                                                                                      | range:(10,+inf], keep order:false | N/A          | N/A  |
+----------------------------+---------+---------+-----------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+--------------+------+
4 rows in set (0.00 sec)

What is changed and how it works?

What's Changed:
Add runtime stats for HashAggExec, and add the String()、Merge()、Tp() for it.

Before this pr:

mysql> explain analyze SELECT /*+ HASH_AGG() */ count(*) FROM t1 WHERE a > 10;
+----------------------------+---------+---------+-----------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+--------------+------+
| id                         | estRows | actRows | task      | access object        | execution info                                                                                                                           | operator info                     | memory       | disk |
+----------------------------+---------+---------+-----------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+--------------+------+
| HashAgg_11                 | 1.00    | 1       | root      |                      | time:487.272µs, loops:2, test, PartialConcurrency:5, FinalConcurrency:5                                                                  | funcs:count(Column#5)->Column#4   | 3.6328125 KB | N/A  |
| └─IndexReader_12           | 1.00    | 1       | root      |                      | time:430.392µs, loops:2, cop_task: {num: 1, max:406.608µs, proc_keys: 0, rpc_num: 1, rpc_time: 378.445µs, copr_cache_hit_ratio: 1.00}    | index:HashAgg_6                   | 201 Bytes    | N/A  |
|   └─HashAgg_6              | 1.00    | 1       | cop[tikv] |                      | time:21ms, loops:10                                                                                                                      | funcs:count(1)->Column#5          | N/A          | N/A  |
|     └─IndexRangeScan_9     | 3333.33 | 9999    | cop[tikv] | table:t1, index:a(a) | time:21ms, loops:10                                                                                                                      | range:(10,+inf], keep order:false | N/A          | N/A  |
+----------------------------+---------+---------+-----------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+--------------+------+
4 rows in set (0.00 sec)

After this pr

mysql> explain analyze SELECT /*+ HASH_AGG() */ sum(a) FROM t1 WHERE a > 10;
+----------------------------+----------+---------+-----------+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------+------+
| id                         | estRows  | actRows | task      | access object          | execution info                                                                                                                                                                                                                                                                                           | operator info                     | memory        | disk |
+----------------------------+----------+---------+-----------+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------+------+
| HashAgg_10                 | 1.00     | 1       | root      |                        | time:136.117588ms, loops:2, partial_worker:{wall_time:136.057357ms, concurrency:5, task_num:1, tot_wait:135.984667ms, tot_exec:6.27µs, tot_time:680.053624ms, max:136.026503ms, p95:136.026503ms}, final_worker:{wall_time:136.103916ms, concurrency:5, task_num:1, max:136.093494ms, p95:136.093494ms}  | funcs:sum(Column#7)->Column#6     | 13.9453125 KB | N/A  |
| └─IndexReader_11           | 1.00     | 1       | root      |                        | time:135.986737ms, loops:2, cop_task: {num: 1, max:135.92485ms, proc_keys: 0, rpc_num: 1, rpc_time: 135.846842ms, copr_cache_hit_ratio: 0.00}                                                                                                                                                            | index:HashAgg_6                   | 183 Bytes     | N/A  |
|   └─HashAgg_6              | 1.00     | 1       | cop[tikv] |                        | time:0ns, loops:0, tikv_task:{time:67.263469ms, loops:99981}                                                                                                                                                                                                                                             | funcs:sum(test.t1.a)->Column#7    | N/A           | N/A  |
|     └─IndexRangeScan_9     | 99987.80 | 99981   | cop[tikv] | table:t1, index:t1a(a) | time:0ns, loops:0, tikv_task:{time:24.81135ms, loops:99981}                                                                                                                                                                                                                                              | range:(10,+inf], keep order:false | N/A           | N/A  |
+----------------------------+----------+---------+-----------+------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------+---------------+------+
4 rows in set (0.14 sec)

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM

Release note

  • executor: Add the HashAggExec runtime information

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@jyz0309 you're already a collaborator in bot's repo.

@ti-srebot
Copy link
Contributor Author

@qw4990, @XuHuaiyu, @crazycs520, PTAL.

1 similar comment
@ti-srebot
Copy link
Contributor Author

@qw4990, @XuHuaiyu, @crazycs520, PTAL.

@zz-jason zz-jason modified the milestones: v4.0.9, v4.0.10 Nov 30, 2020
@ti-srebot
Copy link
Contributor Author

@qw4990, @XuHuaiyu, @crazycs520, PTAL.

@jebter jebter modified the milestones: v4.0.10, v4.0.11 Jan 18, 2021
@ti-chi-bot
Copy link
Member

@ti-srebot: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2021
@ti-srebot
Copy link
Contributor Author

@qw4990, @XuHuaiyu, @crazycs520, PTAL.

2 similar comments
@ti-srebot
Copy link
Contributor Author

@qw4990, @XuHuaiyu, @crazycs520, PTAL.

@ti-srebot
Copy link
Contributor Author

@qw4990, @XuHuaiyu, @crazycs520, PTAL.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented May 7, 2021

New feature, we do not need to cherrypick it to release-4.0

@XuHuaiyu XuHuaiyu closed this May 7, 2021
@zhouqiang-cl zhouqiang-cl modified the milestones: v4.0.11, v4.0.13 May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/execution SIG execution type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants