Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUuSu-006aoe-9Y for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 20:44:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sUuSp-005lnn-Sl for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 20:44:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUuSp-005lnf-Gy for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 20:44:27 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sUuSn-000Qpy-Bf for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 20:44:26 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-819c1f53617so37266439f.2 for ; Fri, 19 Jul 2024 13:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721421864; x=1722026664; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BJNRiI9adSHfdcGCVCKVe55EdyEO+XTltZ/2j3GwOos=; b=I8OmX/4J1R8nUYXskO+GLg7evkELhZ4qkAXPqWvOHukT+soF7hHpH6WRLo/hStCXl4 xnIn0IfV2PcyEupBs+mJ/JvVA7XlR3YJEEFDcw1eUSjpHXREy0PeKmtIliVcZ71CMfBU aQi5SR/AEcNh1WoOPlSSR/0NYFrbgtMgfLJ5DVSONqAC26tc1k5ZY+EQ75wTEHzBBUj0 c+359VNXRiI+VXE27CoGHFxPowem+Qwtgw9rvWJPJh7Aff6fN8yjZSV6dkuxEjskb+et sGXv39C9SUUngqiogw3SFkIZ4iabqSkdNkZqa26mWRIQErxfED4WgNwalU/X4DCs5uuj 5l+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721421864; x=1722026664; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BJNRiI9adSHfdcGCVCKVe55EdyEO+XTltZ/2j3GwOos=; b=CWdmXF2hndFb0z1EfmwfZs8uLJLX4GwNeqL19I2E/w3UNQLGQIFX5OBQReyyr3hXbf uEhDHsbMc9iuUNmSOffeuZeId99zZnJX//j3GXDXnFEwftekoiGNVrE4F4maP05P93Ww SZsg4K6pk9EsliLxV2WW3dyAUC7rITxW6AqpN4ZRQo2RnidzaTDmWYKHXmzEwbKq1Yjc 3osklPK5fT2M4CJHWQmLLHqgZWVxYHT4P/DnCcW3NfrawGagNWr89tBx61q85bhwoHqn T5cZWdhOJnJ+Aixmxa45y1cR6aOJec4IGzYqeGhNzYy0yIe4JSiclB0uc1HN2WsF5ocw /j+w== X-Forwarded-Encrypted: i=1; AJvYcCWiWuiCnevrRtRdpsWuEmbxdxfkokK7oV6IZu+yzStmBm+Ryl4LO0rBb9opo69GtEZGKC3csAxrcuY4RvxYQ8le/mTPhhnrwI8itxCDCeEhDQCC X-Gm-Message-State: AOJu0YzmGWqqPSPgf8EAZbMi2F8HDspOTyfSS9XJ7lb74wHsUbQUC4tP qX7r4vlr7nAmUvRscqy2+K2zLXQfMlVEW8tg1Y6DUq8wHJcd2jXe X-Google-Smtp-Source: AGHT+IGY+i0YyEaNaqkYioCJ6N98LZmWm8oyQa7GG+VtqonJ4bu/TeJky1C0/rZKwkgYI3P04ixIyw== X-Received: by 2002:a05:6602:6422:b0:7fa:d16f:82f7 with SMTP id ca18e2360f4ac-817123e1a47mr1082834939f.19.1721421864489; Fri, 19 Jul 2024 13:44:24 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-819ad823f84sm67263339f.42.2024.07.19.13.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 13:44:24 -0700 (PDT) Date: Fri, 19 Jul 2024 15:44:22 -0500 From: Nathan Bossart To: Amit Kapila Cc: vignesh C , "Hayato Kuroda (Fujitsu)" , Justin Pryzby , Masahiko Sawada , Michael Paquier , Peter Smith , Julien Rouhaud , "pgsql-hackers@lists.postgresql.org" Subject: Re: pg_upgrade and logical replication Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I've been looking into optimizing pg_upgrade's once-in-each-database steps [0], and I noticed that we are opening a connection to every database in the cluster and running a query like SELECT count(*) FROM pg_catalog.pg_subscription WHERE subdbid = %d; Then, later on, we combine all of these values in count_old_cluster_subscriptions() to verify that max_replication_slots is set high enough. AFAICT these per-database subscription counts aren't used for anything else. This is an extremely expensive way to perform that check, and so I'm wondering why we don't just do SELECT count(*) FROM pg_catalog.pg_subscription; once in count_old_cluster_subscriptions(). [0] https://commitfest.postgresql.org/48/4995/ -- nathan