diff --git a/alternator/streams.cc b/alternator/streams.cc index b03cda0437..43d73e9a71 100644 --- a/alternator/streams.cc +++ b/alternator/streams.cc @@ -1023,8 +1023,8 @@ future executor::get_records(client_state& client // ugh. figure out if we are and end-of-shard auto normal_token_owners = _proxy.get_token_metadata_ptr()->count_normal_token_owners(); - - return _sdks.cdc_current_generation_timestamp({ normal_token_owners }).then([this, iter, high_ts, start_time, ret = std::move(ret)](db_clock::time_point ts) mutable { + + return _sdks.cdc_current_generation_timestamp({ normal_token_owners }).then([this, iter, high_ts, start_time, ret = std::move(ret), nrecords](db_clock::time_point ts) mutable { auto& shard = iter.shard; if (shard.time < ts && ts < high_ts) { @@ -1041,6 +1041,10 @@ future executor::get_records(client_state& client rjson::add(ret, "NextShardIterator", iter); } _stats.api_operations.get_records_latency.add(std::chrono::steady_clock::now() - start_time); + // TODO: determine a better threshold... + if (nrecords > 10) { + return make_ready_future(make_streamed(std::move(ret))); + } return make_ready_future(make_jsonable(std::move(ret))); }); });