@@ -298,10 +298,9 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
298
298
batch.Proto = std::move (*computeData.Proto .MutableChannelData ()->MutableData ());
299
299
batch.Payload = std::move (computeData.Payload );
300
300
301
- TKqpProtoBuilder protoBuilder{*AppData ()->FunctionRegistry };
302
- auto resultSet = protoBuilder.BuildYdbResultSet (std::move (batches), txResult.MkqlItemType , txResult.ColumnOrder , txResult.ColumnHints );
303
-
304
301
if (!trailingResults) {
302
+ TKqpProtoBuilder protoBuilder{*AppData ()->FunctionRegistry };
303
+ auto resultSet = protoBuilder.BuildYdbResultSet (std::move (batches), txResult.MkqlItemType , txResult.ColumnOrder , txResult.ColumnHints );
305
304
auto streamEv = MakeHolder<TEvKqpExecuter::TEvStreamData>();
306
305
streamEv->Record .SetSeqNo (computeData.Proto .GetSeqNo ());
307
306
streamEv->Record .SetQueryResultIndex (*txResult.QueryResultIndex + StatementResultIndex);
@@ -319,10 +318,11 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
319
318
ackEv->Record .SetChannelId (channel.Id );
320
319
ackEv->Record .SetFreeSpace (50_MB);
321
320
this ->Send (channelComputeActorId, ackEv.Release (), /* TODO: undelivery */ 0 , /* cookie */ channel.Id );
322
- txResult.TrailingResult .Swap (&resultSet);
321
+ ui64 rowCount = batch.RowCount ();
322
+ ResponseEv->TakeResult (channel.DstInputIndex , std::move (batch));
323
323
txResult.HasTrailingResult = true ;
324
324
LOG_D (" staging TEvStreamData to " << Target << " , seqNo: " << computeData.Proto .GetSeqNo ()
325
- << " , nRows: " << txResult. TrailingResult . rows (). size () );
325
+ << " , nRows: " << rowCount );
326
326
}
327
327
328
328
return ;
@@ -828,7 +828,7 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
828
828
std::map<ui32, TStageScheduleInfo> result;
829
829
if (!resourceSnapshot.empty ()) // can't schedule w/o node count
830
830
{
831
- // collect costs and schedule stages with external sources only
831
+ // collect costs and schedule stages with external sources only
832
832
double totalCost = 0.0 ;
833
833
for (ui32 stageIdx = 0 ; stageIdx < tx.Body ->StagesSize (); ++stageIdx) {
834
834
auto & stage = tx.Body ->GetStages (stageIdx);
@@ -843,11 +843,11 @@ class TKqpExecuterBase : public TActorBootstrapped<TDerived> {
843
843
if (!result.empty ()) {
844
844
// allow use 2/3 of threads in single stage
845
845
ui32 maxStageTaskCount = (TStagePredictor::GetUsableThreads () * 2 + 2 ) / 3 ;
846
- // total limit per mode is x2
846
+ // total limit per mode is x2
847
847
ui32 maxTotalTaskCount = maxStageTaskCount * 2 ;
848
848
for (auto & [_, stageInfo] : result) {
849
849
// schedule tasks evenly between nodes
850
- stageInfo.TaskCount =
850
+ stageInfo.TaskCount =
851
851
std::max<ui32>(
852
852
std::min (static_cast <ui32>(maxTotalTaskCount * stageInfo.StageCost / totalCost), maxStageTaskCount)
853
853
, 1
0 commit comments