aboutsummaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2025-02-20 01:29:06 -0800
committerJeff Davis <jdavis@postgresql.org>2025-02-20 01:29:06 -0800
commit1fd1bd871012732e3c6c482667d2f2c56f1a9395 (patch)
tree232adb265bbbfdb2c2aa89fe9d2ec8f6c14839c2 /src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
parent7da344b9f84f0c63590a34136f3fa5d0ab128657 (diff)
downloadpostgresql-1fd1bd871012732e3c6c482667d2f2c56f1a9395.tar.gz
postgresql-1fd1bd871012732e3c6c482667d2f2c56f1a9395.zip
Transfer statistics during pg_upgrade.
Add support to pg_dump for dumping stats, and use that during pg_upgrade so that statistics are transferred during upgrade. In most cases this removes the need for a costly re-analyze after upgrade. Some statistics are not transferred, such as extended statistics or statistics with a custom stakind. Now pg_dump accepts the options --schema-only, --no-schema, --data-only, --no-data, --statistics-only, and --no-statistics; which allow all combinations of schema, data, and/or stats. The options are named this way to preserve compatibility with the previous --schema-only and --data-only options. Statistics are in SECTION_DATA, unless the object itself is in SECTION_POST_DATA. The stats are represented as calls to pg_restore_relation_stats() and pg_restore_attribute_stats(). Author: Corey Huinker, Jeff Davis Reviewed-by: Jian He Discussion: https://postgr.es/m/CADkLM=fzX7QX6r78fShWDjNN3Vcr4PVAnvXxQ4DiGy6V=0bCUA@mail.gmail.com Discussion: https://postgr.es/m/CADkLM%3DcB0rF3p_FuWRTMSV0983ihTRpsH%2BOCpNyiqE7Wk0vUWA%40mail.gmail.com
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm')
-rw-r--r--src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
index 38c96f76fbf..264c33b45d0 100644
--- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
+++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
@@ -294,6 +294,11 @@ sub adjust_old_dumpfile
# Version comments will certainly not match.
$dump =~ s/^-- Dumped from database version.*\n//mg;
+ # Same with version argument to pg_restore_relation_stats() or
+ # pg_restore_attribute_stats().
+ $dump =~ s ['version', '${old_version}\d{4}'::integer,]
+ ['version', '000000'::integer,]mg;
+
if ($old_version < 16)
{
# Fix up some view queries that no longer require table-qualification.
@@ -626,6 +631,11 @@ sub adjust_new_dumpfile
# Version comments will certainly not match.
$dump =~ s/^-- Dumped from database version.*\n//mg;
+ # Same with version argument to pg_restore_relation_stats() or
+ # pg_restore_attribute_stats().
+ $dump =~ s ['version', '\d{6}'::integer,]
+ ['version', '000000'::integer,]mg;
+
if ($old_version < 14)
{
# Suppress noise-word uses of IN in CREATE/ALTER PROCEDURE.