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: avoid using infoschema when to init stats #54514

Merged
merged 25 commits into from
Sep 30, 2024

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jul 9, 2024

What problem does this PR solve?

Issue Number: close #55851

Problem Summary:

What changed and how does it work?

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 do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked 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. sig/planner SIG: Planner labels Jul 9, 2024
@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 Jul 9, 2024
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 83.08824% with 23 lines in your changes missing coverage. Please review.

Project coverage is 77.5396%. Comparing base (a5e07a2) to head (c420a65).
Report is 72 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #54514        +/-   ##
================================================
+ Coverage   73.4625%   77.5396%   +4.0770%     
================================================
  Files          1605       1649        +44     
  Lines        445096     473612     +28516     
================================================
+ Hits         326979     367237     +40258     
+ Misses        98081      84994     -13087     
- Partials      20036      21381      +1345     
Flag Coverage Δ
integration 54.3537% <75.7352%> (?)
unit 73.7611% <80.8823%> (+1.2181%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 65.6140% <ø> (+19.5998%) ⬆️

@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 9, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2024
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 28, 2024
Copy link

ti-chi-bot bot commented Aug 28, 2024

PR needs rebase.

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.

@hawkingrei hawkingrei force-pushed the avoid_use branch 3 times, most recently from c44c3fa to afa34ce Compare September 4, 2024 06:21
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

@hawkingrei
Copy link
Member Author

/retest

Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@@ -508,46 +508,6 @@ func TestIssue44369(t *testing.T) {
tk.MustExec("select * from t where a = 10 and bb > 20;")
}

// Test the case that after ALTER TABLE happens, the pointer to the column info/index info should be refreshed.
func TestColAndIdxExistenceMapChangedAfterAlterTable(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

No table info in the stats. so we don't need to test for it.

@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest


// Detect the context cancel signal, since it may take a long time for the loop.
// TODO: add context to TableInfoByID and remove this code block?
if ctx.Err() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is important, why remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we don't need to read meta. so we can remove this code.

// Now, we cannot init the column info in the ColAndIdxExistenceMap when to disable lite-init-stats.
// so we have to get the column info from the domain.
is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema)
tblInfo, ok := statsHandle.TableInfoByID(is, col.TableID)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference... it's still calling TableInfoByID?
How could this avoid using infoschema when init stats

Copy link
Member Author

Choose a reason for hiding this comment

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

In this context, stats are loaded only for the tables that require statistical information, thereby avoiding a full load meta.

pkg/statistics/table.go Show resolved Hide resolved
pkg/statistics/table.go Show resolved Hide resolved
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member Author

/retest

1 similar comment
@hawkingrei
Copy link
Member Author

/retest

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

ti-chi-bot bot commented Sep 29, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-27 12:50:41.690544279 +0000 UTC m=+13597.110757285: ☑️ agreed by winoros.
  • 2024-09-29 14:29:53.299663543 +0000 UTC m=+192348.719876551: ☑️ agreed by tiancaiamao.

Copy link

ti-chi-bot bot commented Sep 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, tiancaiamao, winoros

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 the approved label Sep 30, 2024
@ti-chi-bot ti-chi-bot bot merged commit bb9f4d1 into pingcap:master Sep 30, 2024
25 checks passed
@hawkingrei hawkingrei deleted the avoid_use branch September 30, 2024 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt the statistics for infoschema v2
4 participants