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: add comments and remove unnessary check #53568

Merged
merged 3 commits into from
May 27, 2024

Conversation

Rustin170506
Copy link
Member

What problem does this PR solve?

Issue Number: ref #53567

Problem Summary:

What changed and how does it work?

  1. I added some comments to the GetPredicateColumns function.
  2. Remove an unnecessary check, because the column id is always not null. You can find it in the schema:
	CreateColumnStatsUsageTable = `CREATE TABLE IF NOT EXISTS mysql.column_stats_usage (
		table_id BIGINT(64) NOT NULL,
		column_id BIGINT(64) NOT NULL,
		last_used_at TIMESTAMP,
		last_analyzed_at TIMESTAMP,
		PRIMARY KEY (table_id, column_id) CLUSTERED
	);`
  1. Added a TODO item to indicate the need to reconsider this design.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@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/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 27, 2024
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
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.)

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 27, 2024
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.)

if err != nil {
return nil, errors.Trace(err)
}
columnIDs := make([]int64, 0, len(rows))
for _, row := range rows {
if row.IsNull(0) || row.IsNull(1) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the first check here.

// `set global enable_column_tracking = 0` indicates all the predicate columns collected before.
// If `last_used_at` is before the time when `set global tidb_enable_column_tracking = 0`, we don't regard the column as predicate column because
// `set global tidb_enable_column_tracking = 0` indicates all the predicate columns collected before.
// TODO: Why do we need to do this? If column tracking is already disabled, we should not collect any column usage.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will discuss it with roger.

Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 74.5982%. Comparing base (d24fdb7) to head (6424eff).
Report is 6 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53568        +/-   ##
================================================
+ Coverage   72.4150%   74.5982%   +2.1831%     
================================================
  Files          1505       1505                
  Lines        430553     430883       +330     
================================================
+ Hits         311785     321431      +9646     
+ Misses        99448      89588      -9860     
- Partials      19320      19864       +544     
Flag Coverage Δ
integration 49.4698% <0.0000%> (?)
unit 71.4252% <94.1176%> (+0.0352%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.4572% <ø> (+9.0701%) ⬆️

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 27, 2024
@Rustin170506
Copy link
Member Author

/retest

Copy link
Contributor

@elsa0520 elsa0520 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

ti-chi-bot bot commented May 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: elsa0520, 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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 27, 2024
Copy link

ti-chi-bot bot commented May 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-27 07:55:01.791022738 +0000 UTC m=+2676655.548158311: ☑️ agreed by qw4990.
  • 2024-05-27 08:42:07.589084123 +0000 UTC m=+2679481.346219693: ☑️ agreed by elsa0520.

@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 2300ac6 into pingcap:master May 27, 2024
23 checks passed
@Rustin170506 Rustin170506 deleted the rustin-patch-disable-tracking branch May 27, 2024 14:36
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants