Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Date
Msg-id 86586.1627309764@sss.pgh.pa.us
Whole thread Raw
In response to BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind  (Christoph Berg <christoph.berg@credativ.de>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> Removing the last/only inheritance child from a table using ALTER TABLE NO
> INHERIT leaves orphaned statistics behind that ANALYZE doesn't remove.
> Original customer complaint on 10.16, but 15devel has the same issue.

Good catch.  I imagine DETACH PARTITION has related issues?

It seems like there are basically two ways to fix this:

1. Make ALTER TABLE NO INHERIT/DETACH PARTITION get rid of
no-longer-wanted stats.

2. Make ANALYZE check for and remove any inappropriate stats.

I'm kind of inclined to prefer #1, on the grounds that #2 would
add almost-always-useless cycles to every ANALYZE run forevermore.
On the other hand, #2 seems a bit more robust, in that we'd not
have to remember to consider this issue every time somebody invents
a new flavor of DDL that affects these things.

Thoughts?

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Next
From: Christoph Berg
Date:
Subject: Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind