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

Better size estimate for SpatialJoin #1555

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/engine/SpatialJoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ size_t SpatialJoin::getCostEstimate() {
// ____________________________________________________________________________
uint64_t SpatialJoin::getSizeEstimateBeforeLimit() {
if (childLeft_ && childRight_) {
// If we limit the number of results to k, even in the largest scenario, the
// result can be at most `|childLeft| * k`
auto maxResults = getMaxResults();
if (maxResults.has_value()) {
return childLeft_->getSizeEstimate() * maxResults.value();
}

// If we don't limit the number of results, we cannot draw conclusions about
// the size, other than the worst case `|childLeft| * |childRight|`
return childLeft_->getSizeEstimate() * childRight_->getSizeEstimate();
}
return 1; // dummy return if not both children are added
Expand Down
Loading