-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
sysvar: tidb_enable_column_tracking only takes effect when tidb_persist_analyze_options is turned on #53481
sysvar: tidb_enable_column_tracking only takes effect when tidb_persist_analyze_options is turned on #53481
Conversation
Tested locally:
mysql> select tidb_version();
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.2.0-alpha-213-gbc145b3afa
Edition: Community
Git Commit Hash: bc145b3afa4c377792f887d08fb6e94e873929df
Git Branch: rustin-patch-tracking
UTC Build Time: 2024-05-22 08:45:27
GoVersion: go1.21.5
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> set global tidb_enable_column_tracking = 1;
Query OK, 0 rows affected (0.02 sec)
mysql> select @@tidb_enable_column_tracking;
+-------------------------------+
| @@tidb_enable_column_tracking |
+-------------------------------+
| 1 |
+-------------------------------+
1 row in set (0.00 sec)
mysql> set global tidb_persist_analyze_options = 0;
ERROR 1105 (HY000): tidb_persist_analyze_options option cannot be set to OFF when tidb_enable_column_tracking is ON, as this will result in the loss of column tracking information
mysql> set global tidb_enable_column_tracking = 0;
Query OK, 0 rows affected (0.01 sec)
mysql> select @@tidb_enable_column_tracking;
+-------------------------------+
| @@tidb_enable_column_tracking |
+-------------------------------+
| 0 |
+--------------------------
mysql> set global tidb_persist_analyze_options = 0;
Query OK, 0 rows affected (0.01 sec)
mysql> select @@tidb_persist_analyze_options;
+--------------------------------+
| @@tidb_persist_analyze_options |
+--------------------------------+
| 0 |
+--------------------------------+
1 row in set (0.00 sec)
mysql> set global tidb_enable_column_tracking = 1;
ERROR 1105 (HY000): tidb_enable_column_tracking option cannot be set to ON when tidb_persist_analyze_options is set to OFF, as this will prevent the preservation of column tracking information |
4db4e82
to
85f323b
Compare
85f323b
to
2aa6c9f
Compare
5fd041c
to
60b5017
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #53481 +/- ##
================================================
+ Coverage 72.5278% 74.7481% +2.2203%
================================================
Files 1505 1505
Lines 429901 430856 +955
================================================
+ Hits 311798 322057 +10259
+ Misses 98809 88950 -9859
- Partials 19294 19849 +555
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…analyze_options is turned on
Signed-off-by: hi-rustin <[email protected]>
60b5017
to
bc145b3
Compare
There was a problem hiding this 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.)
enabled := TiDBOptOn(val) | ||
// If this is a user initiated statement, | ||
// we log that column tracking is disabled. | ||
if s.StmtCtx.StmtType == "Set" && !enabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why do we need to check the stmt type here. Because we are already in the set func.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: hi-rustin <[email protected]>
/test all |
[LGTM Timeline notifier]Timeline:
|
/approve For the short term, tidb_enable_column_tracking looks good to me, but for the long term, I believe only tidb_persist_analyze_options is reasonable. We don't need so many variables with complex dependencies. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: easonn7, elsa0520, hawkingrei 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 |
/retest |
3 similar comments
/retest |
/retest |
/retest |
…st_analyze_options is turned on (pingcap#53481) close pingcap#53478
What problem does this PR solve?
In TiDB we have a global variable called tidb_persist_analyze_options, the default value is true, and it will help us to store the analyze options in the system table mysql.analyze_options.
We know that the Predicate Columns collection feature relies on this system to store the column selection. So if we set tidb_persist_analyze_options to false, the predicate column feature won't work anymore. Every time you need to explicitly ANALYZE TABLE table_name PREDICATE COLUMNS to make sure TiDB only analyses the predicate columns, otherwise auto-analyze it will keep analysing all columns.
So tidb_enable_column_tracking only takes effect when tidb_persist_analyze_options is turned on.
Issue Number: close #53478
Problem Summary:
What changed and how does it work?
I added some checks before we set tidb_enable_column_tracking and tidb_persist_analyze_options. Now, you can only turn on tidb_enable_column_tracking if tidb_persist_analyze_options is turned on.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.