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

expression: add header for tidb_decode_plan result #18440

Merged
merged 9 commits into from
Jul 13, 2020

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Jul 8, 2020

What problem does this PR solve?

After #17573, TiDB will record runtime information in slow-log plan field. the tidb_decode_plan maybe output 8 fields when plan with runtime information. It's hard to know the filed means without a header/column_name.

This PR add header for tidb_decode_plan result, such as below:

> select tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5NjQ4bRWEODc2CTEuOTA5NjAzMTE4OAEdDDQ0IE0JWxgyCTExXzEyAeHwWzAwMDAJdGFibGU6U0xPV19RVUVSWSwgb25seSBzZWFyY2ggaW4gdGhlIGN1cnJlbnQgJ3RpZGItc2xvdy5sb2cnIGZpbGUJNzY0NjkJdGltZTo2NTEuODk5NDAzHY4kNwlOL0EJTi9BCg==');
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5Nj |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     id                     task    estRows    operator info                                                        actRows    execution info                                                         memory                   disk                               |
|     HashAgg_8              root    1          funcs:count(1)->Column#50                                            1          time:766.09976ms, loops:2, PartialConcurrency:4, FinalConcurrency:4    10.740005493164062 MB    N/A                                |
|     └─Selection_11         root    8000       eq(Column#31, 0)                                                     76140      time:765.359648ms, loops:76                                            1.9096031188964844 MB    N/A                                |
|       └─MemTableScan_12    root    10000      table:SLOW_QUERY, only search in the current 'tidb-slow.log' file    76469      time:651.899403ms, loops:77                                            N/A                      N/A                                |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Before this PR, the result will be:

> select tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5NjQ4bRWEODc2CTEuOTA5NjAzMTE4OAEdDDQ0IE0JWxgyCTExXzEyAeHwWzAwMDAJdGFibGU6U0xPV19RVUVSWSwgb25seSBzZWFyY2ggaW4gdGhlIGN1cnJlbnQgJ3RpZGItc2xvdy5sb2cnIGZpbGUJNzY0NjkJdGltZTo2NTEuODk5NDAzHY4kNwlOL0EJTi9BCg==');
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5Nj |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|     HashAgg_8              root    1        funcs:count(1)->Column#50                                            1        time:766.09976ms, loops:2, PartialConcurrency:4, FinalConcurrency:4    10.740005493164062 MB    N/A                                    |
|     └─Selection_11         root    8000     eq(Column#31, 0)                                                     76140    time:765.359648ms, loops:76                                            1.9096031188964844 MB    N/A                                    |
|       └─MemTableScan_12    root    10000    table:SLOW_QUERY, only search in the current 'tidb-slow.log' file    76469    time:651.899403ms, loops:77                                            N/A                      N/A                                    |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

What is changed and how it works?

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

  • Breaking backward compatibility

Release note

  • Add a header for tidb_decode_plan result.

Signed-off-by: crazycs520 <crazycs520@gmail.com>
Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520 crazycs520 requested review from a team as code owners July 8, 2020 08:18
@crazycs520 crazycs520 requested review from SunRunAway and removed request for a team July 8, 2020 08:18
@crazycs520
Copy link
Contributor Author

/rebuild

@codecov
Copy link

codecov bot commented Jul 8, 2020

Codecov Report

Merging #18440 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #18440   +/-   ##
===========================================
  Coverage   79.4834%   79.4834%           
===========================================
  Files           540        540           
  Lines        144961     144961           
===========================================
  Hits         115220     115220           
  Misses        20464      20464           
  Partials       9277       9277           

@github-actions github-actions bot added sig/sql-infra SIG: SQL Infra sig/planner SIG: Planner labels Jul 8, 2020
util/plancodec/codec.go Outdated Show resolved Hide resolved
Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 13, 2020
@ti-srebot
Copy link
Contributor

@tangenta,Thanks for your review.

Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Jul 13, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 13, 2020
@ti-srebot
Copy link
Contributor

@djshow832,Thanks for your review.

@crazycs520 crazycs520 merged commit 009c112 into pingcap:master Jul 13, 2020
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #18501

jackysp pushed a commit that referenced this pull request Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression sig/planner SIG: Planner sig/sql-infra SIG: SQL Infra status/LGT2 Indicates that a PR has LGTM 2. type/usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants