Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcZ3i-0000jZ-Ee for pgsql-docs@arkaria.postgresql.org; Mon, 18 Oct 2021 20:16:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mcZ3f-0008EY-RJ for pgsql-docs@arkaria.postgresql.org; Mon, 18 Oct 2021 20:16:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcZ3f-0008EO-3R for pgsql-docs@lists.postgresql.org; Mon, 18 Oct 2021 20:16:31 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcZ3X-0002Ma-CS for pgsql-docs@lists.postgresql.org; Mon, 18 Oct 2021 20:16:30 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0DB8B5C010B; Mon, 18 Oct 2021 16:16:21 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute1.internal (MEProxy); Mon, 18 Oct 2021 16:16:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm3; bh=bkVyIKxeIDT3LHoTqU28VTw0bV3vzoF gbq2+ymGIYyY=; b=SDlXcLDa7wYQPMaD2jyxrc4d9KJEbRgkluqTgz4ch0Nlswz vnK57DVV/XF7nig4Ei/wR/uU8rw8GdGQvKgERVQONfKv6mjs0MKkAAiuIfeC/kXd dY+asSFawU9QG3SxjOqHOHG/t37tc+9UaRlYjgH9J7qjW1/y0mtQd3fNQfdOtiv6 jyFj388Z3QOYRyIRkX/wFppzCvk1cXdynFyqv0XKOJdjRgElwW/uap17zm1QzVxn yAGvdQ+m2NfmmS9flXy6+tNWDuON8c6XYFEsqLWGHcXC190zRL3iaahOYxdWVZjA PNXdo+IoTeJI2joASeuqv0yGdgGE09+xdN+rIxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=bkVyIK xeIDT3LHoTqU28VTw0bV3vzoFgbq2+ymGIYyY=; b=MQ5eAdO8I75PW3dXHmvhtq TJJ8PB1PX/mfwrkiuXNDJNXA1ucxufSzsVMIjAdy/KfdDZQVlEqGaBgi2VsW8fJ+ h/ncTAknLbTQrJ0uWX5FEWGlcV6VQr4DASGr215FV1tlGOEf2EnSBXBpT8epNSf4 VTtU3jxpJ/lUo+Myk2sojvnz9BrbkuzRUsnSwGfqzBnYTc6XRIqOmDgru9L9qgaJ 5R95PI9jhm7p/LDMHpm8BHfLkI64xt/7HmMOQ8jK+vBBlsM39e2eKlbg9/HciPRK RjEWJhc3BFxUqgsLg7GbabT7YShJHETISqSGJRRw+rGKBb729NsY/Z3np01s7uVw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvtddgudegfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrg dtreerreertdenucfhrhhomhepfdfguhhlvghrucfvrghvvghirhgrfdcuoegvuhhlvghr segvuhhlvghrthhordgtohhmqeenucggtffrrghtthgvrhhnpeejtefhuedvgffftdetve dufedtjeeuffekleevkefhveekgeelfefhjeehtdejgeenucffohhmrghinhepvghnthgv rhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepvghulhgvrhesvghulhgvrhhtohdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6982F51C0060; Mon, 18 Oct 2021 16:16:20 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1345-g8441cd7852-fm-20211006.001-g8441cd78 Mime-Version: 1.0 Message-Id: <99443f30-4c03-40e5-b403-055e1f3e706d@www.fastmail.com> In-Reply-To: References: Date: Mon, 18 Oct 2021 17:15:59 -0300 From: "Euler Taveira" To: "nikolai.berkoff" , "pgsql-docs@lists.postgresql.org" Subject: Re: ALTER TABLE ... SET DATA TYPE removes statistics Content-Type: multipart/alternative; boundary=8b3edbc96cec47188117e06654454fff List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --8b3edbc96cec47188117e06654454fff Content-Type: text/plain 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/ --8b3edbc96cec47188117e06654454fff Content-Type: text/html Content-Transfer-Encoding: quoted-printable
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

ATExecAlterCol= umnType
/*
* Drop any pg_statistic entry for= the column, since it's now wrong type
*/
Re= moveStatistics(RelationGetRelid(rel), attnum);

<= div>Although this might be obvious it tripped me up.  For example r= enaming 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

--8b3edbc96cec47188117e06654454fff--