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 1u23Lf-00CBzP-Sr for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Apr 2025 07:26:20 +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 1u23Ld-006pbe-GH for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Apr 2025 07:26:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u23Ld-006pbV-6X for pgsql-hackers@lists.postgresql.org; Tue, 08 Apr 2025 07:26:17 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u23Lb-0045Id-0q for pgsql-hackers@lists.postgresql.org; Tue, 08 Apr 2025 07:26:17 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43ef83a6bfaso27325e9.1 for ; Tue, 08 Apr 2025 00:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744097174; x=1744701974; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PHNDUY62ORLj18RgR4CyLz7b9S/nytskrhGUe108lb0=; b=PrBdURIFvPDMr6kkrlxlzZHUQDAx5XVpiAOB+Ysgi02xrV9rfductfhfsS+iuSAd4v zVDdJ/BjBQ3Rw4IswQSJfe2VAP7S5JVuJhbfOAZGJtNc8Lh+vlYft3MOXL8wiOvfztOO qdMnqnwWSvWwFMC/MQ9q/Wlvy9RGTLEFW1yBQHD0EywxesC3lXv3jXyw0tsv/Ko8jfZH 5ff8/omPhbI6P/L8F7znpBsqVhwueyLxnm1Y2Cm/IxHBe1zo2f4jhy4x0Okca4a+jHph QebVWwP2KB66gXKyh0GI+nQZRe/HHoq+XpOcLBUPk/BVQLATiFeYK7Xv99RdovBURVy9 7WJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744097174; x=1744701974; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PHNDUY62ORLj18RgR4CyLz7b9S/nytskrhGUe108lb0=; b=j7kDkfWduMpsRDAfl26SoKNT9xGbhgnhMw2EIdS/R3DHC94mD3panS/+5vziDQATNU XCKuZnYB/3jof0H1eSNJAdtO/s9sAXg0eH9wTFhSOBxL9YzXKTS4BrtKNWURMJ/Kx5Ot prC0uI0Bgaz2XTvezQ/Evg55oB1778b810ewsdlrQ8cpc6ioBhyIf+ax+X82cdPgCgbf Hs5e7V46LAqV1iT2w8qaAalp0NK/LltP2mLSHM7dm1W0RATZq2QlOZb2EZnPy5KkRVQ4 Jc7ZiwplWHltkN+iSOyNC2t8JjY8HFwnaB3QiP/UTYBrP0kYxKYzwbMz5CBp9fCElQpF J2KA== X-Forwarded-Encrypted: i=1; AJvYcCVAyA1JdWKHZlbPw3zh+BNJKzgzB3T0LU1iYPQSJIdUs3jPu8s8097Umb3T1SjdB3jvBINYoHBhTJVnfL7l@lists.postgresql.org X-Gm-Message-State: AOJu0Yz+h4ImJom6p/6vSXrQvCtEv8sWXu6c612/DN+JGl87hxu5LvP/ kgLVBMKyLhiZaVkiGPZTm1RjTlYBfGgGcGj5ux3dMTrtbs+SDKkqb3Vod/reNhTdYQF6wJ6TN6d XoAzf2XVdEjYzvFFEC/dV4GH8Lo4CWU5o42cx X-Gm-Gg: ASbGncsaIYQgodiGAIjvmeSEUsdO3BwLLSA/79WhjqzaxVrjtMQSBYPhKfpZ6uaKKmj rxkIM4oeB2hK5kYL4YVAhU4/32mIkuT6vbB1uocN6QBv/W+FlnVvBv5IJ1WdEoVoCjjgcUVlio9 7Koyq1QKdGUFLYBaMTVVJx/728zQ== X-Google-Smtp-Source: AGHT+IFA3O9AXggoMqrSdHLBcgtS83o+FrO8NIOjn+RQOHVMej7X2gf8usBslp/8vi0f7z4EMpQ0NEWDIRal/UUVJiU= X-Received: by 2002:a05:600c:3c82:b0:43d:409c:6142 with SMTP id 5b1f17b1804b1-43f105ca9demr896745e9.0.1744097173658; Tue, 08 Apr 2025 00:26:13 -0700 (PDT) MIME-Version: 1.0 References: <3681760.1744061132@sss.pgh.pa.us> In-Reply-To: From: Hannu Krosing Date: Tue, 8 Apr 2025 09:26:02 +0200 X-Gm-Features: ATxdqUFM45MliWdL0sdi7TRgljXRc52IVbTz1fFivlTFTX4WvdVS0qkAl3C5SuY Message-ID: Subject: Re: Horribly slow pg_upgrade performance with many Large Objects To: Michael Paquier Cc: Tom Lane , PostgreSQL Hackers , Nathan Bossart Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Looked like a bit illogical order on re-reading it so I want to make clear that the pg_upgrade-like test showing 100min for 100 million LOs is at the end of last message and the proposed solution is at the beginning On Tue, Apr 8, 2025 at 9:15=E2=80=AFAM Hannu Krosing wr= ote: > > I was testing on version 17 > > > On Tue, Apr 8, 2025 at 6:52=E2=80=AFAM Michael Paquier wrote: > > > > On Mon, Apr 07, 2025 at 05:25:32PM -0400, Tom Lane wrote: > > > What version are you testing? We did some work in that area in the > > > v17 cycle (a45c78e32). > > > > I am puzzled by the target version used here, as well. > > I was testing on version 17 > > Here is how you can easily test too (as --binary-upgrade does not dump > the actual data it is ok for the test to not put anything there) > > hannuk@db01-c1a:~/work/lo-testing$ createdb -p 5433 lodb > hannuk@db01-c1a:~/work/lo-testing$ psql -p 5433 lodb > psql (17.4 (Ubuntu 17.4-1.pgdg22.04+2)) > Type "help" for help. > > lodb=3D# insert into pg_largeobject_metadata(oid, lomowner) SELECT i, > 16384 FROM generate_series(1, 100_000_000) g(i); > INSERT 0 100000000 > Time: 162414.216 ms (02:42.414) > lodb=3D# > \q > > hannuk@db01-c1a:~/work/lo-testing$ time pg_dump --data-only -t > pg_largeobject_metadata -p 5433 lodb | gzip > > pg_largeobject_metadata.data.gz > real 0m22.094s > user 0m20.741s > sys 0m2.085s > > hannuk@db01-c1a:~/work/lo-testing$ time pg_dump --data-only -t > pg_largeobject_metadata --format=3Dcustom -p 5433 lodb -f > pg_largeobject_metadata.dump > real 0m20.226s > user 0m18.068s > sys 0m0.824s > > > If there is > > more that can be improved, v19 would be the version to consider for > > future improvements at this stage. > > If the internal format has changed in 16 the correct way would be to > go through the data-only dump of pg_largeobject_metadata in all cases. > Even for the 100M case where you get the restore in 2 minutes instead > of 100 minutes > > hannuk@db01-c1a:~/work/lo-testing$ createdb -p 5434 lodb > hannuk@db01-c1a:~/work/lo-testing$ time pg_restore -p 5434 > --exit-on-error --transaction-size=3D1000 --dbname lodb > pg_largeobject_metadata.dump > > real 2m2.277s > user 0m2.594s > sys 0m0.549s > > And even in case of the user-visible format change in acl format it is > most likely that changing the visible format using some regexp magic, > or even a dedicated function, would still me much faster than creating > all the LOs though creation commands. > > ------ > The commands I used to do the pg_upgrade-like test were > > hannuk@db01-c1a:~/work/lo-testing$ time pg_dump --schema-only > --quote-all-identifiers --binary-upgrade --format=3Dcustom > --file=3Dlodb100m.dump -p 5433 lodb > real 1m58.241s > user 0m35.229s > sys 0m17.854s > > hannuk@db01-c1a:~/work/lo-testing$ time pg_restore -p 5434 > --exit-on-error --transaction-size=3D1000 --dbname lodb lodb100m.dump > real 100m54.878s > user 3m23.885s > sys 20m33.761s > > (I left out the --verbose part that pg_upgrade also sets as I did not > want to get 100M lines of "large object created " messages ) > > also the postgres server at -p 5434 needs to be started with -b flag > to accept the loading a dump from --binary-upgrade. In Debian/Ubuntu > this can be directly passed to pg_ctlcluster as follows > > sudo pg_ctlcluster 17 target -o -b > > ---- > Hannu > > > > > > -- > > Michael