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

planner: fix the issue where TiDB generates multiple plandigests for 'IN (...)'. #47216

Merged
merged 18 commits into from
Nov 1, 2023

Conversation

King-Dylan
Copy link
Contributor

@King-Dylan King-Dylan commented Sep 24, 2023

What problem does this PR solve?

Issue Number: close #33559
Problem Summary:
queries with the same plan have different plan_digest in information_schema.statement_summary

What is changed and how it works?

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.

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.

Supports generating the same plan digest for SQL IN operations with different numbers of arguments.

@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title release-note-none Denotes a PR that doesn't merit a release note. labels Sep 24, 2023
@sre-bot
Copy link
Contributor

sre-bot commented Sep 24, 2023

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Sep 24, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 24, 2023

Welcome @King-Dylan!

It looks like this is your first PR to pingcap/tidb 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tidb. 😃

@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 24, 2023

Hi @King-Dylan. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

@tiprow
Copy link

tiprow bot commented Sep 24, 2023

Hi @King-Dylan. 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/test-infra repository.

@King-Dylan King-Dylan changed the title fix the issue where TiDB generates multiple plandigests for 'IN (...)'. planner: fix the issue where TiDB generates multiple plandigests for 'IN (...)'. Sep 24, 2023
Copy link
Contributor

@fixdb fixdb left a comment

Choose a reason for hiding this comment

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

This patch only works for IN list where it is in predicate, but will it work for IN list in Projection? e.g.

select a in (1, 2, 3) from t;

@King-Dylan King-Dylan requested a review from fixdb September 26, 2023 04:40
Copy link
Contributor

@fixdb fixdb left a comment

Choose a reason for hiding this comment

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

Can we also add test case for projection?

@King-Dylan King-Dylan requested a review from fixdb October 2, 2023 02:01
@jackysp
Copy link
Member

jackysp commented Oct 3, 2023

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

Please sign it @King-Dylan

}
default:
if expr.FuncName.L == ast.In {
buffer.WriteString("...")
Copy link
Member

Choose a reason for hiding this comment

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

What if there is only one constant or if there are columns in the arguments? What's the expected behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if the plan hasn't changed, we don't need to worry about how many arguments are used. What do you think about? I can add more logical if you think it's necessary.

Copy link
Member

@time-and-fate time-and-fate Oct 10, 2023

Choose a reason for hiding this comment

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

I think we can say this is proper and expected behavior. And I'm also OK with this idea.
What I'm concerned about is that it's not fully consistent with the behavior of SQL digest. Essentially there isn't an overall design for their behaviors.

@King-Dylan King-Dylan requested a review from a team as a code owner October 10, 2023 07:55
}
default:
if expr.FuncName.L == ast.In {
buffer.WriteString("...")
Copy link
Member

@time-and-fate time-and-fate Oct 10, 2023

Choose a reason for hiding this comment

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

I think we can say this is proper and expected behavior. And I'm also OK with this idea.
What I'm concerned about is that it's not fully consistent with the behavior of SQL digest. Essentially there isn't an overall design for their behaviors.

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 13, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 13, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-10-12 07:36:14.516107442 +0000 UTC m=+1296972.103217588: ☑️ agreed by time-and-fate.
  • 2023-10-13 07:08:57.531890132 +0000 UTC m=+1381735.119000292: ☑️ agreed by chrysan.

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #47216 (3b19c71) into master (cc12200) will increase coverage by 1.3477%.
Report is 14 commits behind head on master.
The diff coverage is 77.0833%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #47216        +/-   ##
================================================
+ Coverage   71.5920%   72.9398%   +1.3477%     
================================================
  Files          1400       1423        +23     
  Lines        405894     413929      +8035     
================================================
+ Hits         290588     301919     +11331     
+ Misses        95488      93118      -2370     
+ Partials      19818      18892       -926     
Flag Coverage Δ
integration 42.7726% <20.8333%> (?)
unit 71.7399% <77.0833%> (+0.1478%) ⬆️

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

Components Coverage Δ
dumpling 55.5260% <ø> (+1.4757%) ⬆️
parser ∅ <ø> (∅)
br 49.3025% <ø> (-3.5954%) ⬇️

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 23, 2023

@King-Dylan: 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/test-infra repository.

1 similar comment
@tiprow
Copy link

tiprow bot commented Oct 23, 2023

@King-Dylan: 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/test-infra repository.

@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Oct 23, 2023
@King-Dylan
Copy link
Contributor Author

/test tiprow_fast_test

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 23, 2023

@King-Dylan: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-br-integration-test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-ddl-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-mysql-client-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test

In response to this:

/test tiprow_fast_test

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.

@tiprow
Copy link

tiprow bot commented Oct 23, 2023

@King-Dylan: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test tiprow_fast_test

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.

@King-Dylan
Copy link
Contributor Author

/retest

@King-Dylan
Copy link
Contributor Author

/retest

1 similar comment
@King-Dylan
Copy link
Contributor Author

/retest

@easonn7
Copy link

easonn7 commented Nov 1, 2023

/approve

A reasonable optimization for tidb_ignore_inlist_plan_digest is to exclude inlists from plan digests in most cases.

Copy link

ti-chi-bot bot commented Nov 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, chrysan, easonn7, time-and-fate, XuHuaiyu

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

@ti-chi-bot ti-chi-bot bot added the approved label Nov 1, 2023
@King-Dylan
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 89945f5 into pingcap:master Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

queries with the same plan have different plan_digest in information_schema.statement_summary
10 participants