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: fix infinite cost estimate for lookup join with limit hint #46440

Merged
merged 1 commit into from
Mar 24, 2020

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented Mar 23, 2020

Due to a divide-by-zero error, the coster estimated an infinite limit hint --
and therefore an infinite cost -- for lookup joins that had a limit hint and
zero output rows. This caused an internal error during planning.

This commit fixes the problem by fixing the divide-by-zero error. Instead of
an infinite limit hint, it estimates a limit hint of 0.

Fixes #46187

Release justification: This is a low risk, high benefit change to existing
functionality.

Release note (bug fix): Fixed an internal error that could occur during
planning for some queries with a join and negative LIMIT.

Due to a divide-by-zero error, the coster estimated an infinite limit hint --
and therefore an infinite cost -- for lookup joins that had a limit hint and
zero output rows. This caused an internal error during planning.

This commit fixes the problem by fixing the divide-by-zero error. Instead of
an infinite limit hint, it estimates a limit hint of 0.

Fixes cockroachdb#46187

Release justification: This is a low risk, high benefit change to existing
functionality.

Release note (bug fix): Fixed an internal error that could occur during
planning for some queries with a join and negative LIMIT.
@rytaft rytaft requested a review from RaduBerinde March 23, 2020 21:51
@rytaft rytaft requested a review from a team as a code owner March 23, 2020 21:51
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks for the quick fix!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)

Copy link
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@rytaft
Copy link
Collaborator Author

rytaft commented Mar 24, 2020

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 24, 2020

Build succeeded

@craig craig bot merged commit 9fe869b into cockroachdb:master Mar 24, 2020
@rytaft rytaft deleted the neg-limit branch April 2, 2020 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query with negative LIMIT results in an internal error "node lookup-join with MaxCost added to the memo"
3 participants