From a5cbdeb98af9a8d4f683fbffa69cd74be1f4a084 Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 25 Feb 2025 16:15:47 -0800 Subject: Remove redundant pg_set_*_stats() variants. After commit f3dae2ae58, the primary purpose of separating the pg_set_*_stats() from the pg_restore_*_stats() variants was eliminated. Leave pg_restore_relation_stats() and pg_restore_attribute_stats(), which satisfy both purposes, and remove pg_set_relation_stats() and pg_set_attribute_stats(). Reviewed-by: Corey Huinker Discussion: https://postgr.es/m/1457469.1740419458@sss.pgh.pa.us --- doc/src/sgml/func.sgml | 254 ++++++++++++++++++++----------------------------- 1 file changed, 104 insertions(+), 150 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index f0ccb751106..12206e0cfc6 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -30180,66 +30180,6 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset - - - - - pg_set_relation_stats - - pg_set_relation_stats ( - relation regclass - , relpages integer - , reltuples real - , relallvisible integer ) - void - - - Updates relation-level statistics for the given relation to the - specified values. The parameters correspond to columns in pg_class. Unspecified - or NULL values leave the setting unchanged. - - - Ordinarily, these statistics are collected automatically or updated - as a part of or , 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. - - - The caller must have the MAINTAIN privilege on - the table or be the owner of the database. - - - The value of relpages must be greater than - or equal to -1, - reltuples must be greater than or equal to - -1.0, and relallvisible - must be greater than or equal to 0. - - - - - - - - - pg_clear_relation_stats - - pg_clear_relation_stats ( relation regclass ) - void - - - Clears table-level statistics for the given relation, as though the - table was newly created. - - - The caller must have the MAINTAIN privilege on - the table or be the owner of the database. - - - - @@ -30248,26 +30188,25 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset 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. + Updates table-level statistics. Ordinarily, these statistics are + collected automatically or updated as a part of or , so it's not + necessary to call this function. However, it is useful after a + restore to enable the optimizer to choose better plans if + ANALYZE has not been run yet. - Additionally, this function supports argument name - version of type integer, which - specifies the version from which the statistics originated, improving - interpretation of older statistics. + The tracked statistics may change from version to version, so + arguments are passed as pairs of argname + and argvalue in the form: + + SELECT pg_restore_relation_stats( + 'arg1name', 'arg1value'::arg1type, + 'arg2name', 'arg2value'::arg2type, + 'arg3name', 'arg3value'::arg3type); + For example, to set the relpages and @@ -30277,62 +30216,37 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset SELECT pg_restore_relation_stats( 'relation', 'mytable'::regclass, 'relpages', 173::integer, - 'reltuples', 10000::float4); + 'reltuples', 10000::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. - - - - - - - - - pg_set_attribute_stats - - pg_set_attribute_stats ( - relation regclass, - attname name, - inherited boolean - , null_frac real - , avg_width integer - , n_distinct real - , most_common_vals text, most_common_freqs real[] - , histogram_bounds text - , correlation real - , most_common_elems text, most_common_elem_freqs real[] - , elem_count_histogram real[] - , range_length_histogram text - , range_empty_frac real - , range_bounds_histogram text ) - void - - - Creates or updates attribute-level statistics for the given relation - and attribute name to the specified values. The parameters correspond - to attributes of the same name found in the pg_stats - view. + The argument relation with a value of type + regclass is required, and specifies the table. Other + arguments are the names of statistics corresponding to certain + columns in pg_class. + The currently-supported relation statistics are + relpages with a value of type + integer, reltuples with a value of + type real, and relallvisible with a + value of type integer. - Optional parameters default to NULL, which leave - the corresponding statistic unchanged. + Additionally, this function supports argument name + version of type integer, which + specifies the version from which the statistics originated, improving + interpretation of statistics from older versions of + PostgreSQL. - Ordinarily, these statistics are collected automatically or updated - as a part of or , 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. + 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. - The caller must have the MAINTAIN privilege on - the table or be the owner of the database. + The caller must have the MAINTAIN privilege on the + table or be the owner of the database. @@ -30341,21 +30255,18 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset - pg_clear_attribute_stats + pg_clear_relation_stats - pg_clear_attribute_stats ( - relation regclass, - attname name, - inherited boolean ) + pg_clear_relation_stats ( relation regclass ) void - Clears table-level statistics for the given relation attribute, as - though the table was newly created. + Clears table-level statistics for the given relation, as though the + table was newly created. - The caller must have the MAINTAIN privilege on - the table or be the owner of the database. + The caller must have the MAINTAIN privilege on the + table or be the owner of the database. @@ -30368,26 +30279,25 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset 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. + Create or update column-level statistics. Ordinarily, these + statistics are collected automatically or updated as a part of or , so it's not + necessary to call this function. However, it is useful after a + restore to enable the optimizer to choose better plans if + ANALYZE has not been run yet. - Additionally, this function supports argument name - version of type integer, which - specifies the version from which the statistics originated, improving - interpretation of older statistics. + The tracked statistics may change from version to version, so + arguments are passed as pairs of argname + and argvalue in the form: + + SELECT pg_restore_attribute_stats( + 'arg1name', 'arg1value'::arg1type, + 'arg2name', 'arg2value'::arg2type, + 'arg3name', 'arg3value'::arg3type); + For example, to set the avg_width and @@ -30403,12 +30313,56 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset 'null_frac', 0.5::real); + + The required arguments are relation with a value + of type regclass, which specifies the table; + attname with a value of type name, + which specifies the column; and inherited, which + specifies whether the statistics includes values from child tables. + Other arguments are the names of statistics corresponding to columns + in pg_stats. + + + Additionally, this function supports argument name + version of type integer, which + specifies the version from which the statistics originated, improving + interpretation of statistics from older versions of + PostgreSQL. + 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. + + The caller must have the MAINTAIN privilege on the + table or be the owner of the database. + + + + + + + + + pg_clear_attribute_stats + + pg_clear_attribute_stats ( + relation regclass, + attname name, + inherited boolean ) + void + + + Clears column-level statistics for the given relation and + attribute, as though the table was newly created. + + + The caller must have the MAINTAIN privilege on + the table or be the owner of the database. + -- cgit v1.2.3