-
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
statistics: Remove the ineffective dirty IDs from the row count cache #56287
statistics: Remove the ineffective dirty IDs from the row count cache #56287
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56287 +/- ##
================================================
+ Coverage 72.9851% 73.2029% +0.2177%
================================================
Files 1699 1729 +30
Lines 469598 477589 +7991
================================================
+ Hits 342737 349609 +6872
- Misses 105774 106158 +384
- Partials 21087 21822 +735
Flags with carried forward coverage won't be shown. Click here to find out more.
|
7f74d6f
to
69353ca
Compare
Tested in the test-infra: mysql> SHOW STATS_META where db_name='uds500k';
+---------+-------------+----------------+---------------------+--------------+-----------+---------------------+
| Db_name | Table_name | Partition_name | Update_time | Modify_count | Row_count | Last_analyze_time |
+---------+-------------+----------------+---------------------+--------------+-----------+---------------------+
| uds500k | index_Data4 | | 2025-02-13 19:33:14 | 0 | 500000 | 2025-02-13 19:33:14 |
| uds500k | index_Data3 | | 2025-02-13 19:33:17 | 0 | 500000 | 2025-02-13 19:33:17 |
| uds500k | index_Data1 | | 2025-02-13 19:33:20 | 0 | 500000 | 2025-02-13 19:33:20 |
| uds500k | index_Data2 | | 2025-02-13 19:33:23 | 0 | 500000 | 2025-02-13 19:33:23 |
| uds500k | index_Data5 | | 2025-02-13 19:33:26 | 0 | 500000 | 2025-02-13 19:33:26 |
| uds500k | Data4 | | 2025-02-13 19:32:58 | 0 | 500000 | 2025-02-13 19:32:58 |
| uds500k | Data5 | | 2025-02-13 19:33:01 | 0 | 500000 | 2025-02-13 19:33:01 |
| uds500k | Data2 | | 2025-02-13 19:33:04 | 0 | 500000 | 2025-02-13 19:33:04 |
| uds500k | Data3 | | 2025-02-13 19:33:07 | 0 | 500000 | 2025-02-13 19:33:07 |
| uds500k | Data1 | | 2025-02-13 19:33:10 | 0 | 500000 | 2025-02-13 19:33:10 |
+---------+-------------+----------------+---------------------+--------------+-----------+---------------------+
10 rows in set (0.39 sec)
mysql> select table_name, avg_row_length, max_data_length, data_length, table_rows from information_schema.tables where table_schema = 'uds500k';
+-------------+----------------+-----------------+-------------+------------+
| table_name | avg_row_length | max_data_length | data_length | table_rows |
+-------------+----------------+-----------------+-------------+------------+
| index_Data4 | 135 | 0 | 67991573 | 500000 |
| index_Data3 | 136 | 0 | 68001335 | 500000 |
| index_Data1 | 136 | 0 | 68002490 | 500000 |
| index_Data2 | 136 | 0 | 68003939 | 500000 |
| index_Data5 | 136 | 0 | 68004062 | 500000 |
| Data4 | 24 | 0 | 12000000 | 500000 |
| Data5 | 24 | 0 | 12000000 | 500000 |
| Data2 | 24 | 0 | 12000000 | 500000 |
| Data3 | 24 | 0 | 12000000 | 500000 |
| Data1 | 24 | 0 | 12000000 | 500000 |
+-------------+----------------+-----------------+-------------+------------+
10 rows in set (0.08 sec) |
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.)
Tested locally: tiup playground v8.5.1 --db.host 127.0.0.1 --without-monitor --tiflash 0 --db 2 On tidb1: use test;
create table t1(a int);create table t3(a int);create table t2(a int);
insert into t1 value(1);
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t2 select * from t1;
insert into t3 select * from t1; Wait until on tidb1: show stats_meta;
Then, on tidb2: mysql> select table_name, avg_row_length, max_data_length, data_length, table_rows from information_schema.tables where table_schema = 'test';
+------------+----------------+-----------------+-------------+------------+
| table_name | avg_row_length | max_data_length | data_length | table_rows |
+------------+----------------+-----------------+-------------+------------+
| t1 | 8 | 0 | 131072 | 16384 |
| t3 | 8 | 0 | 131072 | 16384 |
| t2 | 8 | 0 | 131072 | 16384 |
+------------+----------------+-----------------+-------------+------------+
3 rows in set (0.02 sec) |
pkg/executor/infoschema_reader.go
Outdated
return rows, err | ||
} | ||
} else { | ||
// Even if the table is a partition table, we still need to update the stats cache for the table itself. |
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.
Please add the reason.
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.
Others LGTM.
/reopen |
@Rustin170506: Failed to re-open PR: state cannot be changed. There are no new commits on the Rustin170506:rustin-patch-modify-time branch. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Signed-off-by: Rustin170506 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
…bles Signed-off-by: Rustin170506 <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qw4990, tangenta, 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 |
/test all |
/retest |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
What problem does this PR solve?
Issue Number: close #55803
Problem Summary:
What changed and how does it work?
As I mentioned in the issue #55803 (comment), the main problem is that
UpdateByID
anciently updates the modify_time even when the dirty tables have not been updated.But as @time-and-fate mentioned, the maintenance of the dirty table follows a best-effort approach, so it would be better to delete it entirely.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.