summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorJeff Davis2024-10-22 22:06:55 +0000
committerJeff Davis2024-10-22 22:06:55 +0000
commitce207d2a79017713c0293bf70132dc6d41166b03 (patch)
tree40a9575ea42f1c8eadd28e542a8f664aeb7a7ed1 /doc/src
parentdbe6bd4343d8cdb1b3cf1f66d6f66dd876a6c09d (diff)
Add functions pg_set_attribute_stats() and pg_clear_attribute_stats().
Enable manipulation of attribute statistics. Only superficial validation is performed, so it's possible to add nonsense, and it's up to the planner (or other users of statistics) to behave reasonably in that case. 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.sgml72
1 files changed, 72 insertions, 0 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 14dd035134a..ba5656c86b6 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -30222,6 +30222,78 @@ DETAIL: Make sure pg_wal_replay_wait() isn't called within a transaction with a
</para>
</entry>
</row>
+
+ <row>
+ <entry role="func_table_entry">
+ <para role="func_signature">
+ <indexterm>
+ <primary>pg_set_attribute_stats</primary>
+ </indexterm>
+ <function>pg_set_attribute_stats</function> (
+ <parameter>relation</parameter> <type>regclass</type>,
+ <parameter>attname</parameter> <type>name</type>,
+ <parameter>inherited</parameter> <type>boolean</type>
+ <optional>, <parameter>null_frac</parameter> <type>real</type></optional>
+ <optional>, <parameter>avg_width</parameter> <type>integer</type></optional>
+ <optional>, <parameter>n_distinct</parameter> <type>real</type></optional>
+ <optional>, <parameter>most_common_vals</parameter> <type>text</type>, <parameter>most_common_freqs</parameter> <type>real[]</type> </optional>
+ <optional>, <parameter>histogram_bounds</parameter> <type>text</type> </optional>
+ <optional>, <parameter>correlation</parameter> <type>real</type> </optional>
+ <optional>, <parameter>most_common_elems</parameter> <type>text</type>, <parameter>most_common_elem_freqs</parameter> <type>real[]</type> </optional>
+ <optional>, <parameter>elem_count_histogram</parameter> <type>real[]</type> </optional>
+ <optional>, <parameter>range_length_histogram</parameter> <type>text</type> </optional>
+ <optional>, <parameter>range_empty_frac</parameter> <type>real</type> </optional>
+ <optional>, <parameter>range_bounds_histogram</parameter> <type>text</type> </optional> )
+ <returnvalue>void</returnvalue>
+ </para>
+ <para>
+ Creates or updates attribute-level statistics for the given relation
+ and attribute name to the specified values. The parameters correspond
+ to to attributes of the same name found in the <link
+ linkend="view-pg-stats"><structname>pg_stats</structname></link>
+ view.
+ </para>
+ <para>
+ Optional parameters default to <literal>NULL</literal>, which leave
+ the corresponding statistic unchanged.
+ </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>
+ </entry>
+ </row>
+
+ <row>
+ <entry role="func_table_entry">
+ <para role="func_signature">
+ <indexterm>
+ <primary>pg_clear_attribute_stats</primary>
+ </indexterm>
+ <function>pg_clear_attribute_stats</function> (
+ <parameter>relation</parameter> <type>regclass</type>,
+ <parameter>attname</parameter> <type>name</type>,
+ <parameter>inherited</parameter> <type>boolean</type> )
+ <returnvalue>boolean</returnvalue>
+ </para>
+ <para>
+ Clears table-level statistics for the given relation attribute, as
+ though the table was newly created.
+ </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>