From d32d1463995c036853eeb9ec99cc367ffc7794ae Mon Sep 17 00:00:00 2001
From: Jeff Davis
Date: Thu, 24 Oct 2024 12:08:00 -0700
Subject: Add functions pg_restore_relation_stats(),
pg_restore_attribute_stats().
Similar to the pg_set_*_stats() functions, except with a variadic
signature that's designed to be more future-proof. Additionally, most
problems are reported as WARNINGs rather than ERRORs, allowing most
stats to be restored even if some cannot.
These functions are intended to be called from pg_dump to avoid the
need to run ANALYZE after an upgrade.
Author: Corey Huinker
Discussion: https://postgr.es/m/CADkLM=eErgzn7ECDpwFcptJKOk9SxZEk5Pot4d94eVTZsvj3gw@mail.gmail.com
---
doc/src/sgml/func.sgml | 100 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
(limited to 'doc/src/sgml/func.sgml')
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 7912fb711d3..58dc06b68b8 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -30267,6 +30267,55 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a
+
+
+
+ pg_restore_relation_stats
+
+ pg_restore_relation_stats (
+ VARIADIC kwargs "any" )
+ boolean
+
+
+ Similar to pg_set_relation_stats(), but intended
+ for bulk restore of relation statistics. The tracked statistics may
+ change from version to version, so the primary purpose of this
+ function is to maintain a consistent function signature to avoid
+ errors when restoring statistics from previous versions.
+
+
+ Arguments are passed as pairs of argname
+ and argvalue, where
+ argname corresponds to a named argument in
+ pg_set_relation_stats() and
+ argvalue is of the corresponding type.
+
+
+ Additionally, this function supports argument name
+ version of type integer, which
+ specifies the version from which the statistics originated, improving
+ intepretation of older statistics.
+
+
+ For example, to set the relpages and
+ reltuples of the table
+ mytable:
+
+ SELECT pg_restore_relation_stats(
+ 'relation', 'mytable'::regclass,
+ 'relpages', 173::integer,
+ 'reltuples', 10000::float4);
+
+
+
+ Minor errors are reported as a WARNING and
+ ignored, and remaining statistics will still be restored. If all
+ specified statistics are successfully restored, return
+ true, otherwise false.
+
+
+
+
@@ -30338,6 +30387,57 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a
+
+
+
+ pg_restore_attribute_stats
+
+ pg_restore_attribute_stats (
+ VARIADIC kwargs "any" )
+ boolean
+
+
+ Similar to pg_set_attribute_stats(), but
+ intended for bulk restore of attribute statistics. The tracked
+ statistics may change from version to version, so the primary purpose
+ of this function is to maintain a consistent function signature to
+ avoid errors when restoring statistics from previous versions.
+
+
+ Arguments are passed as pairs of argname
+ and argvalue, where
+ argname corresponds to a named argument in
+ pg_set_attribute_stats() and
+ argvalue is of the corresponding type.
+
+
+ Additionally, this function supports argument name
+ version of type integer, which
+ specifies the version from which the statistics originated, improving
+ intepretation of older statistics.
+
+
+ For example, to set the avg_width and
+ null_frac for the attribute
+ col1 of the table
+ mytable:
+
+ SELECT pg_restore_attribute_stats(
+ 'relation', 'mytable'::regclass,
+ 'attname', 'col1'::name,
+ 'inherited', false,
+ 'avg_width', 125::integer,
+ 'null_frac', 0.5::real);
+
+
+
+ Minor errors are reported as a WARNING and
+ ignored, and remaining statistics will still be restored. If all
+ specified statistics are successfully restored, return
+ true, otherwise false.
+
+
+
--
cgit v1.2.3