From f193e16a018bcb2bebb16bcb4d1593ff13910f00 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 4 May 2022 16:44:06 +0200 Subject: [PATCH] Refrain reading the metadata cache for all tables during upgrade First, it is not needed. Second, in the past we had issues regarding this: https://github.com/citusdata/citus/pull/4344 When I create 10k tables, ~120K shards, this saves 40Mb of memory during ALTER EXTENSION citus UPDATE. Before the change: MetadataCacheMemoryContext: 41943040 ~ 40MB After the change: MetadataCacheMemoryContext: 8192 --- src/backend/distributed/commands/extension.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/commands/extension.c b/src/backend/distributed/commands/extension.c index e61d62054..e4b720b4c 100644 --- a/src/backend/distributed/commands/extension.c +++ b/src/backend/distributed/commands/extension.c @@ -513,7 +513,8 @@ MarkExistingObjectDependenciesDistributedIfSupported() ObjectAddress tableAddress = { 0 }; ObjectAddressSet(tableAddress, RelationRelationId, citusTableId); - if (ShouldSyncTableMetadata(citusTableId)) + /* refrain reading the metadata cache for all tables */ + if (ShouldSyncTableMetadataViaCatalog(citusTableId)) { /* we need to pass pointer allocated in the heap */ ObjectAddress *addressPointer = palloc0(sizeof(ObjectAddress));