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 1rxM8y-007unS-Kk for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 07:25:17 +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 1rxM8w-001lGB-P3 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 07:25:14 +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 1rxM8w-001lBE-CE for pgsql-hackers@lists.postgresql.org; Thu, 18 Apr 2024 07:25:14 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rxM8q-003PxQ-L1 for pgsql-hackers@postgresql.org; Thu, 18 Apr 2024 07:25:13 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 5DDD4300E6E0 for ; Thu, 18 Apr 2024 09:25:05 +0200 (CEST) Received: from s899.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 4ED352E27F4E; Thu, 18 Apr 2024 09:25:05 +0200 (CEST) Received: from s474.loopia.se (unknown [172.22.191.6]) by s899.loopia.se (Postfix) with ESMTP id 4A79C2C8BA62; Thu, 18 Apr 2024 09:25:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.21 X-Spam-Level: X-Spam-Status: No, score=-1.21 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=disabled Authentication-Results: s474.loopia.se (amavisd-new); dkim=pass (2048-bit key) header.d=yesql.se Received: from s980.loopia.se ([172.22.191.6]) by s474.loopia.se (s474.loopia.se [172.22.190.14]) (amavisd-new, port 10024) with LMTP id FSEo6SCFJGKC; Thu, 18 Apr 2024 09:25:04 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s980.loopia.se (Postfix) with ESMTPSA id A31B9220165F; Thu, 18 Apr 2024 09:25:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yesql.se; s=loopiadkim1707475645; t=1713425104; bh=Nf8nS8cxpSZL4TDrx06r2b/7BVy+1wbachBhtnEeJG0=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=fh85lDAReChsHeJ6qJnPYSWdU3CiVbGwMXdBOa+gv0241X6GVj08GD1m+TGdj98E3 op6IIMrZwFagWw/QM534VzyUq44LyAZaoL2xlFLNMOw8/q2wvfanKp+LYdU1YBPiSV 3GpIf0w1f+BB0CZgMx21CEO000i9VS8tFvzoVGsr3lMvk9U8iFqfH9R51gvoPTYu16 zqPKmcYaj7uXw+mZwDCbEjPp3owmSNEKVbcBgXOd9xUSeb2UZfb/vswBZZTms8Btff HV1MnUXSIVO6LSXS2KtWGHjY0s6Fq2AqNK3JUOzjl5jXJYngzN1AuwYYUWcgZT1nOZ Gzk1I1bVAAZxg== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: improve performance of pg_dump --binary-upgrade From: Daniel Gustafsson In-Reply-To: <20240418041712.GA3441570@nathanxps13> Date: Thu, 18 Apr 2024 09:24:53 +0200 Cc: PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <20240418041712.GA3441570@nathanxps13> To: Nathan Bossart X-Mailer: Apple Mail (2.3774.500.171.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 18 Apr 2024, at 06:17, Nathan Bossart = wrote: > The attached work-in-progress patch speeds up 'pg_dump = --binary-upgrade' > for this case. Instead of executing the query in every call to the > function, we can execute it once during the first call and store all = the > required information in a sorted array that we can bsearch() in future > calls. That does indeed seem like a saner approach. Since we look up the = relkind we can also remove the is_index parameter to = binary_upgrade_set_pg_class_oids since we already know that without the caller telling us? > One downside of this approach is the memory usage. I'm not too worried about the worst-case performance of this. > This was more-or-less > the first approach that crossed my mind, so I wouldn't be surprised if > there's a better way. I tried to keep the pg_dump output the same, = but if > that isn't important, maybe we could dump all the pg_class OIDs at = once > instead of calling binary_upgrade_set_pg_class_oids() for each one. Without changing the backend handling of the Oid's we can't really do = that AFAICT, the backend stores the Oid for the next call so it needs to be = per relation like now? For Greenplum we moved this to the backend by first dumping all Oids = which were read into backend cache, and during relation creation the Oid to use was = looked up in the backend. (This wasn't a performance change, it was to allow = multiple shared-nothing clusters to have a unified view of Oids, so I never = benchmarked it all that well.) The upside of that is that the magic Oid variables in = the backend can be removed, but it obviously adds slight overhead in others. -- Daniel Gustafsson