Re: Improve docs for n_distinct_inherited

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improve docs for n_distinct_inherited
Date: 2025-10-13 03:48:42
Message-ID: CAApHDvobFfXVEeJV1_4fVbYkr47J=f1d5_4pugRhgd6a-5S-mQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 13 Oct 2025 at 14:47, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
> Hi David,
>
> I think your revision is good and accurate.
>
> On Oct 13, 2025, at 07:42, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> I wonder if ", since the multiplication by the number of rows in the
> table is not performed until query planning time" should be deleted
> since I modified the text earlier to talk about "the query planner”.
>
>
> Yeah, with your rewrite, that clause now feels a little redundant. I think it can be removed entirely.

I've now removed that part.

> The other thing that doesn’t belong to your change but as you are touching here:
>
> “When set to a negative value, which must be greater than or equal to -1"
>
> When I first time read the doc, I was confused. Because no easier sentence indicated “n_distinct” is of float type. I thought “greater than” was a typo. When I read through, the later example (0.5) resolved my confusion. To avoid the same confusion to other readers, maybe change to “when set to a negative value between -1 and 0 (inclusive of -1)” or “when set to a negative value, which must be in the range -1<= value < 0”.

I agree that part is a bit clumsy. Starting at this cold again today I
also thought it must mean less than -1, so rewording that seems like a
good idea.

It now reads:

Fractional values may also be specified by using values below 0 and above
or equal to -1. This instructs the query planner to estimate the number
of distinct values by multiplying the absolute value of the specified
number by the estimated number of rows in the table.

Updated patch attached.

David

Attachment Content-Type Size
doc_n_distinct_inherited_v4.patch application/octet-stream 32.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Lakhin 2025-10-13 04:00:00 Re: IO in wrong state on riscv64
Previous Message David Rowley 2025-10-13 03:43:46 Re: Improve docs for n_distinct_inherited