Skip to content

Commit 66b9521

Browse files
authored
Optimize size of PQTabletConfig (#9375)
1 parent fe04aee commit 66b9521

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

ydb/core/protos/pqconfig.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ message TPQTabletConfig {
426426
}
427427
optional TPartitionStrategy PartitionStrategy = 35;
428428

429+
// The field is filled in only for the PQ tablet. Contains information about linked partitions for constructing a partial PartitionGraph.
429430
repeated TPartition AllPartitions = 36; // filled by schemeshard
430431

431432
optional TOffloadConfig OffloadConfig = 38;

ydb/core/tx/schemeshard/schemeshard__operation_common.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,20 +928,37 @@ class TConfigureParts: public TSubOperationState {
928928
config.SetVersion(pqGroup.AlterData->AlterVersion);
929929
}
930930

931+
THashSet<ui32> linkedPartitions;
932+
931933
for(const auto& pq : pqShard.Partitions) {
932934
config.AddPartitionIds(pq->PqId);
933935

934936
auto& partition = *config.AddPartitions();
935937
FillPartition(partition, pq.Get(), 0);
938+
939+
linkedPartitions.insert(pq->PqId);
940+
linkedPartitions.insert(pq->ParentPartitionIds.begin(), pq->ParentPartitionIds.end());
941+
linkedPartitions.insert(pq->ChildPartitionIds.begin(), pq->ChildPartitionIds.end());
942+
for (auto c : pq->ChildPartitionIds) {
943+
auto it = pqGroup.Partitions.find(c);
944+
if (it == pqGroup.Partitions.end()) {
945+
continue;
946+
}
947+
linkedPartitions.insert(it->second->ParentPartitionIds.begin(), it->second->ParentPartitionIds.end());
948+
}
936949
}
937950

938-
for(const auto& p : pqGroup.Shards) {
939-
const auto& pqShard = p.second;
940-
const auto& tabletId = context.SS->ShardInfos[p.first].TabletID;
941-
for (const auto& pq : pqShard->Partitions) {
942-
auto& partition = *config.AddAllPartitions();
943-
FillPartition(partition, pq.Get(), ui64(tabletId));
951+
for(auto lp : linkedPartitions) {
952+
auto it = pqGroup.Partitions.find(lp);
953+
if (it == pqGroup.Partitions.end()) {
954+
continue;
944955
}
956+
957+
auto* partitionInfo = it->second;
958+
const auto& tabletId = context.SS->ShardInfos[partitionInfo->ShardIdx].TabletID;
959+
960+
auto& partition = *config.AddAllPartitions();
961+
FillPartition(partition, partitionInfo, ui64(tabletId));
945962
}
946963
}
947964

ydb/core/tx/schemeshard/schemeshard_info_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,8 @@ struct TTopicTabletInfo : TSimpleRefCount<TTopicTabletInfo> {
959959
THashSet<ui32> ParentPartitionIds;
960960
THashSet<ui32> ChildPartitionIds;
961961

962+
TShardIdx ShardIdx;
963+
962964
void SetStatus(const TActorContext& ctx, ui32 value) {
963965
if (value >= NKikimrPQ::ETopicPartitionStatus::Active &&
964966
value <= NKikimrPQ::ETopicPartitionStatus::Deleted) {
@@ -1152,6 +1154,8 @@ struct TTopicInfo : TSimpleRefCount<TTopicInfo> {
11521154
TTopicStats Stats;
11531155

11541156
void AddPartition(TShardIdx shardIdx, TTopicTabletInfo::TTopicPartitionInfo* partition) {
1157+
partition->ShardIdx = shardIdx;
1158+
11551159
TTopicTabletInfo::TPtr& pqShard = Shards[shardIdx];
11561160
if (!pqShard) {
11571161
pqShard.Reset(new TTopicTabletInfo());

0 commit comments

Comments
 (0)