Re: ALTER TABLE ... SET DATA TYPE removes statistics - Mailing list pgsql-docs

From Euler Taveira
Subject Re: ALTER TABLE ... SET DATA TYPE removes statistics
Date
Msg-id 99443f30-4c03-40e5-b403-055e1f3e706d@www.fastmail.com
Whole thread Raw
In response to ALTER TABLE ... SET DATA TYPE removes statistics  ("nikolai.berkoff" <nikolai.berkoff@pm.me>)
Responses Re: ALTER TABLE ... SET DATA TYPE removes statistics  (Michael Paquier <michael@paquier.xyz>)
List pgsql-docs
On Fri, Oct 8, 2021, at 6:03 AM, nikolai.berkoff wrote:
The current documentation does not mention that the column statistics are removed which I can see they are in src/backend/commands/tablecmds.c

ATExecAlterColumnType
/*
* Drop any pg_statistic entry for the column, since it's now wrong type
*/
RemoveStatistics(RelationGetRelid(rel), attnum);

Although this might be obvious it tripped me up.  For example renaming and SET STATISTICS preserves statistics.  Patch attached.
I agree that it might surprise an user and it would be good to document it.
However, it does not belong to the description. I would add it to the Notes
section at the end of the ALTER TABLE page.


--
Euler Taveira

pgsql-docs by date:

Previous
From: "Euler Taveira"
Date:
Subject: Re: vacuumdb --analyze-in-stages
Next
From: Alvaro Herrera
Date:
Subject: Re: vacuumdb --analyze-in-stages