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: do not analyze table when auto analyze ratio is 0 #51467

Merged

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Mar 4, 2024

What problem does this PR solve?

Issue Number: ref #50132

Problem Summary:

What changed and how does it work?

There are two configurations for the auto-analyze feature that are very easy to misunderstand.

  1. tidb_enable_auto_analyze: Determines whether TiDB automatically updates table statistics as a background operation.
  2. tidb_auto_analyze_ratio: This variable is used to set the threshold when TiDB automatically executes ANALYZE TABLE in a background thread to update table statistics. It is possible for the value to be 0, which means auto analysis based on the change percentage will be turned off. However, new tables and indexes will still be analyzed.

So in the new implementation, I forgot it.

In this PR, I added a check for auto-analyze ratio and also added a test case to cover it.

Off-topic: I also updated TestPickOneTableAndAnalyzeByPriority to use the real API to do the analysis instead of inserting jobs directly.

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 4, 2024
Signed-off-by: hi-rustin <[email protected]>
Copy link

codecov bot commented Mar 4, 2024

Codecov Report

Merging #51467 (cb27be8) into master (ac057eb) will increase coverage by 2.0899%.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #51467        +/-   ##
================================================
+ Coverage   70.7288%   72.8187%   +2.0899%     
================================================
  Files          1462       1462                
  Lines        435268     435293        +25     
================================================
+ Hits         307860     316975      +9115     
+ Misses       108130      98376      -9754     
- Partials      19278      19942       +664     
Flag Coverage Δ
integration 48.8787% <0.0000%> (?)
unit 70.4767% <100.0000%> (-0.0534%) ⬇️

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

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

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 4, 2024
Signed-off-by: hi-rustin <[email protected]>
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

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 4, 2024
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 Mar 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, elsa0520

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 Mar 4, 2024
Copy link

ti-chi-bot bot commented Mar 4, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-04 07:46:34.503895222 +0000 UTC m=+66821.526141611: ☑️ agreed by AilinKid.
  • 2024-03-04 08:14:12.421649933 +0000 UTC m=+68479.443896318: ☑️ agreed by elsa0520.

@ti-chi-bot ti-chi-bot bot merged commit 62afab3 into pingcap:master Mar 4, 2024
23 checks passed
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/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.

3 participants