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 1u7LBJ-00Eib3-JL for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Apr 2025 21:29:30 +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 1u7LBH-000bme-TX for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Apr 2025 21:29:28 +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 1u7LBH-000blX-Jb for pgsql-hackers@lists.postgresql.org; Tue, 22 Apr 2025 21:29:28 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u7LBF-001Tbt-0i for pgsql-hackers@lists.postgresql.org; Tue, 22 Apr 2025 21:29:28 +0000 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-85e1b1f08a5so151009539f.2 for ; Tue, 22 Apr 2025 14:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745357364; x=1745962164; 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=PIKkEFQIcx721WXjG0bkyVllfypM0G8vGVRY+dexkfU=; b=lOXfbjiUsPKf4Y5MYEwYHUVTjTRoAonNzf79w4SBnV5funq2LDwmLJJyeVuraqe0Vm hYMIkR6YuLnBs5K0Czwq3C2IlYe5h67cmX1zYawXJxnuoxLWqIAkJbQt9sQjhNyq/1JV Zz3TVSaTBSp7ghYec5m4tD+9h46rlzoePW+MQUQrqrKeto07EkLAPs649YsbXnlxmkwP idtNnG1qmVyFAPcINfyj8PSVfXg16hZd6OzueoeNZWbwuOGEl6LvqvVfubGAYbaHrDrt r93/l5UB+bhqLiUI4dcbLGI7UBFWqAHM2Rff7M/oOnzqo5rlWg+f0zHi5oDWgKI9503w HuNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745357364; x=1745962164; 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=PIKkEFQIcx721WXjG0bkyVllfypM0G8vGVRY+dexkfU=; b=Pkg8lfRxXDzycxTStGOqswlZQ2aLiz3m/NAunyaP8YGnIobG1zivOwrXxkWoW7Vupi vYN4L0wUw5VKZq+6al6daiXdXIKnCLiaD1l9AcQmNf6MxLZ70U1vWnlIz2xqS4AaPrcY bo7EVI0vnC9t/VX0YP0w8KW4J502o8cisTZzQSYNIa6VzBrbzf+x+gQ7ipqK3QvT+56F zylyJRPFpWANoHi25fLTVJtIFwU1MsHwjwou7WsRyM5LZKEyGKtGOR6D2fafNLpQDpK5 mwq8FJssbZkmvygrkg4yW+oULOAuXIwT9nsDDswPEMejNmMiRKiTxw2RfJaqlqiOQSTv MJIQ== X-Forwarded-Encrypted: i=1; AJvYcCXvdrMzMRO7UohBS/G2FB8r+tt/ltcW484MTevSWOXnu6LrxiKLKor/RD/JnCyK+BcPMWxGTpxu/nv1bFKD@lists.postgresql.org X-Gm-Message-State: AOJu0YxEeWMScaXpjkCjCs00v4rZKP7WbZV1JLNiahWYlYABnwAHIG6d 3GZQbYot+12+iQcy1GOElSF3GEeHGbd/764x1mxpeYQd0aYhTgAm X-Gm-Gg: ASbGnctVqqp8Tc0Y/RhsYAIqXyopQfRgOmzeLr6f6ExJcdUzN3RujfKUXjvaeGSzpGV lf7q/EjQLw+6Xzp5uOGORPEWWOftn6IWK8o3TJuU0owE8MMII1G/ay0BgZTYEWj+Q+44QoccPvI 4MJNrxZnLX4c8A2Zva5JkqdxonLVPl5niVKtPjjKCl2GfxdTrMbHIqOqj59KBtrnDgtGwThNKva ne7xykYMDbx/2JoM/d9XkFthwc0WzY5/Y6CigHGX1sMBxfmbwGvPsGjokDBABOO1OLb3EQLFLlp SUQnthoE7VEmgQOhOFkHLxINVqszeU1fQCVxcol5nICcKwT594spv24CaoKbGmrxZKYoWPbZp2R HttB2BQ7fIGugud+IDTHZEmp9osGEJOs= X-Google-Smtp-Source: AGHT+IEVbsqaAlMOwcbsZ8Imugn54gA0TvMkZrL5gVLWnp1Lk6uVMiP/8/eoERllF3DzRAYAbnwRTw== X-Received: by 2002:a6b:620f:0:b0:862:ba37:eb0e with SMTP id ca18e2360f4ac-862ba37ecbcmr1439786539f.12.1745357364227; Tue, 22 Apr 2025 14:29: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-8644475f03fsm4238339f.21.2025.04.22.14.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 14:29:23 -0700 (PDT) Date: Tue, 22 Apr 2025 16:29:21 -0500 From: Nathan Bossart To: Christoph Berg Cc: Corey Huinker , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Update guidance for running vacuumdb after pg_upgrade. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="JWVqibUa/J+F7jYr" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --JWVqibUa/J+F7jYr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Apr 22, 2025 at 11:03:29PM +0200, Christoph Berg wrote: > Re: Nathan Bossart >> In any case, IMO it's unfortunate >> that we might end up recommending roughly the same post-upgrade steps as >> before even though the optimizer statistics are carried over. > > Maybe the docs (and the pg_upgrade scripts) should recommend the old > procedure by default until this gap is closed? People could then still > opt to use the new procedure in specific cases. I think we'd still want to modify the --analyze-in-stages recommendation (from what is currently recommended for supported versions). If we don't, you'll wipe out the optimizer stats you brought over from the old version. Here is a rough draft of what I am thinking. -- nathan --JWVqibUa/J+F7jYr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="post_upgrade_guidance.patch" diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml index df13365b287..648c6e2967c 100644 --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -833,17 +833,19 @@ psql --username=postgres --file=script.sql postgres Because not all statistics are not transferred by - pg_upgrade, you will be instructed to run a command to + pg_upgrade, you will be instructed to run commands to regenerate that information at the end of the upgrade. You might need to set connection parameters to match your new cluster. - Using vacuumdb --all --analyze-only --missing-stats-only - can efficiently generate such statistics. Alternatively, + First, use vacuumdb --all --analyze-in-stages --missing-stats-only - can be used to generate minimal statistics quickly. For either command, - the use of can speed it up. + to quickly generate minimal optimizer statistics for relations without + any. Then, use vacuumdb --all --analyze-only to ensure + all relations have updated cumulative statistics for triggering vacuum and + analyze. For both commands, the use of can speed + it up. If vacuum_cost_delay is set to a non-zero value, this can be overridden to speed up statistics generation using PGOPTIONS, e.g., PGOPTIONS='-c diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 18c2d652bb6..f1b90c5957e 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -814,9 +814,12 @@ output_completion_banner(char *deletion_script_file_name) } pg_log(PG_REPORT, - "Some optimizer statistics may not have been transferred by pg_upgrade.\n" + "Some statistics are not transferred by pg_upgrade.\n" "Once you start the new server, consider running:\n" - " %s/vacuumdb %s--all --analyze-in-stages --missing-stats-only", new_cluster.bindir, user_specification.data); + " %s/vacuumdb %s--all --analyze-in-stages --missing-stats-only\n" + " %s/vacuumdb %s--all --analyze-only", + new_cluster.bindir, user_specification.data, + new_cluster.bindir, user_specification.data); if (deletion_script_file_name) pg_log(PG_REPORT, --JWVqibUa/J+F7jYr--