Re: Improve rowcount estimate for UNNEST(column) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Improve rowcount estimate for UNNEST(column)
Date
Msg-id 3699083.1701030124@sss.pgh.pa.us
Whole thread Raw
In response to Re: Improve rowcount estimate for UNNEST(column)  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: Improve rowcount estimate for UNNEST(column)
List pgsql-hackers
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Sat, 2023-11-25 at 09:19 -0800, Paul A Jungwirth wrote:
>> Here is a patch to improve rowcount estimates for
>> `UNNEST(some_array_column)`. Today we hard code this to 10, but we
>> have statistics about array size, so it's easy to use them.

> The idea sounds good to me.

I didn't read the patch either yet, but it seems like a reasonable idea.

> I didn't test or scrutinize the code, but I noticed that you use
> EXPLAIN in the regression tests.  I think that makes the tests vulnerable
> to changes in the parameters or in the block size.

Yes, this regression test is entirely unacceptable; the numbers will
not be stable enough.  Even aside from the different-settings issue,
you can't rely on ANALYZE deriving exactly the same stats every time.
Usually what we try to do is devise a query where the plan shape
changes because of the better estimate.  That typically will provide
some insulation against small changes in the numerical estimates.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Improve rowcount estimate for UNNEST(column)
Next
From: Peter Smith
Date:
Subject: Re: GUC names in messages