@@ -7306,7 +7306,7 @@ void TSchemeShard::Handle(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr&
73067306 StatisticsAggregatorId = TTabletId (entry.DomainInfo ->Params .GetStatisticsAggregator ());
73077307 LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
73087308 " Handle TEvTxProxySchemeCache::TEvNavigateKeySetResult, StatisticsAggregatorId=" << StatisticsAggregatorId
7309- << " , at schemeshard: " << TabletID ());
7309+ << " , at schemeshard: " << TabletID ());
73107310 ConnectToSA ();
73117311 }
73127312}
@@ -7315,13 +7315,16 @@ void TSchemeShard::Handle(TEvPrivate::TEvSendBaseStatsToSA::TPtr&, const TActorC
73157315 TDuration delta = SendBaseStatsToSA ();
73167316 LOG_DEBUG_S (TlsActivationContext->AsActorContext (), NKikimrServices::STATISTICS,
73177317 " Schedule next SendBaseStatsToSA in " << delta
7318- << " , at schemeshard: " << TabletID ());
7318+ << " , at schemeshard: " << TabletID ());
73197319 ctx.Schedule (delta, new TEvPrivate::TEvSendBaseStatsToSA ());
73207320}
73217321
73227322void TSchemeShard::InitializeStatistics (const TActorContext& ctx) {
73237323 ResolveSA ();
7324- ctx.Schedule (TDuration::Seconds (30 ), new TEvPrivate::TEvSendBaseStatsToSA ());
7324+ // since columnshard statistics is now sent once in a minute,
7325+ // we expect that in most cases we will gather full stats
7326+ // before sending them to StatisticsAggregator
7327+ ctx.Schedule (TDuration::Seconds (120 ), new TEvPrivate::TEvSendBaseStatsToSA ());
73257328}
73267329
73277330void TSchemeShard::ResolveSA () {
@@ -7395,30 +7398,56 @@ TDuration TSchemeShard::SendBaseStatsToSA() {
73957398 }
73967399
73977400 int count = 0 ;
7401+ bool areAllStatsFull = true ;
73987402
73997403 NKikimrStat::TSchemeShardStats record;
74007404 for (const auto & [pathId, tableInfo] : Tables) {
7401- const auto & aggregated = tableInfo->GetStats ().Aggregated ;
7405+ const auto & stats = tableInfo->GetStats ();
7406+ const auto & aggregated = stats.Aggregated ;
7407+ bool areStatsFull = stats.AreStatsFull ();
7408+
74027409 auto * entry = record.AddEntries ();
74037410 auto * entryPathId = entry->MutablePathId ();
74047411 entryPathId->SetOwnerId (pathId.OwnerId );
74057412 entryPathId->SetLocalId (pathId.LocalPathId );
7406- entry->SetRowCount (aggregated.RowCount );
7407- entry->SetBytesSize (aggregated.DataSize );
7413+ entry->SetRowCount (areStatsFull ? aggregated.RowCount : 0 );
7414+ entry->SetBytesSize (areStatsFull ? aggregated.DataSize : 0 );
74087415 entry->SetIsColumnTable (false );
7416+ entry->SetAreStatsFull (areStatsFull);
7417+ areAllStatsFull = areAllStatsFull && areStatsFull;
7418+
74097419 ++count;
74107420 }
7421+
74117422 auto columnTablesPathIds = ColumnTables.GetAllPathIds ();
74127423 for (const auto & pathId : columnTablesPathIds) {
74137424 const auto & tableInfo = ColumnTables.GetVerified (pathId);
7414- const auto & aggregated = tableInfo->Stats .Aggregated ;
7425+ const auto & stats = tableInfo->GetStats ();
7426+ const TTableAggregatedStats* aggregatedStats = nullptr ;
7427+
7428+ // stats are stored differently for standalone and non-standalone column tables
7429+ if (tableInfo->IsStandalone ()) {
7430+ aggregatedStats = &stats;
7431+ } else {
7432+ auto it = stats.TableStats .find (pathId);
7433+ if (it == stats.TableStats .end ()) {
7434+ continue ;
7435+ }
7436+ aggregatedStats = &it->second ;
7437+ }
7438+ const auto & aggregated = aggregatedStats->Aggregated ;
7439+ bool areStatsFull = aggregatedStats->AreStatsFull ();
7440+
74157441 auto * entry = record.AddEntries ();
74167442 auto * entryPathId = entry->MutablePathId ();
74177443 entryPathId->SetOwnerId (pathId.OwnerId );
74187444 entryPathId->SetLocalId (pathId.LocalPathId );
7419- entry->SetRowCount (aggregated.RowCount );
7420- entry->SetBytesSize (aggregated.DataSize );
7445+ entry->SetRowCount (areStatsFull ? aggregated.RowCount : 0 );
7446+ entry->SetBytesSize (areStatsFull ? aggregated.DataSize : 0 );
74217447 entry->SetIsColumnTable (true );
7448+ entry->SetAreStatsFull (areStatsFull);
7449+ areAllStatsFull = areAllStatsFull && areStatsFull;
7450+
74227451 ++count;
74237452 }
74247453
@@ -7429,8 +7458,9 @@ TDuration TSchemeShard::SendBaseStatsToSA() {
74297458 return TDuration::Seconds (30 );
74307459 }
74317460
7461+ record.SetAreAllStatsFull (areAllStatsFull);
7462+
74327463 TString stats;
7433- stats.clear ();
74347464 Y_PROTOBUF_SUPPRESS_NODISCARD record.SerializeToString (&stats);
74357465
74367466 auto event = std::make_unique<NStat::TEvStatistics::TEvSchemeShardStats>();
0 commit comments