On Thu, 8 May 2025 at 10:40, PG Bug reporting form
<noreply(at)postgresql(dot)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://stream.boxwatch.ru/docs/17/sql-altertable.html