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

statistics: always tracking predicate columns #54152

Merged

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jun 21, 2024

What problem does this PR solve?

Issue Number: ref #53567

Problem Summary:

What changed and how does it work?

You can find the more detailed design here: #53511

  • Marked TiDBEnableColumnTracking and TiDBDisableColumnTrackingTime as deprecated.
  • Always enable predicate column tracking.
  • Removed use of EnableColumnTracking and TiDBDisableColumnTrackingTime.

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. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 21, 2024
@Rustin170506 Rustin170506 changed the title statistics: mark TiDBEnableColumnTracking and TiDBDisableColumnTrackingTime deprecated WIP: statistics: mark TiDBEnableColumnTracking and TiDBDisableColumnTrackingTime deprecated Jun 21, 2024
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 21, 2024
Copy link

codecov bot commented Jun 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.9384%. Comparing base (f57d2b9) to head (794a650).
Report is 4 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54152         +/-   ##
=================================================
- Coverage   72.8354%   55.9384%   -16.8971%     
=================================================
  Files          1520       1640        +120     
  Lines        434902     605433     +170531     
=================================================
+ Hits         316763     338670      +21907     
- Misses        98541     243641     +145100     
- Partials      19598      23122       +3524     
Flag Coverage Δ
integration 37.0097% <70.0000%> (?)
unit 71.8311% <100.0000%> (+0.0121%) ⬆️

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

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

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

Rustin170506 commented Jun 21, 2024

Tested locally:

  1. Start the TiDB cluster with patch: tiup playground v8.1.0 --db.binpath /Volumes/t7/code/tidb/bin/tidb-server
  2. Try to set TiDBEnableColumnTracking: set global tidb_enable_column_tracking = 0
mysql> set global tidb_enable_column_tracking = 0
    -> ;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1681 | The 'tidb_enable_column_tracking' variable is deprecated and will be removed in future versions of TiDB. It is always set to 'ON' now. |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
  1. Check its value:
mysql> select @@tidb_enable_column_tracking;
+-------------------------------+
| @@tidb_enable_column_tracking |
+-------------------------------+
|                             1 |
+-------------------------------+
1 row in set (0.00 sec)
  1. Create a table:
use test;
create table t(a int, b int);
  1. Select from the table: select * from t where a = 1
  2. Check the predicate columns table(wait for 5 minutes):
select * from mysql.column_stats_usage;
mysql> select * from mysql.column_stats_usage;
+----------+-----------+---------------------+------------------+
| table_id | column_id | last_used_at        | last_analyzed_at |
+----------+-----------+---------------------+------------------+
|      104 |         1 | 2024-06-21 14:58:14 | NULL             |
+----------+-----------+---------------------+------------------+
1 row in set (0.00 sec)
  1. Analyze the table: analyze table t
mysql> select * from mysql.analyze_jobs;
+----+---------------------+--------------+------------+----------------+--------------------------------------------------------------------+----------------+---------------------+---------------------+----------+-------------+----------------+------------+
| id | update_time         | table_schema | table_name | partition_name | job_info                                                           | processed_rows | start_time          | end_time            | state    | fail_reason | instance       | process_id |
+----+---------------------+--------------+------------+----------------+--------------------------------------------------------------------+----------------+---------------------+---------------------+----------+-------------+----------------+------------+
|  1 | 2024-06-21 14:55:13 | test         | t          |                | analyze table all columns with 256 buckets, 100 topn, 1 samplerate |              0 | 2024-06-21 14:55:13 | 2024-06-21 14:55:13 | finished | NULL        | 127.0.0.1:4000 |       NULL |
+----+---------------------+--------------+------------+----------------+--------------------------------------------------------------------+----------------+---------------------+---------------------+----------+-------------+----------------+------------+
1 row in set (0.00 sec)

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 WIP: statistics: mark TiDBEnableColumnTracking and TiDBDisableColumnTrackingTime deprecated statistics: mark TiDBEnableColumnTracking and TiDBDisableColumnTrackingTime deprecated Jun 21, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 21, 2024
@Rustin170506 Rustin170506 changed the title statistics: mark TiDBEnableColumnTracking and TiDBDisableColumnTrackingTime deprecated statistics: always tracking predicate columns Jun 21, 2024
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 21, 2024
@Rustin170506 Rustin170506 force-pushed the rustin-patch-deprecated-predicate branch from f0fed12 to d8601c9 Compare June 21, 2024 07:46
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.)

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

ti-chi-bot bot commented Jun 21, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-21 08:08:44.200133478 +0000 UTC m=+361450.685622310: ☑️ agreed by qw4990.
  • 2024-06-21 08:17:29.77504754 +0000 UTC m=+361976.260536372: ☑️ agreed by AilinKid.

@easonn7
Copy link

easonn7 commented Jun 22, 2024

/approve

@ti-chi-bot ti-chi-bot bot added the approved label Jun 22, 2024
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.

+1

Copy link

ti-chi-bot bot commented Jun 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, easonn7, fixdb, qw4990

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

@Rustin170506 Rustin170506 force-pushed the rustin-patch-deprecated-predicate branch from d8601c9 to 794a650 Compare June 24, 2024 03:47
@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit fd2b5e9 into pingcap:master Jun 24, 2024
23 checks passed
@Rustin170506 Rustin170506 deleted the rustin-patch-deprecated-predicate branch June 24, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved component/statistics lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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.

5 participants