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: reduce cost of locality optimized anti join #63830

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented Apr 18, 2021

This commit reduces the cost of locality optimized anti join to
to ensure that we always choose it over a non-locality-optimized anti
join when possible.

Informs #63735

Release note (performance improvement): Adjusted the estimated cost
of locality optimized anti joins in the optimizer so that they are
always chosen over non-locality-optimized anti joins when possible.
This makes it more likely that queries involving anti joins (such as
inserts with foreign key checks) can avoid visting remote regions.
This results in lower latency.

This commit reduces the cost of locality optimized anti join to
to ensure that we always choose it over a non-locality-optimized anti
join when possible.

Informs cockroachdb#63735

Release note (performance improvement): Adjusted the estimated cost
of locality optimized anti joins in the optimizer so that they are
always chosen over non-locality-optimized anti joins when possible.
This makes it more likely that queries involving anti joins (such as
inserts with foreign key checks) can avoid visting remote regions.
This results in lower latency.
@rytaft rytaft requested review from a team April 18, 2021 22:28
@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:

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


pkg/sql/opt/xform/coster.go, line 881 at r1 (raw file):

	// based on the latency between regions.
	if localityOptimized {
		cost /= 2.5

Any problem with using a bigger constant (given that 2 was too conservative)?

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!

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


pkg/sql/opt/xform/coster.go, line 881 at r1 (raw file):

Previously, RaduBerinde wrote…

Any problem with using a bigger constant (given that 2 was too conservative)?

I don't think there's a big problem, but I also don't want the cost to be way smaller than it would be otherwise. I'm pretty confident that 2.5 will do the trick since the cost of all the lookup joins should be basically identical. I think the problem with dividing by 2 was that depending on the numerical rounding, either the locality optimized anti joins or the single anti join could be slightly cheaper.

@rytaft
Copy link
Collaborator Author

rytaft commented Apr 20, 2021

bors r+

@craig
Copy link
Contributor

craig bot commented Apr 20, 2021

Build succeeded:

@craig craig bot merged commit bea4754 into cockroachdb:master Apr 20, 2021
@rafiss rafiss added this to the 21.1 milestone Apr 22, 2021
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.

4 participants