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

explain analyze support DML statement #18056

Closed
6 of 7 tasks
crazycs520 opened this issue Jun 16, 2020 · 8 comments · Fixed by #19106
Closed
6 of 7 tasks

explain analyze support DML statement #18056

crazycs520 opened this issue Jun 16, 2020 · 8 comments · Fixed by #19106
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/enhancement The issue or PR belongs to an enhancement. type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@crazycs520
Copy link
Contributor

crazycs520 commented Jun 16, 2020

Background

After #17573, TiDB maybe records the executor runtime information in slow log.

But currently, the executor runtime information doesn't contain the insert/update/delete executor runtime information.

Feature Request

explain analyze also need the executor runtime information to display. Currently, explain analyze DML(insert/delete/update) will return not return the runtime information, here is an example:

mysql>explain analyze insert into t values (1,1),(2,2),(3,3),(4,4);
Query OK, 4 rows affected
Time: 0.010s
mysql>explain analyze update t set a=a+10 where a>0;
Query OK, 24 rows affected
Time: 0.014s
mysql>explain analyze delete from t where a<24;
Query OK, 4 rows affected
Time: 0.010s

Describe the feature you'd like:

Add runtime information for DML in explain analyze too. Such as:

Here is an example:

test> explain analyze insert into t values (1,1),(2,2),(3,3),(4,4);
+-------------------+---------+---------+-----------+---------------+--------------------------------------------------------------------+--------------------------------+-----------+------+
| id                | estRows | actRows | task      | access object | execution info                                                     | operator info                  | memory    | disk |
+-------------------+---------+---------+-----------+---------------+--------------------------------------------------------------------+--------------------------------+-----------+------+
| InsertExec _5     | 4.00    | 2       | root      | table:t       | time:535.68µs, loops:2, rpc num: 1, rpc time:498.42µs              |                                | 213 Bytes | N/A  |
+-------------------+---------+---------+-----------+---------------+--------------------------------------------------------------------+--------------------------------+-----------+------+

And then, we can record the insert/update/delete executor runtime information in slow-log.

There is some information we can add for DML and PointGet in explain analyze results (or slow logs):
For PointGet or BatchGet:

For DML:

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

@crazycs520 crazycs520 added type/enhancement The issue or PR belongs to an enhancement. type/feature-request Categorizes issue or PR as related to a new feature. labels Jun 16, 2020
@crazycs520 crazycs520 added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jul 15, 2020
@zz-jason
Copy link
Member

Could you describe more on the use scenarios and the motivation of this feature request?

@zz-jason
Copy link
Member

Typically, explain analyze is used for postmortem analysis. For example, we found a statement executed too slow, wish to investigate where the time spent on.

I'm afraid it's not suitable for UPDATE statements because it changes the data state. This means the slow UPDATE query can not be reproduced repeatedly. The second EXPLAIN ANALYZE UPDATE may not able to update anything in some scenarios.

@crazycs520
Copy link
Contributor Author

@zz-jason Sorry, Already add a background description.

My original intention is want to record insert/update/delete executor runtime information in the Plan field of slow-log.

Since explain analyze also need the runtime information, so maybe explain analyze can also display the insert/update/delete executor runtime information.

@zz-jason
Copy link
Member

record insert/update/delete executor runtime information in the Plan field of slow-log.

Gotcha, that makes sense to me.@SunRunAway @qw4990 What's your opinion?

@SunRunAway
Copy link
Contributor

Make sense to me.

@SunRunAway SunRunAway added the sig/planner SIG: Planner label Jul 20, 2020
@SunRunAway SunRunAway removed the sig/planner SIG: Planner label Jul 20, 2020
@SunRunAway SunRunAway added the sig/execution SIG execution label Jul 20, 2020
@qw4990
Copy link
Contributor

qw4990 commented Jul 21, 2020

Make sense to me, but I think we should add extra fields in slow logs for some important behaviors(for example, time cost on commit and pre-commit), since some third-party tools like pt-query may rely on them and it's more friendly to users.

@qw4990 qw4990 changed the title Add runtime information for DML in explain analyze Add runtime information for DML and PointGet in explain analyze and slow logs Jul 21, 2020
@jianyilyu
Copy link
Contributor

/assign

@SunRunAway
Copy link
Contributor

Added documentation for alerting users it has no explain result for DML now, pingcap/docs-cn#4059
Please update this after this issue is resolved.

@zz-jason zz-jason added the feature/accepted This feature request is accepted by product managers label Jul 29, 2020
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 10, 2020
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Aug 10, 2020
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 10, 2020
… DML in explain analyze pingcap#18056

Signed-off-by: jianyilyu <jianyilyu@126.com>
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 11, 2020
Signed-off-by: jianyilyu <jianyilyu@126.com>
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 11, 2020
Signed-off-by: jianyilyu <jianyilyu@126.com>
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 12, 2020
Signed-off-by: jianyilyu <jianyilyu@126.com>
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Aug 12, 2020
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 12, 2020
Signed-off-by: jianyilyu <jianyilyu@126.com>
jianyilyu added a commit to jianyilyu/tidb that referenced this issue Aug 12, 2020
Signed-off-by: jianyilyu <jianyilyu@126.com>
qw4990 added a commit to jianyilyu/tidb that referenced this issue Aug 19, 2020
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Sep 21, 2020
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Sep 22, 2020
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Sep 25, 2020
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Sep 27, 2020
crazycs520 added a commit to jianyilyu/tidb that referenced this issue Oct 10, 2020
@crazycs520 crazycs520 changed the title Add runtime information for DML and PointGet in explain analyze and slow logs explain analyze support DML statement Jan 11, 2021
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/enhancement The issue or PR belongs to an enhancement. 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.

5 participants