-
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
br: support backup and restore column_stats_usage
#54634
br: support backup and restore column_stats_usage
#54634
Conversation
5f3e251
to
7ac61e4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54634 +/- ##
=================================================
- Coverage 74.6249% 57.2039% -17.4211%
=================================================
Files 1551 1674 +123
Lines 362640 617732 +255092
=================================================
+ Hits 270620 353367 +82747
- Misses 72390 240802 +168412
- Partials 19630 23563 +3933
Flags with carried forward coverage won't be shown. Click here to find out more.
|
911b542
to
739b023
Compare
/retest |
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.)
colStatsUsage map[model.TableItemID]statstypes.ColStatsTimeInfo, | ||
) error { | ||
for colID, statsUsage := range colStatsUsage { | ||
lastUsedAt := "NULL" |
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 if we have a better way to handle this. The ExecRows function cannot handle nil correctly, so I have to rely on the CONVERT_TZ to insert 'null' if it is 'NULL'.
5fdf072
to
5f69217
Compare
column_stats_usage
column_stats_usage
Tests locally:
USE test;
CREATE TABLE new_employees
(
id INT NOT NULL,
fname VARCHAR(30),
lname VARCHAR(30),
hired DATE NOT NULL DEFAULT '1970-01-01',
separated DATE DEFAULT '9999-12-31',
job_code INT,
store_id INT NOT NULL
);
INSERT INTO new_employees (id, fname, lname, hired, separated, job_code, store_id) VALUES
(1, 'John', 'Doe', '2023-01-01', '9999-12-31', 101, 1),
(2, 'Jane', 'Doe', '2023-02-01', '9999-12-31', 102, 2),
(3, 'Jim', 'Beam', '2023-03-01', '9999-12-31', 103, 3);
SELECT * from mysql.stats_meta;
SELECT * FROM new_employees WHERE fname = 'a';
SELECT * FROM mysql.column_stats_usage;
+--------+---------+-------------------+----------------+
|table_id|column_id|last_used_at |last_analyzed_at|
+--------+---------+-------------------+----------------+
|104 |2 |2024-07-17 18:06:39|null |
+--------+---------+-------------------+----------------+
ANALYZE table new_employees;
SELECT * FROM mysql.column_stats_usage;
+--------+---------+-------------------+-------------------+
|table_id|column_id|last_used_at |last_analyzed_at |
+--------+---------+-------------------+-------------------+
|104 |2 |2024-07-17 18:06:39|2024-07-17 18:11:45|
+--------+---------+-------------------+-------------------+
SELECT * FROM mysql.column_stats_usage;
SELECT * FROM mysql.column_stats_usage;
+--------+---------+-------------------+-------------------+
|table_id|column_id|last_used_at |last_analyzed_at |
+--------+---------+-------------------+-------------------+
|104 |2 |2024-07-17 18:06:39|2024-07-17 18:11:45|
+--------+---------+-------------------+-------------------+ |
/retest |
/retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hawkingrei, Leavrth 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 |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: ref #53567
Problem Summary:
After we enabled the predicate columns feature by default, we need to support backup and restore this information.
What changed and how does it work?
column_stats_usage
.pkg/statistics/handle/usage/predicate_column.go
topkg/statistics/handle/usage/predicatecolumn/predicate_column.go
, otherwise it would cause a cyclic dependence issue.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.