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, sessionctx : Add 'last_plan_from_binding' to help know whether sql's plan is matched with the hints in the binding #18017

Merged
merged 29 commits into from
Nov 20, 2020

Conversation

Reminiscent
Copy link
Contributor

@Reminiscent Reminiscent commented Jun 15, 2020

What problem does this PR solve?

Issue Number: close #16425

Problem Summary:
Add last_plan_from_binding to help know whether sql's plan is matched with the hints in the binding

What is changed and how it works?

What's Changed:

  • add a session scope system variable last_plan_from_binding to help decide whether the plan cache got hit.
  • display the last_plan_from_binding in slow log and statement summary table

Check List

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn

  • Unit test

  • Integration test

Release note

  • Add 'last_plan_from_binding' to help know whether sql's plan is matched with the hints in the binding

@github-actions github-actions bot added sig/execution SIG execution sig/planner SIG: Planner labels Jun 15, 2020
@Reminiscent
Copy link
Contributor Author

Reminiscent commented Jun 15, 2020

@lawyerphx @eurekaka PTAL
It's similar to #16321, #16476 and #17088.

@Reminiscent Reminiscent marked this pull request as ready for review June 15, 2020 08:48
@codecov
Copy link

codecov bot commented Jun 15, 2020

Codecov Report

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

@@             Coverage Diff             @@
##             master     #18017   +/-   ##
===========================================
  Coverage   79.5721%   79.5721%           
===========================================
  Files           526        526           
  Lines        143725     143725           
===========================================
  Hits         114365     114365           
  Misses        20175      20175           
  Partials       9185       9185           

@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Jun 15, 2020
Copy link
Contributor

@danmay319 danmay319 left a comment

Choose a reason for hiding this comment

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

rest LGTM

sessionctx/variable/session.go Outdated Show resolved Hide resolved
@Reminiscent
Copy link
Contributor Author

@lawyerphx @eurekaka PTAL

@danmay319 danmay319 added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 16, 2020
Copy link
Contributor

@danmay319 danmay319 left a comment

Choose a reason for hiding this comment

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

LGTM

@Reminiscent
Copy link
Contributor Author

/rebuild

@Reminiscent Reminiscent requested review from a team as code owners June 18, 2020 03:11
@Reminiscent Reminiscent requested review from wshwsh12 and removed request for a team June 18, 2020 03:11
@zz-jason zz-jason requested review from a team and removed request for a team June 18, 2020 03:15
sessionctx/variable/session.go Outdated Show resolved Hide resolved
sessionctx/variable/tidb_vars.go Outdated Show resolved Hide resolved
@Reminiscent Reminiscent changed the title planner, sessionctx : Add 'last_statement_found_in_spm' to help know whether sql's plan is matched with the hints in the binding planner, sessionctx : Add 'last_plan_from_binding' to help know whether sql's plan is matched with the hints in the binding Jun 18, 2020
@@ -415,6 +415,7 @@ const tableEventsStatementsSummaryByDigest = "CREATE TABLE if not exists perform
"LAST_SEEN timestamp(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000'," +
"PLAN_IN_CACHE bool NOT NULL," +
"PLAN_CACHE_HITS bigint unsigned NOT NULL," +
"PLAN_IN_SPM bool NOT NULL," +
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"PLAN_IN_SPM bool NOT NULL," +
"PLAN_IN_BINDING bool NOT NULL," +

@Reminiscent
Copy link
Contributor Author

@zz-jason Change all PLAN_IN_SPM to PLAN_IN_BINDING. PTAL

Copy link
Contributor

@eurekaka eurekaka 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 Nov 20, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Nov 20, 2020
@eurekaka
Copy link
Contributor

@crazycs520 I suppose this change would not break slow query stuffs, please help confirm this.

@eurekaka
Copy link
Contributor

/run-all-tests

1 similar comment
@Reminiscent
Copy link
Contributor Author

/run-all-tests

@Reminiscent
Copy link
Contributor Author

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@Reminiscent merge failed.

@Reminiscent
Copy link
Contributor Author

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 2c66371 into pingcap:master Nov 20, 2020
@Reminiscent
Copy link
Contributor Author

/label needs-cherry-pick-4.0

@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #21430

qw4990 pushed a commit that referenced this pull request Mar 12, 2021
…er sql's plan is matched with the hints in the binding (#18017) (#21430)
@Reminiscent Reminiscent deleted the issue16425 branch August 5, 2021 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/executor contribution This PR is from a community contributor. sig/execution SIG execution sig/planner SIG: Planner sig/sql-infra SIG: SQL Infra status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

intuitively observe whether a SQL used session or global binding
8 participants