10000 Fix numeric overflow in WINDOW cost estimtation (#14464) · RtiWeb/arangodb@287b9f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 287b9f3

Browse files
authored
Fix numeric overflow in WINDOW cost estimtation (arangodb#14464)
* Fix numeric overflow in AQL WINDOW node cost estimation if the number of preceding rows was set to `unbounded`.
1 parent c4a3be5 commit 287b9f3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
devel
22
-----
33

4+
* Fix numeric overflow in AQL WINDOW node cost estimation if the number of
5+
preceding rows was set to `unbounded`.
6+
47
* Updated ArangoDB Starter to 0.15.1-preview-3.
58

69
* Added garbage collection for finished and failed Pregel conductors.

arangod/Aql/WindowNode.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,14 @@ CostEstimate WindowNode::estimateCost() const {
492492
// we never return more rows than above
493493
CostEstimate estimate = _dependencies.at(0)->getCost();
494494
if (_rangeVariable == nullptr) {
495-
int64_t numRows = 1 + _bounds.numPrecedingRows() + _bounds.numFollowingRows();
496-
estimate.estimatedCost += double(numRows * numRows) * _aggregateVariables.size();
495+
uint64_t numRows = 1;
496+
if ( _bounds.unboundedPreceding()) {
497+
numRows += estimate.estimatedNrItems;
498+
} else {
499+
numRows += std::min<uint64_t>(estimate.estimatedNrItems, _bounds.numPrecedingRows());
500+
}
501+
numRows += _bounds.numFollowingRows();
502+
estimate.estimatedCost += double(numRows) * double(numRows) * _aggregateVariables.size();
497503
} else { // guestimate
498504
estimate.estimatedCost += 4 * _aggregateVariables.size();
499505
}

0 commit comments

Comments
 (0)
0