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

ddl: enhance row size estimation before adding index #52086

Merged
merged 6 commits into from
Mar 27, 2024

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Mar 25, 2024

What problem does this PR solve?

Issue Number: close #52085

Problem Summary: See #52085.

What changed and how does it work?

  • Move avarage row size estimation to the beginning of adding index.
  • Use approximate-key-size * MB / approximate-keys from region info fetched by PD client to enhance row size estimation.

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-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 25, 2024
Copy link

tiprow bot commented Mar 25, 2024

Hi @tangenta. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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/test-infra repository.

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Merging #52086 (0ac1463) into master (75c8347) will decrease coverage by 16.0419%.
Report is 10 commits behind head on master.
The diff coverage is 67.8899%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #52086         +/-   ##
=================================================
- Coverage   70.6807%   54.6389%   -16.0419%     
=================================================
  Files          1486       1597        +111     
  Lines        439452     610629     +171177     
=================================================
+ Hits         310608     333641      +23033     
- Misses       109337     253743     +144406     
- Partials      19507      23245       +3738     
Flag Coverage Δ
integration 36.6812% <65.1376%> (?)
unit 70.4238% <32.1100%> (-0.0680%) ⬇️

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

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

@ywqzzy ywqzzy self-requested a review March 26, 2024 03:11
logutil.Logger(ctx).Info("estimate row size",
zap.Int64("tableID", tbl.Meta().ID), zap.Int("size", sizeInBytes), zap.Error(gErr))
}()
rowCount, avgRowLen, _, _ := cache.TableRowStatsCache.EstimateDataLength(tbl.Meta())
Copy link
Contributor

@ywqzzy ywqzzy Mar 26, 2024

Choose a reason for hiding this comment

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

statsCache only updated when we access infoschema.Table/Columns, maybe read stats from mysql.stats_meta and mysql.stats_histograms;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

@ywqzzy ywqzzy 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

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. and removed do-not-merge/needs-tests-checked labels Mar 26, 2024
@tangenta
Copy link
Contributor Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 26, 2024
@tangenta
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 26, 2024
Copy link

ti-chi-bot bot commented Mar 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ywqzzy, zimulala

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

ti-chi-bot bot commented Mar 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-26 03:25:55.011139614 +0000 UTC m=+1951982.033386002: ☑️ agreed by ywqzzy.
  • 2024-03-27 02:24:46.692264103 +0000 UTC m=+2034713.714510491: ☑️ agreed by zimulala.

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

Add index row estimation is not fully usable
3 participants