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

*: support resource_group sql hint #41678

Merged
merged 12 commits into from
Mar 6, 2023

Conversation

BornChanger
Copy link
Contributor

@BornChanger BornChanger commented Feb 22, 2023

What problem does this PR solve?

Issue Number: close #41676

Problem Summary:

What is changed and how it works?

Via this pr, resource control can support resource _group hint, here is an example

select /*+ resource_group(rg1) */ * from t1;

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
mysql> select * from information_schema.resource_groups;
+---------+------------+-----------+
| NAME    | RU_PER_SEC | BURSTABLE |
+---------+------------+-----------+
| default |   10000000 | YES       |
| rg1     |      10000 | NO        |
+---------+------------+-----------+
2 rows in set (0.00 sec)

mysql> select /*+ resource_group(rg1) */ * from t1;
Empty set (0.01 sec)

mysql> select /*+ resource_group(rg2) */ * from t1;
ERROR 1105 (HY000): [resource group] resourceGroupName rg2 is not existed.

mysql> insert /*+ resource_group(rg2) */ into t1 values(1);
ERROR 1105 (HY000): [resource group] resourceGroupName rg2 is not existed.

mysql> delete /*+ resource_group(rg3) */ from t1;
ERROR 1105 (HY000): [resource group] resourceGroupName rg3 is not existed.
  • No code

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
Copy link
Member

ti-chi-bot commented Feb 22, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • glorv
  • tiancaiamao

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 22, 2023
@BornChanger
Copy link
Contributor Author

/cc @nolouch @tiancaiamao @glorv

Signed-off-by: BornChanger <[email protected]>
Signed-off-by: BornChanger <[email protected]>
Signed-off-by: BornChanger <[email protected]>
planner/optimize.go Outdated Show resolved Hide resolved
Signed-off-by: BornChanger <[email protected]>
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 27, 2023
Signed-off-by: BornChanger <[email protected]>
Signed-off-by: BornChanger <[email protected]>
Signed-off-by: BornChanger <[email protected]>
Signed-off-by: BornChanger <[email protected]>
session/session.go Outdated Show resolved Hide resolved
Signed-off-by: BornChanger <[email protected]>
Copy link
Contributor

@glorv glorv 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-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 3, 2023
@BornChanger
Copy link
Contributor Author

/retest

@@ -162,6 +162,15 @@ func Optimize(ctx context.Context, sctx sessionctx.Context, node ast.Node, is in
}
}

// Override the resource group if necessary
// TODO: we didn't check the existence of the hinted resource group now to save the cost per query
if originStmtHints.HasResourceGroup && variable.EnableResourceControl.Load() {
Copy link
Member

@nolouch nolouch Mar 6, 2023

Choose a reason for hiding this comment

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

How about :

if originStmtHints.HasResourceGroup {
       if variable.EnableResourceControl.Load() {
       }
       ...
}

I think more readable and can reduce once if judged for normal situations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: BornChanger <[email protected]>
@BornChanger
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 6, 2023
@BornChanger
Copy link
Contributor Author

/retest

@glorv
Copy link
Contributor

glorv commented Mar 6, 2023

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: be210d8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 6, 2023
@glorv glorv merged commit 17bbc29 into pingcap:master Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. 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.

support resource_group hint for resource control feature
6 participants