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) #58234

Open
wants to merge 1 commit into
base: release-6.5
Choose a base branch
from

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #58203

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 added 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. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Dec 13, 2024
Copy link

ti-chi-bot bot commented Dec 13, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign 3aceshowhand for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed do-not-merge/cherry-pick-not-approved size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 13, 2024
Copy link

ti-chi-bot bot commented Dec 13, 2024

@ti-chi-bot: The following tests 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/check_dev b87059b link true /test check-dev
idc-jenkins-ci-tidb/unit-test b87059b link true /test unit-test
idc-jenkins-ci-tidb/build b87059b link true /test build
idc-jenkins-ci-tidb/check_dev_2 b87059b link true /test check-dev2
idc-jenkins-ci-tidb/mysql-test b87059b link true /test mysql-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/test-infra 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
cherry-pick-approved Cherry pick PR approved by release team. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants