-
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: Do not create pseudo statistics for the auto-analysis check process #51479
statistics: Do not create pseudo statistics for the auto-analysis check process #51479
Conversation
Skipping CI for Draft Pull Request. |
Skipping CI for Draft Pull Request. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #51479 +/- ##
================================================
+ Coverage 70.7337% 72.9590% +2.2252%
================================================
Files 1462 1464 +2
Lines 435276 440243 +4967
================================================
+ Hits 307887 321197 +13310
+ Misses 108095 99013 -9082
- Partials 19294 20033 +739
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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:
import pymysql
import random
# Connect to TiDB
conn = pymysql.connect(host='localhost', port=4000, user='root', passwd='', db='test')
cursor = conn.cursor()
# Create partitioned table
cursor.execute("""
CREATE TABLE users (
id INT NOT NULL,
name VARCHAR(50) NOT NULL,
age INT NOT NULL,
country VARCHAR(2) NOT NULL
)
PARTITION BY RANGE (age) (
PARTITION p0 VALUES LESS THAN (20),
PARTITION p1 VALUES LESS THAN (40),
PARTITION p2 VALUES LESS THAN (60)
);
""")
# Generate and insert data
for i in range(2000):
id = i
name = 'User {}'.format(i)
age = random.randint(15, 55)
country = random.choice(['US', 'CN', 'IN'])
cursor.execute("INSERT INTO users VALUES (%s, %s, %s, %s)", (id, name, age, country))
conn.commit()
print("Partitioned table created and data inserted successfully!")
conn.close()
|
…ck process Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: ignore nil pseudo defs Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: add CreateStaticPartitionAnalysisJob Signed-off-by: hi-rustin <rustin.liu@gmail.com> feat: analyze static partition Signed-off-by: hi-rustin <rustin.liu@gmail.com> test: add more cases Signed-off-by: hi-rustin <rustin.liu@gmail.com> test: add more cases Signed-off-by: hi-rustin <rustin.liu@gmail.com> chore: rename Signed-off-by: hi-rustin <rustin.liu@gmail.com> test: add tests for stringer Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: only check static partition Signed-off-by: hi-rustin <rustin.liu@gmail.com> refactor: use crater Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: lint Signed-off-by: hi-rustin <rustin.liu@gmail.com> test: add more cases Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix:build Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: build Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: remove useless code Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: do not crate pseudo stats Signed-off-by: hi-rustin <rustin.liu@gmail.com> chore: remove todo Signed-off-by: hi-rustin <rustin.liu@gmail.com> fix: use correct id Signed-off-by: hi-rustin <rustin.liu@gmail.com> test: add more cases Signed-off-by: hi-rustin <rustin.liu@gmail.com> chore: rename Signed-off-by: hi-rustin <rustin.liu@gmail.com> chore: rename Signed-off-by: hi-rustin <rustin.liu@gmail.com> chore: rename Signed-off-by: hi-rustin <rustin.liu@gmail.com>
d6d6c74
to
1d025d1
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hawkingrei, 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 |
[LGTM Timeline notifier]Timeline:
|
/retest |
What problem does this PR solve?
Issue Number: ref #50132
Problem Summary:
What changed and how does it work?
In this PR, we solved two problems:
So I made the following changes:
GetPartitionStatsForAutoAnalyze
andGetTableStatsForAutoAnalyze
to avoid creating the pseudo stats.a.
analyze table %n.%n partition %n
b.
analyze table %n.%n partition %n index %n
In the old implementation, we wrongly analyze the entire table.
I also did some refactorings to help us construct the job.
I think I can use generic to reduce the confusion of the job structure, but this PR is already big enough. So I will do it in my following PR.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.