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: skip execution when build query for VIEW in I_S #58203

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Dec 12, 2024

What problem does this PR solve?

Issue Number: close #58184

Problem Summary:

What changed and how does it work?

use PlanBuilderOptNoExecution to skip unnecessary execution. This should be the same behaviour with SHOW COLUMNS

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

I tested the new PlanBuilderOptNoExecution based on release-6.5 with the reproduce steps in issue. Before this PR (which is v6.5.11)

mysql> select count(1) from INFORMATION_SCHEMA.columns;
+----------+
| count(1) |
+----------+
|     4635 |
+----------+
1 row in set (0.66 sec)

mysql> trace select count(1) from INFORMATION_SCHEMA.columns;
+-----------------------------------------------------------------------------+-----------------+-------------+
| operation                                                                   | startTS         | duration    |
+-----------------------------------------------------------------------------+-----------------+-------------+
| trace                                                                       | 15:19:40.955394 | 28.741875ms |
|   ├─session.ExecuteStmt                                                     | 15:19:40.955411 | 897.25µs    |
|   │ ├─executor.Compile                                                      | 15:19:40.955448 | 293.25µs    |
|   │ └─session.runStmt                                                       | 15:19:40.956066 | 196.333µs   |
|   ├─*executor.HashAggExec.Next                                              | 15:19:40.956323 | 27.783083ms |
|   │ ├─*executor.MemTableReaderExec.Next                                     | 15:19:40.956367 | 5.175042ms  |
|   │ ├─*executor.MemTableReaderExec.Next                                     | 15:19:40.961575 | 4.542083ms  |
|   │ ├─*executor.MemTableReaderExec.Next                                     | 15:19:40.966134 | 4.1615ms    |
|   │ ├─*executor.MemTableReaderExec.Next                                     | 15:19:40.970309 | 3.901959ms  |
|   │ ├─*executor.MemTableReaderExec.Next                                     | 15:19:40.974224 | 9.777625ms  |
|   │ │ ├─executor.EvalSubQuery                                               | 15:19:40.977166 | 832.333µs   |
|   │ │ │ ├─TableReaderExecutor.Open                                          | 15:19:40.977198 | 62.292µs    |
|   │ │ │ │ └─distsql.Select                                                  | 15:19:40.977220 | 26.75µs     |
|   │ │ │ │   └─regionRequest.SendReqCtx                                      | 15:19:40.977293 | 594.75µs    |
|   │ │ │ │     └─rpcClient.SendRequest, region ID: 90, type: Cop             | 15:19:40.977314 | 558.375µs   |
|   │ │ │ │       └─tikv.RPC                                                  | 15:19:40.977316 | 195.75µs    |
|   │ │ │ │         └─tikv.Wait                                               | 15:19:40.977316 | 41.708µs    |
|   │ │ │ │           └─tikv.GetSnapshot                                      | 15:19:40.977316 | 41.708µs    |
|   │ │ │ └─*executor.MaxOneRowExec.Next                                      | 15:19:40.977273 | 714.667µs   |
|   │ │ │   ├─*executor.StreamAggExec.Next                                    | 15:19:40.977275 | 703.458µs   |
|   │ │ │   │ ├─*executor.TopNExec.Next                                       | 15:19:40.977276 | 691.042µs   |
|   │ │ │   │ │ ├─*executor.TableReaderExecutor.Next                          | 15:19:40.977281 | 649.375µs   |
|   │ │ │   │ │ └─*executor.TableReaderExecutor.Next                          | 15:19:40.977943 | 16.5µs      |
|   │ │ │   │ └─*executor.TopNExec.Next                                       | 15:19:40.977973 | 542ns       |
|   │ │ │   └─*executor.StreamAggExec.Next                                    | 15:19:40.977983 | 542ns       |
|   │ │ ├─executor.EvalSubQuery                                               | 15:19:40.978578 | 494.875µs   |
|   │ │ │ ├─TableReaderExecutor.Open                                          | 15:19:40.978592 | 26.541µs    |
|   │ │ │ │ └─distsql.Select                                                  | 15:19:40.978601 | 10.916µs    |
|   │ │ │ │   └─regionRequest.SendReqCtx                                      | 15:19:40.978640 | 362.875µs   |
|   │ │ │ │     └─rpcClient.SendRequest, region ID: 90, type: Cop             | 15:19:40.978648 | 347.334µs   |
|   │ │ │ │       └─tikv.RPC                                                  | 15:19:40.978648 | 103.959µs   |
|   │ │ │ │         └─tikv.Wait                                               | 15:19:40.978648 | 20.291µs    |
|   │ │ │ │           └─tikv.GetSnapshot                                      | 15:19:40.978648 | 20.291µs    |
|   │ │ │ └─*executor.MaxOneRowExec.Next                                      | 15:19:40.978625 | 442.625µs   |
|   │ │ │   ├─*executor.StreamAggExec.Next                                    | 15:19:40.978626 | 431.334µs   |
|   │ │ │   │ ├─*executor.TopNExec.Next                                       | 15:19:40.978627 | 421.458µs   |
|   │ │ │   │ │ ├─*executor.TableReaderExecutor.Next                          | 15:19:40.978629 | 394.625µs   |
|   │ │ │   │ │ └─*executor.TableReaderExecutor.Next                          | 15:19:40.979033 | 9.958µs     |
|   │ │ │   │ └─*executor.TopNExec.Next                                       | 15:19:40.979053 | 417ns       |
|   │ │ │   └─*executor.StreamAggExec.Next                                    | 15:19:40.979062 | 334ns       |
|   │ │ ├─executor.EvalSubQuery                                               | 15:19:40.979615 | 519.291µs   |
|   │ │ │ ├─TableReaderExecutor.Open                                          | 15:19:40.979634 | 27.583µs    |
|   │ │ │ │ └─distsql.Select                                                  | 15:19:40.979645 | 11.459µs    |
|   │ │ │ │   └─regionRequest.SendReqCtx                                      | 15:19:40.979682 | 358.625µs   |
|   │ │ │ │     └─rpcClient.SendRequest, region ID: 90, type: Cop             | 15:19:40.979689 | 344.542µs   |
|   │ │ │ │       └─tikv.RPC                                                  | 15:19:40.979690 | 108.958µs   |
|   │ │ │ │         └─tikv.Wait                                               | 15:19:40.979690 | 19.458µs    |
|   │ │ │ │           └─tikv.GetSnapshot                                      | 15:19:40.979690 | 19.458µs    |
|   │ │ │ └─*executor.MaxOneRowExec.Next                                      | 15:19:40.979669 | 460.375µs   |
|   │ │ │   ├─*executor.StreamAggExec.Next                                    | 15:19:40.979670 | 451.083µs   |
|   │ │ │   │ ├─*executor.TopNExec.Next                                       | 15:19:40.979670 | 441.5µs     |
|   │ │ │   │ │ ├─*executor.TableReaderExecutor.Next                          | 15:19:40.979673 | 389.833µs   |
|   │ │ │   │ │ └─*executor.TableReaderExecutor.Next                          | 15:19:40.980092 | 12.75µs     |
|   │ │ │   │ └─*executor.TopNExec.Next                                       | 15:19:40.980117 | 417ns       |
|   │ │ │   └─*executor.StreamAggExec.Next                                    | 15:19:40.980125 | 333ns       |
|   │ │ ├─executor.EvalSubQuery                                               | 15:19:40.980505 | 1.343084ms  |
|   │ │ │ ├─TableReaderExecutor.Open                                          | 15:19:40.980519 | 34.292µs    |
|   │ │ │ │ └─distsql.Select                                                  | 15:19:40.980531 | 12.958µs    |
|   │ │ │ │   └─regionRequest.SendReqCtx                                      | 15:19:40.980573 | 339.75µs    |
|   │ │ │ │     └─rpcClient.SendRequest, region ID: 90, type: Cop             | 15:19:40.980582 | 321.542µs   |
|   │ │ │ │       └─tikv.RPC                                                  | 15:19:40.980582 | 88.792µs    |
|   │ │ │ │         └─tikv.Wait                                               | 15:19:40.980582 | 18.458µs    |
|   │ │ │ │           └─tikv.GetSnapshot                                      | 15:19:40.980582 | 18.458µs    |
|   │ │ │ └─*executor.MaxOneRowExec.Next                                      | 15:19:40.980560 | 1.281041ms  |
|   │ │ │   ├─*executor.StreamAggExec.Next                                    | 15:19:40.980561 | 1.272291ms  |
|   │ │ │   │ ├─*executor.TopNExec.Next                                       | 15:19:40.980562 | 1.259083ms  |
|   │ │ │   │ │ ├─*executor.TableReaderExecutor.Next                          | 15:19:40.980564 | 367.958µs   |
|   │ │ │   │ │ └─*executor.TableReaderExecutor.Next                          | 15:19:40.980940 | 8.542µs     |
|   │ │ │   │ └─*executor.TopNExec.Next                                       | 15:19:40.981829 | 833ns       |
|   │ │ │   └─*executor.StreamAggExec.Next                                    | 15:19:40.981838 | 333ns       |
|   │ │ ├─executor.EvalSubQuery                                               | 15:19:40.982310 | 398.042µs   |
|   │ │ │ ├─TableReaderExecutor.Open                                          | 15:19:40.982322 | 27.666µs    |
|   │ │ │ │ └─distsql.Select                                                  | 15:19:40.982331 | 13.875µs    |
|   │ │ │ │   └─regionRequest.SendReqCtx                                      | 15:19:40.982370 | 262.708µs   |
|   │ │ │ │     └─rpcClient.SendRequest, region ID: 90, type: Cop             | 15:19:40.982377 | 249.208µs   |
|   │ │ │ │       └─tikv.RPC                                                  | 15:19:40.982377 | 77.459µs    |
|   │ │ │ │         └─tikv.Wait                                               | 15:19:40.982377 | 17.458µs    |
|   │ │ │ │           └─tikv.GetSnapshot                                      | 15:19:40.982377 | 17.458µs    |
|   │ │ │ └─*executor.MaxOneRowExec.Next                                      | 15:19:40.982356 | 346µs       |
|   │ │ │   ├─*executor.StreamAggExec.Next                                    | 15:19:40.982357 | 325.5µs     |
|   │ │ │   │ ├─*executor.TopNExec.Next                                       | 15:19:40.982358 | 316.625µs   |
|   │ │ │   │ │ ├─*executor.TableReaderExecutor.Next                          | 15:19:40.982361 | 290.833µs   |
|   │ │ │   │ │ └─*executor.TableReaderExecutor.Next                          | 15:19:40.982659 | 9.917µs     |
|   │ │ │   │ └─*executor.TopNExec.Next                                       | 15:19:40.982679 | 416ns       |
|   │ │ │   └─*executor.StreamAggExec.Next                                    | 15:19:40.982698 | 417ns       |
|   │ │ └─executor.EvalSubQuery                                               | 15:19:40.983042 | 401.166µs   |
|   │ │   ├─TableReaderExecutor.Open                                          | 15:19:40.983054 | 27.25µs     |
|   │ │   │ └─distsql.Select                                                  | 15:19:40.983062 | 13µs        |
|   │ │   │   └─regionRequest.SendReqCtx                                      | 15:19:40.983101 | 277.667µs   |
|   │ │   │     └─rpcClient.SendRequest, region ID: 90, type: Cop             | 15:19:40.983107 | 265.083µs   |
|   │ │   │       └─tikv.RPC                                                  | 15:19:40.983108 | 94.5µs      |
|   │ │   │         └─tikv.Wait                                               | 15:19:40.983108 | 22.083µs    |
|   │ │   │           └─tikv.GetSnapshot                                      | 15:19:40.983108 | 22.083µs    |
|   │ │   └─*executor.MaxOneRowExec.Next                                      | 15:19:40.983088 | 349.375µs   |
|   │ │     ├─*executor.StreamAggExec.Next                                    | 15:19:40.983089 | 340.459µs   |
|   │ │     │ ├─*executor.TopNExec.Next                                       | 15:19:40.983090 | 329.916µs   |
|   │ │     │ │ ├─*executor.TableReaderExecutor.Next                          | 15:19:40.983092 | 305.541µs   |
|   │ │     │ │ └─*executor.TableReaderExecutor.Next                          | 15:19:40.983406 | 8.208µs     |
|   │ │     │ └─*executor.TopNExec.Next                                       | 15:19:40.983424 | 375ns       |
|   │ │     └─*executor.StreamAggExec.Next                                    | 15:19:40.983434 | 375ns       |
|   │ └─*executor.MemTableReaderExec.Next                                     | 15:19:40.984015 | 1.75µs      |
|   └─*executor.HashAggExec.Next                                              | 15:19:40.984115 | 750ns       |
+-----------------------------------------------------------------------------+-----------------+-------------+
102 rows in set (0.03 sec)

with this PR

mysql> select count(1) from INFORMATION_SCHEMA.columns;
+----------+
| count(1) |
+----------+
|     4635 |
+----------+
1 row in set (0.03 sec)

mysql> trace SELECT COUNT(1) FROM INFORMATION_SCHEMA.COLUMNS;
+-----------------------------------------------+-----------------+-------------+
| operation                                     | startTS         | duration    |
+-----------------------------------------------+-----------------+-------------+
| trace                                         | 15:17:33.199398 | 28.597792ms |
|   ├─session.ExecuteStmt                       | 15:17:33.199704 | 1.093833ms  |
|   │ ├─executor.Compile                        | 15:17:33.199750 | 317.875µs   |
|   │ └─session.runStmt                         | 15:17:33.200340 | 181.5µs     |
|   ├─*executor.HashAggExec.Next                | 15:17:33.200809 | 27.12125ms  |
|   │ ├─*executor.MemTableReaderExec.Next       | 15:17:33.200850 | 5.302125ms  |
|   │ ├─*executor.MemTableReaderExec.Next       | 15:17:33.206185 | 4.823458ms  |
|   │ ├─*executor.MemTableReaderExec.Next       | 15:17:33.211029 | 4.406417ms  |
|   │ ├─*executor.MemTableReaderExec.Next       | 15:17:33.215453 | 7.002666ms  |
|   │ ├─*executor.MemTableReaderExec.Next       | 15:17:33.222477 | 5.324958ms  |
|   │ └─*executor.MemTableReaderExec.Next       | 15:17:33.227816 | 1.667µs     |
|   └─*executor.HashAggExec.Next                | 15:17:33.227942 | 17.833µs    |
+-----------------------------------------------+-----------------+-------------+
12 rows in set (0.03 sec)

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 12, 2024
Copy link

tiprow bot commented Dec 12, 2024

Hi @lance6716. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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-sigs/prow repository.

@lance6716
Copy link
Contributor Author

/check-issue-triage-complete

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 12, 2024
Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

The planner part looks good to me.

Thanks! :shipit:

@lance6716 lance6716 changed the title I_S: skip execution when build query for VIEW exector: skip execution when build query for VIEW Dec 12, 2024
Copy link

ti-chi-bot bot commented Dec 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Rustin170506, tangenta

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lance6716 lance6716 changed the title exector: skip execution when build query for VIEW executor: skip execution when build query for VIEW Dec 12, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 12, 2024
Copy link

ti-chi-bot bot commented Dec 12, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-12 08:32:03.217972069 +0000 UTC m=+513713.306774613: ☑️ agreed by tangenta.
  • 2024-12-12 08:35:33.423623157 +0000 UTC m=+513923.512425699: ☑️ agreed by Rustin170506.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.6376%. Comparing base (4e6468d) to head (3a794bb).
Report is 57 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58203        +/-   ##
================================================
+ Coverage   73.2161%   73.6376%   +0.4215%     
================================================
  Files          1676       1676                
  Lines        462084     462125        +41     
================================================
+ Hits         338320     340298      +1978     
+ Misses       102995     101045      -1950     
- Partials      20769      20782        +13     
Flag Coverage Δ
integration 43.1785% <50.0000%> (?)
unit 72.3403% <100.0000%> (-0.0180%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.9908% <ø> (+0.0060%) ⬆️

@lance6716 lance6716 changed the title executor: skip execution when build query for VIEW executor: skip execution when build query for VIEW in I_S Dec 12, 2024
@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Dec 12, 2024

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit 3ccd7e6 into pingcap:master Dec 12, 2024
23 checks passed
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Dec 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #58230.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 13, 2024
lance6716 added a commit to lance6716/tidb that referenced this pull request Dec 13, 2024
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Dec 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #58232.

@ti-chi-bot ti-chi-bot bot added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. labels Dec 13, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #58233.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #58234.

@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Dec 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #58236.

Copy link

ti-chi-bot bot commented Dec 19, 2024

@lance6716: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 3a794bb link true /test unit-test

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INFORMATION_SCHEMA.columns performance regression after fix #54343
4 participants