mirror of
https://github.com/postgres/postgres.git
synced 2025-12-24 06:01:07 +03:00
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
This commit is contained in:
@@ -30267,6 +30267,55 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>pg_restore_relation_stats</primary>
|
||||
</indexterm>
|
||||
<function>pg_restore_relation_stats</function> (
|
||||
<literal>VARIADIC</literal> <parameter>kwargs</parameter> <type>"any"</type> )
|
||||
<returnvalue>boolean</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Similar to <function>pg_set_relation_stats()</function>, 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.
|
||||
</para>
|
||||
<para>
|
||||
Arguments are passed as pairs of <replaceable>argname</replaceable>
|
||||
and <replaceable>argvalue</replaceable>, where
|
||||
<replaceable>argname</replaceable> corresponds to a named argument in
|
||||
<function>pg_set_relation_stats()</function> and
|
||||
<replaceable>argvalue</replaceable> is of the corresponding type.
|
||||
</para>
|
||||
<para>
|
||||
Additionally, this function supports argument name
|
||||
<literal>version</literal> of type <type>integer</type>, which
|
||||
specifies the version from which the statistics originated, improving
|
||||
intepretation of older statistics.
|
||||
</para>
|
||||
<para>
|
||||
For example, to set the <structname>relpages</structname> and
|
||||
<structname>reltuples</structname> of the table
|
||||
<structname>mytable</structname>:
|
||||
<programlisting>
|
||||
SELECT pg_restore_relation_stats(
|
||||
'relation', 'mytable'::regclass,
|
||||
'relpages', 173::integer,
|
||||
'reltuples', 10000::float4);
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Minor errors are reported as a <literal>WARNING</literal> and
|
||||
ignored, and remaining statistics will still be restored. If all
|
||||
specified statistics are successfully restored, return
|
||||
<literal>true</literal>, otherwise <literal>false</literal>.
|
||||
</para>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry">
|
||||
<para role="func_signature">
|
||||
@@ -30338,6 +30387,57 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="func_table_entry"><para role="func_signature">
|
||||
<indexterm>
|
||||
<primary>pg_restore_attribute_stats</primary>
|
||||
</indexterm>
|
||||
<function>pg_restore_attribute_stats</function> (
|
||||
<literal>VARIADIC</literal> <parameter>kwargs</parameter> <type>"any"</type> )
|
||||
<returnvalue>boolean</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Similar to <function>pg_set_attribute_stats()</function>, 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.
|
||||
</para>
|
||||
<para>
|
||||
Arguments are passed as pairs of <replaceable>argname</replaceable>
|
||||
and <replaceable>argvalue</replaceable>, where
|
||||
<replaceable>argname</replaceable> corresponds to a named argument in
|
||||
<function>pg_set_attribute_stats()</function> and
|
||||
<replaceable>argvalue</replaceable> is of the corresponding type.
|
||||
</para>
|
||||
<para>
|
||||
Additionally, this function supports argument name
|
||||
<literal>version</literal> of type <type>integer</type>, which
|
||||
specifies the version from which the statistics originated, improving
|
||||
intepretation of older statistics.
|
||||
</para>
|
||||
<para>
|
||||
For example, to set the <structname>avg_width</structname> and
|
||||
<structname>null_frac</structname> for the attribute
|
||||
<structname>col1</structname> of the table
|
||||
<structname>mytable</structname>:
|
||||
<programlisting>
|
||||
SELECT pg_restore_attribute_stats(
|
||||
'relation', 'mytable'::regclass,
|
||||
'attname', 'col1'::name,
|
||||
'inherited', false,
|
||||
'avg_width', 125::integer,
|
||||
'null_frac', 0.5::real);
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
Minor errors are reported as a <literal>WARNING</literal> and
|
||||
ignored, and remaining statistics will still be restored. If all
|
||||
specified statistics are successfully restored, return
|
||||
<literal>true</literal>, otherwise <literal>false</literal>.
|
||||
</para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user