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

release-19.1: opt: improve per-ON condition cost adjustment for lookup join #39028

Merged

Conversation

RaduBerinde
Copy link
Member

Backport 1/1 commits from #39016.

/cc @cockroachdb/release


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.

@RaduBerinde RaduBerinde requested review from justinj and rytaft July 22, 2019 17:51
@RaduBerinde RaduBerinde requested a review from a team as a code owner July 22, 2019 17:51
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@justinj justinj left a comment

Choose a reason for hiding this comment

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

:lgtm:

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


pkg/sql/opt/xform/testdata/coster/join, line 395 at r1 (raw file):

opt
SELECT w, x, y, z
FROM wxyzijklmn

how come this is different from the original commit?

@RaduBerinde
Copy link
Member Author


pkg/sql/opt/xform/testdata/coster/join, line 395 at r1 (raw file):

Previously, justinj (Justin Jaffray) wrote…

how come this is different from the original commit?

How is it different?

Copy link
Contributor

@justinj justinj left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/opt/xform/testdata/coster/join, line 395 at r1 (raw file):

Previously, RaduBerinde wrote…

How is it different?

oops, I was looking at the first query in the original commit and this one in this commit, ignore me!

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.
@RaduBerinde RaduBerinde merged commit c9d949e into cockroachdb:release-19.1 Jul 23, 2019
@RaduBerinde RaduBerinde deleted the backport19.1-39016 branch July 23, 2019 15:44
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.

3 participants