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: refine index/column stats methods and remove statistics.Column.Count #44406

Merged

Conversation

xuyifangreeneyes
Copy link
Contributor

This is a manual cherry-pick of #42910 and #43033

What problem does this PR solve?

Issue Number: ref #42160 close #44404

Problem Summary:

What is changed and how it works?

#42910

  1. Introduce IsAnalyzed and StatsCollected to improve encapsulation.
  2. Make TableAnalyzed more precise.
  3. Make (StatsLoadedStatus).IsLoadNeeded more precise.
  4. Make (*Table).GetColRowCount neat.

#43033

Remove statistics.Column.Count.

Before the PR, in order to maintain statistics.Column.Count, we need to read mysql.stats_top_n and mysql.stats_buckets for each column when init stats, which is time-consuming. On the other hand, the usage of statistics.Column.Count is limited. We modify (*DataSource).getColumnNDV to get rid of statistics.Column.Count.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

@ti-chi-bot ti-chi-bot bot added release-note-none do-not-merge/cherry-pick-not-approved size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 5, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 5, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-06-05 07:29:26.19494617 +0000 UTC m=+246952.467918954: ☑️ agreed by hawkingrei.
  • 2023-06-05 07:43:25.301148773 +0000 UTC m=+247791.574121557: ☑️ agreed by winoros.

@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jun 5, 2023
@xuyifangreeneyes
Copy link
Contributor Author

/test build

@xuyifangreeneyes
Copy link
Contributor Author

/approve

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 5, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrysan, hawkingrei, winoros, xuyifangreeneyes

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:
  • OWNERS [chrysan,hawkingrei,winoros,xuyifangreeneyes]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@xuyifangreeneyes
Copy link
Contributor Author

/merge

@ti-chi-bot ti-chi-bot bot merged commit 546e491 into pingcap:release-6.5 Jun 5, 2023
8 checks passed
@xuyifangreeneyes xuyifangreeneyes deleted the cp-42910-43033-to-65 branch June 5, 2023 08:18
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved and removed cherry-pick-approved Cherry pick PR approved by release team. labels Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved do-not-merge/cherry-pick-not-approved lgtm release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants