diff --git a/src/engine/IndexScan.cpp b/src/engine/IndexScan.cpp index 5554bb62b8..f56123a42b 100644 --- a/src/engine/IndexScan.cpp +++ b/src/engine/IndexScan.cpp @@ -594,14 +594,14 @@ Result::Generator IndexScan::createPrefilteredJoinSide( } auto& prefetchedValues = innerState->prefetchedValues_; while (true) { - while (prefetchedValues.empty()) { + if (prefetchedValues.empty()) { if (innerState->doneFetching_) { co_return; } innerState->fetch(); + AD_CORRECTNESS_CHECK(!prefetchedValues.empty() || + innerState->doneFetching_); } - AD_CORRECTNESS_CHECK(!prefetchedValues.empty() || - innerState->doneFetching_); // Make a defensive copy of the values to avoid modification during // iteration when yielding. auto copy = std::move(prefetchedValues);