-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
*: implement analyze predicate columns #30816
*: implement analyze predicate columns #30816
Conversation
… consider partition table
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/ae5f30bbb086d2ab896231837b633c4ffe75500e |
/run-unit-test |
/run-check_dev_2 |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: f00e4a3
|
/run-unit-test |
/run-check_dev_2 |
What problem does this PR solve?
Issue Number: close #31102
Problem Summary:
What is changed and how it works?
What is changed?
analyze table t predicate columns
. When there is no predicate column fort
, it gives a warning and falls back to analyze all columns.tidb_enable_column_tracking
, which controls whether to collect predicate columns from SQL and dump to disk. Whenset global tidb_enable_column_tracking = 0
, all the predicate columns collected before are invalidated.How it works?
analyze table t predicate columns
finds out predicate columns fort
by reading frommysql.column_stats_usage
. After figuring out which columns' stats need to be collected, the following thing is just the same asanalyze table t columns c1, ..., cn
.set global tidb_enable_column_tracking = 0
, we don't physically updatemysql.column_stats_usage
to invalidate predicate columns. Instead, we record the time of the setting operation intidb_disable_column_tracking_time
, which is a variable in the system variablemysql.tidb
. When we want to get predicate columns, we read frommysql.column_stats_usage
and filter out the columns whoselast_used_at
is null. Then we comparelast_used_at
withtidb_disable_column_tracking_time
.last_used_at <= tidb_disable_column_tracking_time
means that the predicate columns is invalidated. So we only regard the columns whoselast_used_at > tidb_disable_column_tracking_time
as predicate columns.Check List
Tests
Side effects
Documentation
Release note