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

sessionctx: add tidb_analyze_column_options global variable #54200

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jun 25, 2024

What problem does this PR solve?

Issue Number: ref #53567

Problem Summary:
We need to introduce a new global variable to control which columns we need to analyze during the auto-analyze and manual analyze.

Users can set this variable to ALL or PREDICATE to analyze all columns or only predicate columns. The default value will be PREDICATE after this feature is fully implemented.

What changed and how does it work?

  • Added a new global variable called tidb_analyze_column_options.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test
  • 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.

None

@ti-chi-bot ti-chi-bot 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 Jun 25, 2024
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.4010%. Comparing base (bec113a) to head (f521574).
Report is 27 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54200         +/-   ##
=================================================
- Coverage   72.8470%   56.4010%   -16.4461%     
=================================================
  Files          1520       1641        +121     
  Lines        435106     608395     +173289     
=================================================
+ Hits         316962     343141      +26179     
- Misses        98555     241903     +143348     
- Partials      19589      23351       +3762     
Flag Coverage Δ
integration 36.7078% <55.5555%> (?)
unit 71.7881% <100.0000%> (-0.0498%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.2782% <ø> (+6.1361%) ⬆️

@Rustin170506
Copy link
Member Author

Tested locally:

  1. Start the cluster with the patch: tiup playground v8.1.0 --db.binpath /Volumes/t7/code/tidb/bin/tide-server
  2. Check the tidb_analyze_default_column_choice:
mysql> select @@tidb_analyze_default_column_choice;
+--------------------------------------+
| @@tidb_analyze_default_column_choice |
+--------------------------------------+
| ALL                                  |
+--------------------------------------+
1 row in set (0.01 sec)
  1. Set the tidb_analyze_default_column_choice with lower case value:
mysql> set global tidb_analyze_default_column_choice = 'predicate'
    -> ;
Query OK, 0 rows affected (0.02 sec)

mysql> select @@tidb_analyze_default_column_choice;
+--------------------------------------+
| @@tidb_analyze_default_column_choice |
+--------------------------------------+
| PREDICATE                            |
+--------------------------------------+
1 row in set (0.00 sec)
  1. Set the tidb_analyze_default_column_choice with upper case value:
mysql> set global tidb_analyze_default_column_choice = 'ALL';
Query OK, 0 rows affected (0.01 sec)

mysql> select @@tidb_analyze_default_column_choice;
+--------------------------------------+
| @@tidb_analyze_default_column_choice |
+--------------------------------------+
| ALL                                  |
+--------------------------------------+
1 row in set (0.00 sec)
  1. Try unknown value:
mysql> set global tidb_analyze_default_column_choice = 'unkown';
ERROR 1105 (HY000): invalid value for tidb_analyze_default_column_choice, it should be either 'ALL' or 'PREDICATE'

@Rustin170506
Copy link
Member Author

/retest

Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

Copy link
Contributor

@elsa0520 elsa0520 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 bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 26, 2024
@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 26, 2024
Copy link

ti-chi-bot bot commented Jun 26, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-26 02:12:55.644185809 +0000 UTC m=+772102.129674638: ☑️ agreed by elsa0520.
  • 2024-06-26 07:46:06.240634898 +0000 UTC m=+792092.726123728: ☑️ agreed by time-and-fate.

test: add tests for tidb_analyze_default_column_choice

feat: support lower case

chore: make lint happy

fix: better comment

fix: better comment

fix: better comment

fix: better comment

fix: better name

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@Rustin170506 Rustin170506 changed the title sessionctx: add tidb_analyze_default_column_choice global variable sessionctx: add tidb_analyze_column_options global variable Jun 26, 2024
@easonn7
Copy link

easonn7 commented Jun 26, 2024

/approve

Copy link

ti-chi-bot bot commented Jun 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: easonn7, elsa0520, time-and-fate

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 Jun 26, 2024
@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 1469fcf into pingcap:master Jun 26, 2024
23 checks passed
@Rustin170506 Rustin170506 deleted the rustin-patch-sessionctx branch June 27, 2024 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants