Skip to content

Commit

Permalink
Address Robin's comment and improve parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannah Bast committed Feb 9, 2025
1 parent 612a8df commit bed12e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/engine/QueryExecutionTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ QueryExecutionTree::selectedVariablesToColumnIndices(

// _____________________________________________________________________________
size_t QueryExecutionTree::getCostEstimate() {
// If the result is cached and `zero-cost-for-cached-subtrees` is set to
// `true`, we set the cost estimate to zero.
// If the result is cached and `zero-cost-estimate-for-cached-subtrees` is set
// to `true`, we set the cost estimate to zero.
if (cachedResult_ &&
RuntimeParameters().get<"zero-cost-for-cached-subtree">()) {
RuntimeParameters().get<"zero-cost-estimate-for-cached-subtree">()) {
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/global/RuntimeParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline auto& RuntimeParameters() {
SizeT<"small-index-scan-size-estimate-divisor">{5},
// Determines whether the cost estimate for a cached subtree should be
// set to zero in query planning.
Bool<"zero-cost-for-cached-subtree">{false},
Bool<"zero-cost-estimate-for-cached-subtree">{false},
};
}();
return params;
Expand Down
12 changes: 8 additions & 4 deletions test/OperationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,22 @@ TEST(OperationTest, estimatesForCachedResults) {
[[maybe_unused]] auto res = qet->getResult();
}
// The result is now cached inside the static execution context. If we create
// the same operation again and `zero-cost-for-cached-subtrees` is set to
// `true`, the cost estimate should be zero. The size estimate does not
// the same operation again and `zero-cost-estimate-for-cached-subtrees` is
// set to `true`, the cost estimate should be zero. The size estimate does not
// change (see the `getCostEstimate` function for details on why).
{
RuntimeParameters().set<"zero-cost-for-cached-subtree">(true);
auto restoreWhenScopeEnds =
setRuntimeParameterForTest<"zero-cost-estimate-for-cached-subtree">(
true);
auto qet = makeQet();
EXPECT_EQ(qet->getCacheKey(), qet->getRootOperation()->getCacheKey());
EXPECT_EQ(qet->getSizeEstimate(), 24u);
EXPECT_EQ(qet->getCostEstimate(), 0u);
}
{
RuntimeParameters().set<"zero-cost-for-cached-subtree">(false);
auto restoreWhenScopeEnds =
setRuntimeParameterForTest<"zero-cost-estimate-for-cached-subtree">(
false);
auto qet = makeQet();
EXPECT_EQ(qet->getCacheKey(), qet->getRootOperation()->getCacheKey());
EXPECT_EQ(qet->getSizeEstimate(), 24u);
Expand Down

0 comments on commit bed12e4

Please sign in to comment.