Skip to content

Commit

Permalink
better size estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
ullingerc committed Oct 15, 2024
1 parent 414f50c commit 202e888
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 202e888

Please sign in to comment.