From: Euler Taveira <euler@eulerto.com>
To: nikolai.berkoff <nikolai.berkoff@pm.me>
To: pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>
Subject: Re: ALTER TABLE ... SET DATA TYPE removes statistics
Date: Mon, 18 Oct 2021 17:15:59 -0300
Message-ID: <99443f30-4c03-40e5-b403-055e1f3e706d@www.fastmail.com> (raw)
In-Reply-To: <vCc8XnwDmlP4ZnHBQLIVxzD405BiYHVC9qZlhIF7IsfxK0gC9mZ4PUUOH0-3y6kv5p-87-3_ljqT1KvQVAnb8OoWhPU3kcqWn2ZpmxRBCQg=@pm.me>
References: <vCc8XnwDmlP4ZnHBQLIVxzD405BiYHVC9qZlhIF7IsfxK0gC9mZ4PUUOH0-3y6kv5p-87-3_ljqT1KvQVAnb8OoWhPU3kcqWn2ZpmxRBCQg=@pm.me>
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
EDB https://www.enterprisedb.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: euler@eulerto.com, nikolai.berkoff@pm.me, pgsql-docs@lists.postgresql.org
Subject: Re: ALTER TABLE ... SET DATA TYPE removes statistics
In-Reply-To: <99443f30-4c03-40e5-b403-055e1f3e706d@www.fastmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox