From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | Florian Pflug <fgp(at)phlo(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Greg Stark <stark(at)mit(dot)edu>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCH] Negative Transition Aggregate Functions (WIP) |
Date: | 2014-01-16 18:38:32 |
Message-ID: | 52D82728.8020605@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 01/16/2014 01:02 PM, David Rowley wrote:
> sum(bigint) became a bit weird as it uses numeric types internally, so I
> had to keep the do_numeric_discard() function to support it.
It's pretty weird that we have implemented sum(bigint) that way. I
understand that the result is a numeric so that it won't overflow, but
implementing it by converting every value to numeric is naive.
I propose that we reimplement sum(bigint) in a more efficient way: For
the internal state, let's use an int8 and a numeric overflow field. The
transition function adds to the int8 variable, and checks for overflow.
On overflow, increment the numeric field by one. In the final function,
multiply the numeric by 2^64, and add the residual int8 value.
- Heikki
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-01-16 18:46:00 | Re: Why conf.d should be default, and auto.conf and recovery.conf should be in it |
Previous Message | Stephen Frost | 2014-01-16 18:38:13 | Re: Why conf.d should be default, and auto.conf and recovery.conf should be in it |