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