Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind

Поиск
Список
Период
Сортировка
От Christoph Berg
Тема Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Дата
Msg-id YP7R0fFWZB1VCmCT@msg.credativ.de
обсуждение исходный текст
Ответ на Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Следующее
От: Lætitia Avrot
Дата:
Сообщение: Re: Statistics updates is delayed when using `commit and chain`