@@ -1229,14 +1229,7 @@ static auto fastForwardType(AqlCall const& call, Executor const& e) -> FastForwa
1229
1229
}
1230
1230
// TODO: We only need to do this is the executor actually require to call.
1231
1231
// e.g. Modifications will always need to be called. Limit only if it needs to report fullCount
1232
- if constexpr (is_one_of_v<Executor, LimitExecutor, ModificationExecutor<AllRowsFetcher, InsertModifier>,
1233
- ModificationExecutor<SingleRowFetcher<BlockPassthrough::Disable>, InsertModifier>,
1234
- ModificationExecutor<AllRowsFetcher, RemoveModifier>,
1235
- ModificationExecutor<SingleRowFetcher<BlockPassthrough::Disable>, RemoveModifier>,
1236
- ModificationExecutor<AllRowsFetcher, UpdateReplaceModifier>,
1237
- ModificationExecutor<SingleRowFetcher<BlockPassthrough::Disable>, UpdateReplaceModifier>,
1238
- ModificationExecutor<AllRowsFetcher, UpsertModifier>,
1239
- ModificationExecutor<SingleRowFetcher<BlockPassthrough::Disable>, UpsertModifier>>) {
1232
+ if constexpr (std::is_same_v<Executor, LimitExecutor> || executorHasSideEffects<Executor>) {
1240
1233
return FastForwardVariant::EXECUTOR;
1241
1234
}
1242
1235
return FastForwardVariant::FETCHER;
@@ -1676,6 +1669,16 @@ ExecutionBlockImpl<Executor>::executeWithoutTrace(AqlCallStack stack) {
1676
1669
case ExecState::CHECKCALL: {
1677
1670
LOG_QUERY (" cfe46" , DEBUG)
1678
1671
<< printTypeInfo () << " determine next action on call " << clientCall;
1672
+
1673
+ if constexpr (executorHasSideEffects<Executor>) {
1674
+ // If the executor has sideEffects, and we need to skip the results we would
1675
+ // produce here because we actually skip the subquery, we instead do a
1676
+ // hardLimit 0 (aka FastForward) call instead to the local Executor
1677
+ if (stack.needToSkipSubquery ()) {
1678
+ _execState = ExecState::FASTFORWARD;
1679
+ break ;
1680
+ }
1681
+ }
1679
1682
_execState = nextState (clientCall);
1680
1683
break ;
1681
1684
}
@@ -1830,8 +1833,25 @@ ExecutionBlockImpl<Executor>::executeWithoutTrace(AqlCallStack stack) {
1830
1833
case ExecState::FASTFORWARD: {
1831
1834
LOG_QUERY (" 96e2c" , DEBUG)
1832
1835
<< printTypeInfo () << " all produced, fast forward to end up (sub-)query." ;
1836
+ AqlCall callCopy = clientCall;
1837
+ if constexpr (executorHasSideEffects<Executor>) {
1838
+ if (stack.needToSkipSubquery ()) {
1839
+ // Fast Forward call.
1840
+ callCopy = AqlCall{0 , false , 0 , AqlCall::LimitType::HARD};
1841
+ }
1842
+ }
1833
1843
auto [state, stats, skippedLocal, call, dependency] =
1834
- executeFastForward (_lastRange, clientCall);
1844
+ executeFastForward (_lastRange, callCopy);
1845
+ if constexpr (executorHasSideEffects<Executor>) {
1846
+ if (!stack.needToSkipSubquery ()) {
1847
+ // We need to modify the original call.
1848
+ clientCall = callCopy;
1849
+ }
1850
+ // else: We are bypassing the results.
1851
+ // Do not count them here.
1852
+ } else {
1853
+ clientCall = callCopy;
1854
+ }
1835
1855
1836
1856
_requestedDependency = dependency;
1837
1857
_skipped.didSkip (skippedLocal);
0 commit comments