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.96) (envelope-from ) id 1w4vjQ-002hoF-33 for pgsql-docs@arkaria.postgresql.org; Tue, 24 Mar 2026 06:59:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4vjP-004sS2-02 for pgsql-docs@arkaria.postgresql.org; Tue, 24 Mar 2026 06:59:15 +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.96) (envelope-from ) id 1w4vjO-004sRt-2S for pgsql-docs@lists.postgresql.org; Tue, 24 Mar 2026 06:59:15 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4vjM-00000000plX-1jbY for pgsql-docs@lists.postgresql.org; Tue, 24 Mar 2026 06:59:14 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-486b96760easo8068785e9.2 for ; Mon, 23 Mar 2026 23:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1774335551; x=1774940351; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=fAYCwcJBfucDpTK8PVZOcFgiWrz9Cz3zvRqZALvtAig=; b=lwOvP7W2vWg+WzVtIaS7/rtLA5SHR06mZmrlDHzozWrFTT5ccOM92r1DUA7gnl327/ ghtyWKJCKLreY/m4OTJRV8yGDp3W3yAjgqorDBLwXtjYf/FV2VghZ9vzzPvmUJMtPj9T QuVPfpoPBEdgKExKprd+yl0mrCXIOAAot/CWsrY24YiEZUdoGSXHy0kv9rKTiDN1ghLu lcrv9KswCc73C6P3WQ9RIIZqNmNUZQEHKsYRmaC7BkrotFZOh+mUXl/Cl0o7WSHFuDCN cyvsqMnLT1nr5bK3VNzZwfsxYgK8D1S1EHGjcWCtbFKrXpEe4RVz4cAHrONEEUj9gF05 LbEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774335551; x=1774940351; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fAYCwcJBfucDpTK8PVZOcFgiWrz9Cz3zvRqZALvtAig=; b=ZDPVs6F1bWl5OlRkhaUGiGEIMemhJ/E3ZG8NIuFaV0B5mKhGUh6zV4SnbVtF3VajGh oBnqmxV7KkzbJJp6yFK03Wi5KILT1n5L/31DDKeDsnQovJnD82a3YzedWHMcRP78zzjh Y6cEVqI5jqSrZmg2lgBc7qapHfS6lOY2IYyq/7JCZgeCCMx2DDiUwSRLZr0kFSZg8EJs vS0lX5OxF4NBvOhaSsqRnG7OzJaGpzXso7JuhMfgiqIISxVteQVrvtmQ1FCwVmSQWAp+ x770wTb/bBfcgW/uOupHcBPlNEsdhhpvsjcQurSgQS94vMb6srIsNxVqOzgK1KitEzOJ XzIA== X-Forwarded-Encrypted: i=1; AJvYcCW37SwKc+n+tEWi+dpo2OeXm/HDO+nRAN88zVjoxDFnRI1jnlYruXwpmduLpQLdpFfPxrKxcEyQtyo2@lists.postgresql.org X-Gm-Message-State: AOJu0YwN4TCsonCqdE7WQZ3nsjJKiobc+Aca+9WlUTimp0p20rKZVOfT bFrpsJu97jkjIU9busmNPqGChrHWbPukCmpkEKuucBEAiU4rRSj5w0bBWUb+BCWHFJg= X-Gm-Gg: ATEYQzwetYZ0fbWAD7I9M5AHAYDW927V3jQeaGuh6plJR/wIuYmyR73SRFWh+Nv9O2D G25E0+JDXbZVBfWhCpcvTtqlhJlQKv0GTcJGm7Tnbq824zKOiFsQzONewCm6glCHD69ORXopgTm ajOhwu0h+7O4L+Po3YH4rFfIR43DXL1ZSevHHYxxJDBXwxputROrhFwDLDaob/zDk2H/eRbT1IH DKtloNmxAw4YqlW6uc2kCoA+zIF1wjCn88QMKYctS29dQw/KWfTgb5+dGIlzirH8BGJ0EpcRAnq sAaQzVs/ONKcNwy4IIwfWDZXb/iCeUFGhMEaFfC8BOf/VJfPUurVsXcDyn4DO6FFKeEqH49+xox LsukwilrJb5gLO7xsHcNn4rLcO1HNhjyJOLNmzRoM3BoPFLP0G1QwXA/17P526U6UzfYp5gF95z VxPQwKfc7o/DVX0k2gpwEISU7sL2Lo+0w/hBiMX46K4T/s66VuOxTrYfU= X-Received: by 2002:a05:600c:2d14:b0:487:2b7:18d1 with SMTP id 5b1f17b1804b1-48702b718demr95853995e9.33.1774335551395; Mon, 23 Mar 2026 23:59:11 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:270:4fd5:603f:45c2:9807:c104]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b644acb52sm36956440f8f.7.2026.03.23.23.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 23:59:10 -0700 (PDT) Message-ID: <1a7d3c03e6169e6340f9d77667433fd0cc5f5897.camel@cybertec.at> Subject: Re: [PATCH] Doc: clarify that pg_upgrade statistics transfer works cross-version From: Laurenz Albe To: nik@postgres.ai, pgsql-docs@lists.postgresql.org Date: Tue, 24 Mar 2026 07:59:10 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-03-23 at 22:30 -0500, nik@postgres.ai wrote: > I initially assumed that PG18's statistics transfer during pg_upgrade > would only work when upgrading from PG18 to a future version. I hear > this misconception from others fairly often too. >=20 > In reality, it works when upgrading *to* PG18 from any older supported > version (PG14, 15, 16, 17), because pg_upgrade uses the new cluster's > pg_dump, which reads from standard catalog views (pg_class and > pg_stats) that exist in all PostgreSQL versions. The pg_dump docs > already note that "pg_dump can also dump from PostgreSQL servers older > than its own version" =E2=80=94 so no changes needed there. The confusion > seems specific to the major upgrade context. >=20 > The attached patch adds a brief clarification to pgupgrade.sgml to addres= s this. >=20 > I tested pg_dump --statistics-only from PG18 against PG16 and PG14 =E2=80= =94 > both work as expected, stats are transferred and restored correctly. I agree that it would be a good idea to explicitly mention that statistics are transferred when upgrading from older PostgreSQL versions. However, I think that your patch offers too much detail, like from which relations the statistics are extracted. Anybody who wants to know that level of detail probably has to read the source code anyway. How about adding a simple remark, like --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -837,6 +837,8 @@ psql --username=3Dpostgres --file=3Dscript.sql postgres all statistics, such as those created explicitly with , custom statistics added by an extension, or statistics collected by the cumulative statistics sy= stem. + Transferring optimizer statistics works regardless of the old cluster= 's + major version. =20 Yours, Laurenz Albe