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

opt: push Offset into IndexJoin #121160

Merged

Conversation

mgartner
Copy link
Collaborator

The PushOffsetIntoIndexJoin rule has been added that pushes Offset
expressions below IndexJoin expressions. It is very similar to
PushLimitIntoIndexJoin.

Fixes #121157

Release note (performance improvement): The optimizer now generates more
efficient query plans for some queries with OFFSET clauses.

@mgartner mgartner requested a review from a team March 26, 2024 21:54
@mgartner mgartner requested a review from a team as a code owner March 26, 2024 21:54
@mgartner mgartner requested review from rytaft and DrewKimball and removed request for a team March 26, 2024 21:54
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball, @mgartner, and @rytaft)


pkg/sql/opt/xform/testdata/rules/limit line 896 at r1 (raw file):

 └── 5

# Ensure that the limit is not pushed down when using SKIP LOCKED.

Glad you have this case!

@mgartner mgartner force-pushed the 121157-push-offset-into-index-join branch from bd5af74 to 6a8308d Compare March 26, 2024 22:38
The `PushOffsetIntoIndexJoin` rule has been added that pushes Offset
expressions below IndexJoin expressions. It is very similar to
`PushLimitIntoIndexJoin`.

Fixes cockroachdb#121157

Release note (performance improvement): The optimizer now generates more
efficient query plans for some queries with `OFFSET` clauses.
@mgartner mgartner force-pushed the 121157-push-offset-into-index-join branch from 6a8308d to 1e4be65 Compare March 26, 2024 22:46
Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

Reviewed 1 of 2 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner and @rytaft)

@mgartner
Copy link
Collaborator Author

TFTRs!

bors r+

@craig craig bot merged commit 502fa9b into cockroachdb:master Mar 27, 2024
22 checks passed
@mgartner mgartner deleted the 121157-push-offset-into-index-join branch March 27, 2024 15:33
@yuzefovich
Copy link
Member

@mgartner Should we backport this? It seems like this should have effectively no risk. (Saw this question on slack.)

@mgartner
Copy link
Collaborator Author

mgartner commented May 9, 2024

We typically don't backport things that can change query plans unless they are disabled by default. I'm not inclined to go through that effort unless there's a strong need for it.

@mgartner
Copy link
Collaborator Author

@yuzefovich I take that back. We've seen some users run into this on v23.2, so I'll backport this behind a session setting.

@mgartner mgartner added the backport-23.2.x Flags PRs that need to be backported to 23.2. label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.2.x Flags PRs that need to be backported to 23.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opt: push Offset into IndexJoin
5 participants