-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
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.
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.
Reviewable status: 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)?
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.
TFTR!
Reviewable status: 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.
bors r+ |
Build succeeded: |
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.