Re: Improve docs for n_distinct_inherited - Mailing list pgsql-hackers

From David Rowley
Subject Re: Improve docs for n_distinct_inherited
Date
Msg-id CAApHDvobFfXVEeJV1_4fVbYkr47J=f1d5_4pugRhgd6a-5S-mQ@mail.gmail.com
Whole thread Raw
In response to Re: Improve docs for n_distinct_inherited  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: Improve docs for n_distinct_inherited
Improve docs for n_distinct_inherited
List pgsql-hackers
On Mon, 13 Oct 2025 at 14:47, Chao Li <li.evan.chao@gmail.com> wrote:
>
> Hi David,
>
> I think your revision is good and accurate.
>
> On Oct 13, 2025, at 07:42, David Rowley <dgrowleyml@gmail.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
confusionto other readers, maybe change to “when set to a negative value between -1 and 0 (inclusive of -1)” or “when
setto 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

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Improve docs for n_distinct_inherited
Next
From: Alexander Lakhin
Date:
Subject: Re: IO in wrong state on riscv64