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: stop pushing TopN down through Projection if it has undeterministic functions #53362

Merged
merged 8 commits into from
May 20, 2024

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented May 17, 2024

What problem does this PR solve?

Issue Number: close #37986

Problem Summary: planner: stop pushing TopN down through Projection if it has undeterministic functions

What changed and how does it work?

planner: stop pushing TopN down through Projection if it has undeterministic functions

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 sig/planner SIG: Planner size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 17, 2024
Copy link

tiprow bot commented May 17, 2024

Hi @qw4990. 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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 17, 2024
@qw4990
Copy link
Contributor Author

qw4990 commented May 17, 2024

/test pull-mysql-client-test

Copy link

tiprow bot commented May 17, 2024

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-mysql-client-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.

Copy link

codecov bot commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.6884%. Comparing base (397a460) to head (396608b).
Report is 5 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #53362        +/-   ##
================================================
+ Coverage   72.5545%   74.6884%   +2.1339%     
================================================
  Files          1505       1505                
  Lines        429830     430006       +176     
================================================
+ Hits         311861     321165      +9304     
+ Misses        98694      89003      -9691     
- Partials      19275      19838       +563     
Flag Coverage Δ
integration 49.4350% <55.5555%> (?)
unit 71.4094% <100.0000%> (-0.0370%) ⬇️

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

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

@hawkingrei
Copy link
Member

/ok-to-test

Copy link
Member

@time-and-fate time-and-fate left a comment

Choose a reason for hiding this comment

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

Please fix the failed cases.

pkg/planner/core/rule_topn_push_down.go Outdated Show resolved Hide resolved
Comment on lines 176 to 177
by.Expr = expression.FoldConstant(exprCtx, expression.ColumnSubstitute(exprCtx, by.Expr, p.schema, p.Exprs))
substituted := expression.ColumnSubstitute(exprCtx, by.Expr, p.schema, p.Exprs)
Copy link
Member

Choose a reason for hiding this comment

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

Why is FoldConstant() removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My fault, it has been updated now.

pkg/planner/core/rule_topn_push_down.go Outdated Show resolved Hide resolved
Copy link
Contributor

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

Comment on lines 176 to 177
by.Expr = expression.FoldConstant(exprCtx, expression.ColumnSubstitute(exprCtx, by.Expr, p.schema, p.Exprs))
substituted := expression.ColumnSubstitute(exprCtx, by.Expr, p.schema, p.Exprs)
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

qw4990 and others added 3 commits May 20, 2024 14:16
Copy link

ti-chi-bot bot commented May 20, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, time-and-fate

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 lgtm label May 20, 2024
Copy link

ti-chi-bot bot commented May 20, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-20 06:21:05.703428775 +0000 UTC m=+2066219.460564332: ☑️ agreed by AilinKid.
  • 2024-05-20 06:47:29.333737419 +0000 UTC m=+2067803.090872992: ☑️ agreed by time-and-fate.

@qw4990
Copy link
Contributor Author

qw4990 commented May 20, 2024

/test check-dev

Copy link

tiprow bot commented May 20, 2024

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

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev

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.

@qw4990 qw4990 added the type/bug-fix This PR fixes a bug. label May 20, 2024
@qw4990
Copy link
Contributor Author

qw4990 commented May 20, 2024

/test unit-test

Copy link

tiprow bot commented May 20, 2024

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

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

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.

@ti-chi-bot ti-chi-bot bot merged commit b3d740f into pingcap:master May 20, 2024
23 checks passed
terry1purcell pushed a commit to terry1purcell/tidb that referenced this pull request May 20, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request May 20, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

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

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

ti-chi-bot bot pushed a commit that referenced this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shouldn't push down the topN when the result for the order by item is uncertain
5 participants