Re: BUG #18916: alter table ... set (n_distinct=) completely ignored on partition head and/or individual partitions - Mailing list pgsql-bugs

From David Rowley
Subject Re: BUG #18916: alter table ... set (n_distinct=) completely ignored on partition head and/or individual partitions
Date
Msg-id CAApHDvrGUcw6-WMv9VKiMq2dh_j6o=D9qNecTwaXLPXU=jSvgA@mail.gmail.com
Whole thread Raw
In response to BUG #18916: alter table ... set (n_distinct=) completely ignored on partition head and/or individual partitions  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Thu, 8 May 2025 at 10:40, PG Bug reporting form
<noreply@postgresql.org> wrote:
> I don't know it's missing feature or actual bug in case of native
> partitioning
> alter table partition_head alter somefield set (n_distinct=...)
> and/or alter table individual_paritition alter somefield set
> (n_distinct=...)
> simple have no effect in distinct somefield estimations, thus leading to
> very bad plans.

You'll need to use n_distinct_inherited since partitioned tables use
the inheritance statistics.

The documentation in [1] does not seem to highlight this very well.

David

[1] https://www.postgresql.org/docs/17/sql-altertable.html



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18916: alter table ... set (n_distinct=) completely ignored on partition head and/or individual partitions
Next
From: Junwang Zhao
Date:
Subject: Re: Incorrect calculation of path fraction value in MergeAppend