-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: improve per-ON condition cost adjustment for lookup join #39016
Conversation
Issue cockroachdb#34810 tracks taking into account the internal row count of lookup joins. We currently have a hack in place to always prefer looking indexes that constrain more columns. We encountered a case where this adjustment doesn't work: when the estimated row count is very very small (which happens when there are a lot of conditions), the per-row cost adjustment ends up not making a difference (this is because of limited floating point precision, and the "tolerance" built into `Cost.Less()`). To address this, we also add a constant per-ON condition cost which isn't scaled by the row count. Release note (bug fix): Fixed bug in the optimizer causing a bad index for lookup join in some cases.
awesome that you were able to pick this up! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, can this change be extended to also address #38800?
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @justinj and @rytaft)
I don't think #38800 is directly related. If I remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 8 of 8 files at r1.
Reviewable status:complete! 2 of 0 LGTMs obtained
bors r+ |
39016: opt: improve per-ON condition cost adjustment for lookup join r=RaduBerinde a=RaduBerinde Issue #34810 tracks taking into account the internal row count of lookup joins. We currently have a hack in place to always prefer looking indexes that constrain more columns (see #35587). We encountered a case where this adjustment doesn't work: when the estimated row count is very very small (which happens when there are a lot of conditions), the per-row cost adjustment ends up not making a difference (this is because of limited floating point precision, and the "tolerance" built into `Cost.Less()`). To address this, we also add a constant per-ON condition cost which isn't scaled by the row count. Release note (bug fix): Fixed bug in the optimizer causing a bad index for lookup join in some cases. Co-authored-by: Radu Berinde <[email protected]>
Build succeeded |
Issue #34810 tracks taking into account the internal row count of
lookup joins. We currently have a hack in place to always prefer
looking indexes that constrain more columns (see #35587). We encountered a case
where this adjustment doesn't work: when the estimated row count is
very very small (which happens when there are a lot of conditions),
the per-row cost adjustment ends up not making a difference (this is
because of limited floating point precision, and the "tolerance" built
into
Cost.Less()
). To address this, we also add a constant per-ONcondition cost which isn't scaled by the row count.
Release note (bug fix): Fixed bug in the optimizer causing a bad index
for lookup join in some cases.