summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2025-08-06 16:47:20 +0900
committerFujii Masao <fujii@postgresql.org>2025-08-06 16:47:20 +0900
commit0b6aea03843dc75871b0490c6302a71a8fecb53d (patch)
treea6a9d641a6a5fb05f0288ff5098a428f6530cc5f
parentb5c53b403c93393c3725558294cbf4dbfb575e42 (diff)
doc: Recommend ANALYZE after ALTER TABLE ... SET EXPRESSION AS.
ALTER TABLE ... SET EXPRESSION AS removes statistics for the target column, so running ANALYZE afterward is recommended. But this was previously not documented, even though a similar recommendation exists for ALTER TABLE ... SET DATA TYPE, which also clears the column's statistics. This commit updates the documentation to include the ANALYZE recommendation for SET EXPRESSION AS. Since v18, virtual generated columns are supported, and these columns never have statistics. Therefore, ANALYZE is not needed after SET DATA TYPE or SET EXPRESSION AS when used on virtual generated columns. This commit also updates the documentation to clarify that ANALYZE is unnecessary in such cases. Back-patch the ANALYZE recommendation for SET EXPRESSION AS to v17 where the feature was introduced, and the note about virtual generated columns to v18 where those columns were added. Author: Yugo Nagata <nagata@sraoss.co.jp> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/20250804151418.0cf365bd2855d606763443fe@sraoss.co.jp Backpatch-through: 17
-rw-r--r--doc/src/sgml/ref/alter_table.sgml11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 541e093a519..8867da6c693 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -210,6 +210,8 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
When this form is used, the column's statistics are removed,
so running <link linkend="sql-analyze"><command>ANALYZE</command></link>
on the table afterwards is recommended.
+ For a virtual generated column, <command>ANALYZE</command>
+ is not necessary because such columns never have statistics.
</para>
</listitem>
</varlistentry>
@@ -271,6 +273,15 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
in a stored generated column is rewritten and all the future changes
will apply the new generation expression.
</para>
+
+ <para>
+ When this form is used on a stored generated column, its statistics
+ are removed, so running
+ <link linkend="sql-analyze"><command>ANALYZE</command></link>
+ on the table afterwards is recommended.
+ For a virtual generated column, <command>ANALYZE</command>
+ is not necessary because such columns never have statistics.
+ </para>
</listitem>
</varlistentry>