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

Adjust range heap coster to ensure we don't choose it over a strong lookup join. #1913

Merged
merged 1 commit into from Jul 31, 2023

Conversation

nicktobey
Copy link
Contributor

This improves the performance for a client query by ensuring that we don't us a HeapRangeJoin when there's a good LookupJoin candidate, but we do use a HeapRangeJoin when there isn't.

In larger queries, the time spent generating and evaluating candidate rows dominates. Using seqIOCostFactor feels like a bit of a misnomer, but cpuCostFactor is too low to reflect this behavior, and this is what costInnerJoin uses.

In larger queries, the time spent generating and evaluating candidate rows dominates. Using seqIOCostFactor feels like a bit of a misnomer, but cpuCostFactor is too low to reflect this behavior, and this is what costInnerJoin uses.

We want to make sure that RangeHeapJoin scores worse than LookupJoins when there's a good index for lookups, but still better than loop joins. This does that.

(Also added a regression test.)
Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

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

lgtm, using seq instead of cpu seems fine while this is all hazy anyways

setup: []string{
"create table vals (val int, filter1 int, filter2 int, filter3 int)",
"create table ranges (min int, max int, filter1 int, filter2 int, filter3 int, key filters (filter1, filter2, filter3))",
"insert into vals values (0, 0, 0, 0), " +
Copy link
Contributor

Choose a reason for hiding this comment

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

we can inject cardinalities into costing, maybe a bit easier than manually writing 100 insertions.

@nicktobey nicktobey merged commit faed8db into main Jul 31, 2023
7 checks passed
@nicktobey nicktobey deleted the nicktobey/heaprangecost branch July 31, 2023 22:46
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.

None yet

2 participants