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

*: not load unnecessay data during the non-lite-init-stats #53399

Merged
merged 5 commits into from
May 22, 2024

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented May 20, 2024

What problem does this PR solve?

Issue Number: close #53425

Problem Summary:

What changed and how does it work?

After #53298, We know that TiDB cannot load the topn when to init stats and have to load it when to sync load. so we need not load hists for the not-index column when to init stats.

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: Weizhen Wang <wangweizhen@pingcap.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none sig/planner SIG: Planner size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 20, 2024
Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.6174%. Comparing base (68219b9) to head (e876856).
Report is 20 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53399        +/-   ##
================================================
+ Coverage   72.5268%   74.6174%   +2.0906%     
================================================
  Files          1505       1505                
  Lines        429830     431474      +1644     
================================================
+ Hits         311742     321955     +10213     
+ Misses        98799      89587      -9212     
- Partials      19289      19932       +643     
Flag Coverage Δ
integration 49.1528% <0.0000%> (?)
unit 71.3514% <100.0000%> (-0.0676%) ⬇️

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

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

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 20, 2024
@@ -174,6 +174,68 @@ func (h *Handle) initStatsHistograms4ChunkLite(is infoschema.InfoSchema, cache s
}
}

func (h *Handle) initStatsHistograms4ChunkConcurrency(is infoschema.InfoSchema, cache statstypes.StatsCache, iter *chunk.Iterator4Chunk) {
Copy link
Member Author

Choose a reason for hiding this comment

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

initStatsHistograms4ChunkConcurrency is the same as initStatsHistograms4Chunk. But it will not read is_index.

Copy link
Member

Choose a reason for hiding this comment

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

What do you mean by concurrency? Can we just add a parameter to initStatsHistograms4Chunk to avoid copying the code?

Copy link
Member Author

Choose a reason for hiding this comment

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

concurrency means it is in concurrency mode.

It is hard that their code is not aligned.

@hawkingrei hawkingrei requested review from winoros and hi-rustin and removed request for winoros May 20, 2024 12:13
@hawkingrei
Copy link
Member Author

/retest

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 22, 2024
Copy link
Member

@hi-rustin hi-rustin left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -322,7 +322,7 @@ func (h *Handle) initStatsHistogramsByPaging(is infoschema.InfoSchema, cache sta
}
}()
sctx := se.(sessionctx.Context)
sql := "select HIGH_PRIORITY table_id, is_index, hist_id, distinct_count, version, null_count, cm_sketch, tot_col_size, stats_ver, correlation, flag, last_analyze_pos from mysql.stats_histograms where table_id >= %? and table_id < %?"
sql := "select HIGH_PRIORITY table_id, is_index, hist_id, distinct_count, version, null_count, cm_sketch, tot_col_size, stats_ver, correlation, flag, last_analyze_pos from mysql.stats_histograms where table_id >= %? and table_id < %? and is_index=1"
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add some comments here to explain why we chose to do it? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

Copy link

ti-chi-bot bot commented May 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

Copy link

ti-chi-bot bot commented May 22, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-22 06:52:23.874528321 +0000 UTC m=+2240897.631663892: ☑️ agreed by hi-rustin.
  • 2024-05-22 09:59:23.051951515 +0000 UTC m=+2252116.809087088: ☑️ agreed by qw4990.

@ti-chi-bot ti-chi-bot bot merged commit e954bcf into pingcap:master May 22, 2024
23 checks passed
@hawkingrei hawkingrei deleted the 0520init-stats branch May 22, 2024 12:37
@hawkingrei
Copy link
Member Author

/cherrypick release-7.5

@hawkingrei
Copy link
Member Author

/cherrypick release-8.1

@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-7.5: #53491.

In response to this:

/cherrypick release-7.5

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 22, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@hawkingrei: new pull request created to branch release-8.1: #53492.

In response to this:

/cherrypick release-8.1

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #53709.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 31, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 release-note-none 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.

not load unnecessay data during the non-lite-init-stats
4 participants