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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: maxim(dot)boguk(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18916: alter table ... set (n_distinct=) completely ignored on partition head and/or individual partitions
Date: 2025-05-07 22:49:24
Message-ID: CAApHDvrGUcw6-WMv9VKiMq2dh_j6o=D9qNecTwaXLPXU=jSvgA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Junwang Zhao 2025-05-07 23:58:17 Re: Incorrect calculation of path fraction value in MergeAppend
Previous Message PG Bug reporting form 2025-05-07 21:18:00 BUG #18916: alter table ... set (n_distinct=) completely ignored on partition head and/or individual partitions