From: Christoph Berg <christoph.berg@credativ.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Date: Mon, 26 Jul 2021 17:16:33 +0200
Message-ID: <YP7R0fFWZB1VCmCT@msg.credativ.de> (raw)
In-Reply-To: <86586.1627309764@sss.pgh.pa.us>
References: <17123-734abc3934f500b6@postgresql.org>
<86586.1627309764@sss.pgh.pa.us>
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
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-bugs@postgresql.org
Cc: christoph.berg@credativ.de, tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
In-Reply-To: <YP7R0fFWZB1VCmCT@msg.credativ.de>
* 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