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

planner: prepare AccessPath.PartialAlternativeIndexPaths to handle MV indexes #58397

Conversation

time-and-fate
Copy link
Member

@time-and-fate time-and-fate commented Dec 18, 2024

What problem does this PR solve?

Issue Number: ref #58361

What changed and how does it work?

  • As said in #58361, AccessPath.PartialAlternativeIndexPaths is changed from [][]*AccessPath to [][][]*AccessPath.
    • It's just a data type change in this PR. It's actually not utilized now, that will be in the next PR.
  • A new function cmpAlternativesByRowCount() is extracted from buildIntoAccessPath() to be reused in matchPropForIndexMergeAlternatives().
  • Related comments and util functions updates.
  • Several minor changes missing in #58332 is also added here.

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. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 18, 2024
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 84.41558% with 12 lines in your changes missing coverage. Please review.

Project coverage is 73.7163%. Comparing base (d9749cd) to head (7103c6e).
Report is 7 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58397        +/-   ##
================================================
+ Coverage   73.5280%   73.7163%   +0.1883%     
================================================
  Files          1681       1681                
  Lines        463868     464194       +326     
================================================
+ Hits         341073     342187      +1114     
+ Misses       101981     101243       -738     
+ Partials      20814      20764        -50     
Flag Coverage Δ
integration 43.2515% <81.8181%> (?)
unit 72.4206% <84.4155%> (+0.1278%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.8112% <ø> (+0.0578%) ⬆️

@time-and-fate
Copy link
Member Author

/retest

1 similar comment
@time-and-fate
Copy link
Member Author

/retest

@time-and-fate
Copy link
Member Author

/test unit-test

Copy link

tiprow bot commented Dec 19, 2024

@time-and-fate: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test fast_test_tiprow_ddlargsv1
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • fast_test_tiprow
  • tidb_parser_test

In response to this:

/test unit-test

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.

if len(ret[i].usableFilters) <= 0 {
ret[i].usableFilters = []expression.Expression{expr}
}
ret[i].usableFilters = []expression.Expression{expr}
Copy link
Member Author

Choose a reason for hiding this comment

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

The changes here should have been included in the last PR but I missed it.
It turns out we don't need, and also should not differentiate the two cases. Otherwise, the final plan may miss some IndexFilters.

Comment on lines +62 to +72
/* For example:
create table t (a int, b int, c int, key a(a), key b(b), key ac(a, c), key bc(b, c));
explain format='verbose' select * from t where a=1 or b=1 order by c;
For a=1, it has two partial alternative paths: [a, ac]
For b=1, it has two partial alternative paths: [b, bc]
Then we build such a AccessPath:
AccessPath {
PartialAlternativeIndexPaths: [[[a], [ac]], [[b], [bc]]]
IndexMergeORSourceFilter: a = 1 or b = 1
}
*/
Copy link
Member Author

Choose a reason for hiding this comment

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

This is moved from comments of generateIndexMergeOrPaths(), which will be deleted later.

Copy link
Member

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

Thanks! :shipit:

idxMergeDigest += ","
}
idxMergeDigest += "{"
resultStrs := make([]string, 0, len(paths)-startIndex)
Copy link
Member

Choose a reason for hiding this comment

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

I guess we have enough test cases to cover this refactoring. Nice refactoring!

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 20, 2024
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 20, 2024
Copy link

ti-chi-bot bot commented Dec 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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

ti-chi-bot bot commented Dec 21, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-20 07:25:41.297323845 +0000 UTC m=+1200931.386126387: ☑️ agreed by Rustin170506.
  • 2024-12-21 04:38:27.111214039 +0000 UTC m=+1277297.200016582: ☑️ agreed by AilinKid.

@ti-chi-bot ti-chi-bot bot merged commit d0ea9e5 into pingcap:master Dec 21, 2024
24 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. 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.

3 participants