pgsql: doc: Recommend ANALYZE after ALTER TABLE ... SET EXPRESSION AS.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: doc: Recommend ANALYZE after ALTER TABLE ... SET EXPRESSION AS.
Date: 2025-08-06 07:49:50
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)sraoss(dot)co(dot)jp>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0b6aea03843dc75871b0490c6302a71a8fecb53d

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml | 11 +++++++++++
1 file changed, 11 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2025-08-06 07:50:09 pgsql: doc: Recommend ANALYZE after ALTER TABLE ... SET EXPRESSION AS.
Previous Message Masahiko Sawada 2025-08-05 22:32:05 pgsql: Suppress maybe-uninitialized warning.