Re: BUG #19340: Wrong result from CORR() function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Oleg Ivanov <o15611(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19340: Wrong result from CORR() function
Date: 2025-12-06 06:09:36
Message-ID: 2107637.1765001376@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
>> Looking at float8_regr_accum(), I think it would be preferable to
>> arrange for it to leave Sxx, Syy, and Sxy zero until distinct X and Y
>> values are seen. I.e., something like this:

> That seems like a good idea. I was initially worried that the extra
> isnan() checks would slow down aggregation noticeably in the normal
> case where we soon discover that the inputs aren't all equal.

BTW, re-reading the patch, I now think we should drop the initial

if (isnan(commonX) || isnan(commonY))

test, instead bulling ahead with computing tmpX/tmpY/scale, and
only skip the updates of Sxx/Syy/Sxy when we have constant inputs.
Using that initial test is optimizing for constant inputs at the
expense of non-constant inputs, which seems like the wrong way
to bet.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dean Rasheed 2025-12-06 11:51:20 Re: BUG #19340: Wrong result from CORR() function
Previous Message Tom Lane 2025-12-06 01:12:12 Re: BUG #19341: REPLACE() fails to match final character when using nondeterministic ICU collation