agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Oleg Ivanov <o15611@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19340: Wrong result from CORR() function
Date: Sat, 06 Dec 2025 01:09:36 -0500
Message-ID: <2107637.1765001376@sss.pgh.pa.us> (raw)
In-Reply-To: <1872685.1764973053@sss.pgh.pa.us>
References: <19340-6fb9f6637f562092@postgresql.org>
	<4ab9867066e9545dd1a7e835a480bb0ecbe1a00d.camel@cybertec.at>
	<CAH1GMznwE=WGJYCZU1ou9iOmNR87NQFSRdYHqE3=JQ3as4P1hQ@mail.gmail.com>
	<375068.1764696127@sss.pgh.pa.us>
	<CAEZATCU8rnyKN3z_5-osk3Bn8dtzWf9nKjTr2E16-ExXiESNrQ@mail.gmail.com>
	<434484.1764707203@sss.pgh.pa.us>
	<CAEZATCUo6skdTfRP1XM1sbMveRo1PgpjzOMZEps69Bbz6-OnKA@mail.gmail.com>
	<513345.1764717860@sss.pgh.pa.us>
	<531516.1764721052@sss.pgh.pa.us>
	<545890.1764725276@sss.pgh.pa.us>
	<CAEZATCXgM=_6KP2RS4ShcAMbVMrVujD+fWs0vD=uOSnD_0dNmg@mail.gmail.com>
	<923070.1764802351@sss.pgh.pa.us>
	<CAEZATCU8=jjP1+dSSos6oXVzToGu-Rofyhv4BBpU31LN9Bo17Q@mail.gmail.com>
	<1872685.1764973053@sss.pgh.pa.us>

I wrote:
> Dean Rasheed <dean.a.rasheed@gmail.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





view thread (24+ messages)  latest in thread

Message-ID: <2107637.1765001376@sss.pgh.pa.us>
Permalink:  ../2107637.1765001376@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2107637.1765001376@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dean.a.rasheed@gmail.com, o15611@gmail.com, laurenz.albe@cybertec.at, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #19340: Wrong result from CORR() function
  In-Reply-To: <2107637.1765001376@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox