summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorJeff Davis2024-10-11 23:55:11 +0000
committerJeff Davis2024-10-11 23:55:11 +0000
commite839c8ecc9352b7754e74f19ace013c0c0d18613 (patch)
tree881e69557ddddebec18104dc286c1ef160d8f909 /doc/src
parent6f782a2a1738ab96ee948a4ab33ca3defd39327b (diff)
Create functions pg_set_relation_stats, pg_clear_relation_stats.
These functions are used to tweak statistics on any relation, provided that the user has MAINTAIN privilege on the relation, or is the database owner. Bump catalog version. Author: Corey Huinker Discussion: https://postgr.es/m/CADkLM=eErgzn7ECDpwFcptJKOk9SxZEk5Pot4d94eVTZsvj3gw@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml94
1 files changed, 94 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 9656d1891e8..f8a0d76d12b 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -30136,6 +30136,100 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a
</table>
<para>
+ <xref linkend="functions-admin-statsmod"/> lists functions used to
+ manipulate statistics.
+ <warning>
+ <para>
+ Changes made by these statistics manipulation functions are likely to be
+ overwritten by <link linkend="autovacuum">autovacuum</link> (or manual
+ <command>VACUUM</command> or <command>ANALYZE</command>) and should be
+ considered temporary.
+ </para>
+ </warning>
+ </para>
+
+ <table id="functions-admin-statsmod">
+ <title>Database Object Statistics Manipulation Functions</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry role="func_table_entry"><para role="func_signature">
+ Function
+ </para>
+ <para>
+ Description
+ </para></entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry role="func_table_entry">
+ <para role="func_signature">
+ <indexterm>
+ <primary>pg_set_relation_stats</primary>
+ </indexterm>
+ <function>pg_set_relation_stats</function> (
+ <parameter>relation</parameter> <type>regclass</type>
+ <optional>, <parameter>relpages</parameter> <type>integer</type></optional>
+ <optional>, <parameter>reltuples</parameter> <type>real</type></optional>
+ <optional>, <parameter>relallvisible</parameter> <type>integer</type></optional> )
+ <returnvalue>boolean</returnvalue>
+ </para>
+ <para>
+ Updates relation-level statistics for the given relation to the
+ specified values. The parameters correspond to columns in <link
+ linkend="catalog-pg-class"><structname>pg_class</structname></link>. Unspecified
+ or <literal>NULL</literal> values leave the setting
+ unchanged. Returns <literal>true</literal> if a change was made;
+ <literal>false</literal> otherwise.
+ </para>
+ <para>
+ Ordinarily, these statistics are collected automatically or updated
+ as a part of <xref linkend="sql-vacuum"/> or <xref
+ linkend="sql-analyze"/>, so it's not necessary to call this
+ function. However, it may be useful when testing the effects of
+ statistics on the planner to understand or anticipate plan changes.
+ </para>
+ <para>
+ The caller must have the <literal>MAINTAIN</literal> privilege on
+ the table or be the owner of the database.
+ </para>
+ <para>
+ The value of <structfield>relpages</structfield> must be greater than
+ or equal to <literal>0</literal>,
+ <structfield>reltuples</structfield> must be greater than or equal to
+ <literal>-1.0</literal>, and <structfield>relallvisible</structfield>
+ must be greater than or equal to <literal>0</literal>.
+ </para>
+ </entry>
+ </row>
+
+ <row>
+ <entry role="func_table_entry">
+ <para role="func_signature">
+ <indexterm>
+ <primary>pg_clear_relation_stats</primary>
+ </indexterm>
+ <function>pg_clear_relation_stats</function> ( <parameter>relation</parameter> <type>regclass</type> )
+ <returnvalue>boolean</returnvalue>
+ </para>
+ <para>
+ Clears table-level statistics for the given relation, as though the
+ table was newly created. Returns <literal>true</literal> if a change
+ was made; <literal>false</literal> otherwise.
+ </para>
+ <para>
+ The caller must have the <literal>MAINTAIN</literal> privilege on
+ the table or be the owner of the database.
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
<xref linkend="functions-info-partition"/> lists functions that provide
information about the structure of partitioned tables.
</para>