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 1m82La-0005sC-88 for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Jul 2021 15:16:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m82LY-0007T6-BF for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Jul 2021 15:16:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m82LY-0007Sy-3M for pgsql-bugs@lists.postgresql.org; Mon, 26 Jul 2021 15:16:48 +0000 Received: from mail.credativ.com ([2a02:158:380:2a0::5d5e:825a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m82LV-0001e0-Bn for pgsql-bugs@lists.postgresql.org; Mon, 26 Jul 2021 15:16:47 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.credativ.com (Postfix) with ESMTP id 7AA3E20160; Mon, 26 Jul 2021 15:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=credativ.de; s=email; t=1627312600; bh=0GRrCZoDxPQLdRN4Z6l+f4e6O7AKPXiDbIOMAj9YU/I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IDFTSVfwD7r9qzIt5H9kUVZm9lcTQ0jpXIW5n+2v4hVZ+rYuRS0K8vUdkBsgEseD4 K3nmhhlUF+OawQdBeVC7C5o9k37GbxSS6gabfI0VB6L0hcDfstltBsg9PPXhCl3Mog wi+MK6bF+cF65GMVzfMjfN3i1YJxw5WLKttvJ8bL2t0H5yeky+bpJhKGPsYsg9/gFq c964kKt07+RYogZreDSmUj3XwzfDUcDq4gEMYKa+tFbdy8QG1P8TvH449jV7mgXt4p 2VcaBF02nKT+9HBKSXFJUBty0ltRdmu84U4/+pnmCkTBJbSIKXCf9xCUd4qhKNYel9 xdcu0n9TyhAQA== Received: from mail.credativ.com ([127.0.0.1]) by localhost (mail.credativ.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RGXT_TAhK3LS; Mon, 26 Jul 2021 15:16:34 +0000 (UTC) Received: from msg.credativ.de (unknown [IPv6:2003:5b:203b:200::10:18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cbe) by mail.credativ.com (Postfix) with ESMTPSA id 6AAAA200AB; Mon, 26 Jul 2021 15:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=credativ.de; s=email; t=1627312594; bh=0GRrCZoDxPQLdRN4Z6l+f4e6O7AKPXiDbIOMAj9YU/I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qLSaJUpnOOqLjpNHPOHqBRQs2tO0EmnuelENyMq0MdBc0toQqNt79TJ5RATXtA9Wa DYQ6LO4CRKLYIC4od6YNyEIYmWHFZNdVNEPcYmXZPPSCA0U9I7o14x8mmiNKRNa31C UjmP0sdaE20q6JPyF+qV7g5tlgHwrFST+z4oHE4smszl9IDWlUd9d1H4QJ4N4Nz+JC mRXJpId2m+YmzsAipjKUJCRJ1K1Kv73f04/GjwYzDd1hZSymi+NyDjbqf0JZq0Rb+I 8rNTl04zox8wWZX+5A55Rvm4K5GnJ+AVqpzBwTiass9/BQ65eEkWrjvo5lpKE7Smgb 43PHvU9YOHETQ== Date: Mon, 26 Jul 2021 17:16:33 +0200 From: Christoph Berg To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind Message-ID: References: <17123-734abc3934f500b6@postgresql.org> <86586.1627309764@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86586.1627309764@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Re: Tom Lane > Good catch. I imagine DETACH PARTITION has related issues? It has, but for partitioned tables I think the case is different. Partitioned tables have inherited=true stats only, and in practice, as the partition parent table is always empty, stale statistics on a partitioned table without any partitions aren't hurting. Maybe one could even argue that keeping the stats around in that case makes sense since they might help with the next partition re-added, like TRUNCATE doesn't reset stats, or like ANALYZE on an empty table doesn't wipe the existing stats. create table log (ts timestamptz) partition by range (ts); create table log2 partition of log for values from ('2021-07-01') to ('2021-08-01'); insert into log values ('2021-07-01'); analyze log; select * from pg_stats where tablename = 'log' and attname = 'ts' \gx alter table log detach partition log2; analyze log; select * from pg_stats where tablename = 'log' and attname = 'ts' \gx Christoph -- Senior Berater, Tel.: +49 2166 9901 187 credativ GmbH, HRB Mönchengladbach 12080, USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Sascha Heuer, Geoff Richardson, Peter Lilley; Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz