Re: Sum aggregate calculation for single precsion real

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Greg Stark <stark(at)mit(dot)edu>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Sum aggregate calculation for single precsion real
Date: 2017-02-17 15:53:56
Message-ID: 19387.1487346836@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Fri, Feb 17, 2017 at 6:51 AM, Greg Stark <stark(at)mit(dot)edu> wrote:
>> Moreover, it wouldn't be hard to make sum(float4) use a float8 as an
>> accumulator and then cast to float4 for the final state. That would be
>> 100% compatible with the existing behaviour aside from producing more
>> accurate results.

> Sure, but if somebody wants that, they can get it already just by a
> minor change to the SQL. The point is that adding up float4 as float4
> is a reasonable thing to do. Adding it as float8 might also be a
> reasonable thing to do, but nobody's keeping anybody from doing that.

Also, if we changed sum(float4) to work that way, it would become very
hard to sum float4 in float4 --- you'd pretty much have to build your
own aggregate function, which is a lot harder than just inserting a
cast. The argument for changing this boils down to "nobody would ever
want that", which I do not think I buy. It's been a long time since
I studied numerical analysis, but I think there are applications where
you do want to do that.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2017-02-17 16:12:45 Re: Index corruption with CREATE INDEX CONCURRENTLY
Previous Message Tom Lane 2017-02-17 15:45:35 Re: Instability in select_parallel regression test