From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Florian Pflug <fgp(at)phlo(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Rowley <dgrowleyml(at)gmail(dot)com>, Kevin Grittner <kgrittn(at)ymail(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-04-10 01:10:00 |
Message-ID: | CAEZATCXqJwgF5v1ueTg0L7io+0Zo5stSFi0h8Fuo6xDY-_KAhw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 10 April 2014 01:13, Florian Pflug <fgp(at)phlo(dot)org> wrote:
> Also, the *only* reason that SUM(int2|int4) cannot use int8 as it's
> transition type is that it needs to return NULL, not 0, if zero rows
> were aggregates. It might seems that it could just use int8 as state
> with initial value NULL, but that only works if the transition functions
> are non-strict (since the special case of state type == input type doesn't
> apply here). And for non-strict transition functions need to deal with
> NULL inputs themselves, which means counting the number of non-NULL inputs..
>
> That problem would go away though if we had support for an initalfunction,
> which would receive the first input value and initialize the state. In
> the case of SUM(), the initial function would be strict, and thus would be
> called on the first non-NULL input value, which it'd convert to int8 and
> return as the new state.
>
Ah snap!
> However, I still believe the best approach at this point is to just work
> on making int4_avg_accum faster. I still see no principal reason what it
> has to be noticeably slower - the only additional work it absolutely *has*
> to perform is *one* 64-bit increment.
>
In the best case that would make sum() not noticeably slower than
avg(), whereas using a firsttrans/initialfunction would potentially
make both of them faster than they currently are, and not just in
window queries.
Also, IMO a first/initial function leads to a cleaner separation of
logic, allowing some of the transition functions to be simplified
rather than becoming more complex.
Regards,
Dean
From | Date | Subject | |
---|---|---|---|
Next Message | Prabakaran, Vaishnavi | 2014-04-10 01:40:12 | Re: New option in pg_basebackup to exclude pg_log files during base backup |
Previous Message | Ian Barwick | 2014-04-10 00:58:59 | Re: Patch: add psql tab completion for event triggers |