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 1u23Bj-00C9h5-7R for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Apr 2025 07:16:03 +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 1u23Bh-006nKc-AR for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Apr 2025 07:16:01 +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 1u23Bg-006nKU-Uj for pgsql-hackers@lists.postgresql.org; Tue, 08 Apr 2025 07:16:01 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u23Be-0045EQ-34 for pgsql-hackers@lists.postgresql.org; Tue, 08 Apr 2025 07:16:00 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-43d5f10e1aaso40815e9.0 for ; Tue, 08 Apr 2025 00:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744096557; x=1744701357; 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=sSPtkMOFQOVYnm5ot8W6vtn5IEn7molCu8UYGIQdUlo=; b=VX01wp78nChKo8Ayng7FvtEznkYwc0/AX+Hw0IodNQ/rwtQLHaIYqMMngvRPqvykt3 lJwdg5iaeJt8YOl76zsqWU5p8Y65md3JjtUO7qa/XiKuKAA4P/jD/bQjxUp+vCQWrg68 g/YyENEG49NXnGWfTuJlSSw1KCrIbpBpDfb2FF5RX7BS+4rhgbREpaAqFpqya3B86jzG +emddTF9g3GzkNcVUoiOS53VVM3HYSvMue0Lvx/SK+pD1swvJGBj4EWJ5BR4U8U3PN/e NP3mZG4ZEMYIbqRZaAZWbaFNXvRpi9Hs+3mMDcAbkc1srBZ8+wJi3zYeW3B01hbk496i kRkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744096557; x=1744701357; 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=sSPtkMOFQOVYnm5ot8W6vtn5IEn7molCu8UYGIQdUlo=; b=sekhO5U7uxFoOc0jkvqDkWPrhk6koGsPc5n3HFpPm51QPPa3jl4NqCnDJwTveRsB8K jNpCTAlDwwC5u7phI6hTdycy+77J8cOC2LLg8tHsna7OOBidE+yNC7259wuzJzVia2k2 HQtorxXIdn3UVFrw5LXELsVhtFTMu/ryNKh5N/vqsEARjIeuWGNJUcwygOUYKhvs9Hk3 6KcXwzjIwgxVmoUA4LfyUKssRbCm/ozjKbqZjzF48tKNL7FBrPjdV8OCmp9m9FQ8KX2q Tq9oaayOdYz9gaS9Q0b9vNDSB32YcrMs8xEmzrj42fDxZpNMBAqQNXHrxp0R/vVn6KqV IwJQ== X-Forwarded-Encrypted: i=1; AJvYcCU8LttwnlcEIeCkQMjO40BB3PCXzmG5S5Ew6vWuL7rmW/o/YDyjcHAuUWlKYIF6EXlAnkXZzCAl4K+z37lu@lists.postgresql.org X-Gm-Message-State: AOJu0YyLDlUxQQqOG/qpnTWF1wbvBwySjtVVXg5eWc0hsVHkdA4HgBR9 xwvTdq00EiHUA6mkn8WLruQJvJLdGeMw/xPEq1FdaE9ANzJkepJh13/9y7WXYa1yH0F9cFq0xiR ZbMbnrmiT68zg3J1b3KKGIxMYUcBvBX1E63iE X-Gm-Gg: ASbGnctve+Cfo7M9iWZ2XgI3r7PAJsGZ6pllqpqjqN+QQ5Vz4+jnrlskGXBAM63AFOf 5lZcy/DJAZuk+iGfiw8otUx0HkQUha+zWIeigHh61W2iqzLMO0f49K4Z4nd0D720Z8SOEkqYv3h 1+a95ryVBgp8HxHmfXi8t3H0EBUA== X-Google-Smtp-Source: AGHT+IFQxhXgVgj1NA2bMH1I22WZ2GkqXOd7U14yTME98CQO/ee1llv7A3zst6tiCSTVlMt/1zv5rGhoGaSYswBNN9U= X-Received: by 2002:a05:600c:46d5:b0:43d:5b3a:18cc with SMTP id 5b1f17b1804b1-43f10788245mr784065e9.2.1744096556362; Tue, 08 Apr 2025 00:15:56 -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:15:45 +0200 X-Gm-Features: ATxdqUGVMnf9Tcm0lNucPy1F46m9zj0b0iLMMsllCKKrjJstVEZzTb-eVNZkCrM 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 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