Re: [HACKERS] Sum aggregate calculation for single precsion real

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: [HACKERS] Sum aggregate calculation for single precsion real
Дата
Msg-id 18f1a3f9-d00e-7a3d-94cc-00ae31a59416@BlueTreble.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Sum aggregate calculation for single precsion real  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Ответы Re: [HACKERS] Sum aggregate calculation for single precsion real  (Robert Haas <robertmhaas@gmail.com>)
Re: [HACKERS] Sum aggregate calculation for single precsion real  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Список pgsql-hackers
On 2/13/17 10:45 AM, Konstantin Knizhnik wrote:
> It is not true - please notice query execution time of this two queries:

I bet you'd get even less difference if you simply cast to float8 
instead of adding 0.0. Same result, no floating point addition.

>> The expectation for SUM(float4) is that you want speed and are
>> prepared to cope with the consequences.  It's easy enough to cast your
>> input to float8 if you want a wider accumulator, or to numeric if
>> you'd like more stable (not necessarily more accurate :-() results.
>> I do not think it's the database's job to make those choices for you.
>
> From my point of your it is strange and wrong expectation.
> I am choosing "float4" type for a column just because it is enough to
> represent range of data I have and I need to minimize size of record.

In other words, you've decided to trade accuracy for performance...

> But when I am calculating sum, I expect to receive more or less precise
> result. Certainly I realize that even in case of using double it is

... but now you want to trade performance for accuracy? Why would you 
expect the database to magically come to that conclusion?
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] pg_waldump's inclusion of backend headers is a mess
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] Should we cacheline align PGXACT?