pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: neverov.max@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17329: Aggregate Functions Precision Error
Date: Wed, 08 Dec 2021 16:45:06 -0500
Message-ID: <3688943.1638999906@sss.pgh.pa.us> (raw)
In-Reply-To: <17329-8c3b204b1716bd24@postgresql.org>
References: <17329-8c3b204b1716bd24@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> Aggregate functions (described here
> https://www.postgresql.org/docs/current/functions-aggregate.html#FUNCTIONS-AGGREGATE-STATISTICS-TABL...)
> that are defined for double precision type suffer from loss of
> significance.

This is pretty much inherent in all uses of float arithmetic.
You might be happier using the numeric type (of course, that's
much slower).

Another possibility, for some aggregates, is to order the inputs
in a way that minimizes error accumulation.  For example,

select sum(f1 order by abs(f1)) from ...

I don't know offhand what the best such incantation is for covar_pop;
it might depend on the problem.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <3688943.1638999906@sss.pgh.pa.us>
Permalink:  ../3688943.1638999906@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3688943.1638999906@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, neverov.max@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17329: Aggregate Functions Precision Error
  In-Reply-To: <3688943.1638999906@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox