Skip to content

executor: skip execution when build query for VIEW in I_S (#58203)#58233

Open
ti-chi-bot wants to merge 4 commits intopingcap:release-7.1from
ti-chi-bot:cherry-pick-58203-to-release-7.1
Open

executor: skip execution when build query for VIEW in I_S (#58203)#58233
ti-chi-bot wants to merge 4 commits intopingcap:release-7.1from
ti-chi-bot:cherry-pick-58203-to-release-7.1

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

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@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-7.1 This PR is cherry-picked to release-7.1 from a source PR. labels Dec 13, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved 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
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved and removed cherry-pick-approved Cherry pick PR approved by release team. labels Mar 4, 2025
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 4, 2025
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 4, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 4, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-03-04 08:09:16.261294757 +0000 UTC m=+342669.390214500: ☑️ agreed by lance6716.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716

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

The pull request process is described here

Details 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 the approved label Mar 4, 2025
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 4, 2025
@lance6716
Copy link
Contributor

/retest

@codecov
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-7.1@0e847c3). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.1     #58233   +/-   ##
================================================
  Coverage               ?   73.4710%           
================================================
  Files                  ?       1213           
  Lines                  ?     382148           
  Branches               ?          0           
================================================
  Hits                   ?     280768           
  Misses                 ?      83448           
  Partials               ?      17932           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Apr 25, 2025
@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed cherry-pick-approved Cherry pick PR approved by release team. labels Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-release-7.1 This PR is cherry-picked to release-7.1 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants