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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: christoph(dot)berg(at)credativ(dot)de
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Date: 2021-07-26 14:29:24
Message-ID: 86586.1627309764@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Christoph Berg 2021-07-26 15:16:33 Re: BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind
Previous Message PG Bug reporting form 2021-07-26 12:54:22 BUG #17123: ALTER TABLE ... NO INHERIT leaves orphaned statistics behind