Re: Rethinking representation of partial-aggregate steps

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Rethinking representation of partial-aggregate steps
Date: 2016-06-26 15:36:35
Message-ID: 24924.1466955395@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
> On 26 June 2016 at 04:07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> After a bit of thought, maybe AggDivision or AggSplit or something
>> along those lines?

> How about AggCompletion? It's seems to fit well in the sense of the
> aggregation being partial or not, but less well when you consider
> serialisation and combining states.

After having worked on the patch some, I think that AggSplit is a pretty
good choice, because it is about how we split up the calculation of an
aggregate. And it's short, which is a good thing for something that's
going to be a component of assorted names.

What I've got at the moment looks like:

/* Primitive options supported by nodeAgg.c: */
#define AGGSPLITOP_COMBINE 0x1 /* substitute combinefn for transfn */
#define AGGSPLITOP_SERIALIZE 0x2 /* apply serializefn to output */
#define AGGSPLITOP_DESERIALIZE 0x4 /* apply deserializefn to input */
#define AGGSPLITOP_FINALIZE 0x8 /* run finalfn */

/* Supported operating modes (i.e., useful combinations of these options): */
typedef enum AggSplit
{
/* Basic, non-split aggregation: */
AGGSPLIT_SIMPLE = AGGSPLITOP_FINALIZE,
/* Initial phase of partial aggregation, with serialization: */
AGGSPLIT_PARTIAL_SERIAL = AGGSPLITOP_SERIALIZE,
/* Final phase of partial aggregation, with deserialization: */
AGGSPLIT_FINAL_DESERIAL = AGGSPLITOP_COMBINE | AGGSPLITOP_DESERIALIZE | AGGSPLITOP_FINALIZE
} AggSplit;

/* Test macros for the primitive options: */
#define DO_AGGSPLIT_COMBINE(as) (((as) & AGGSPLITOP_COMBINE) != 0)
#define DO_AGGSPLIT_SERIALIZE(as) (((as) & AGGSPLITOP_SERIALIZE) != 0)
#define DO_AGGSPLIT_DESERIALIZE(as) (((as) & AGGSPLITOP_DESERIALIZE) != 0)
#define DO_AGGSPLIT_FINALIZE(as) (((as) & AGGSPLITOP_FINALIZE) != 0)

Looking at this in the light of morning, I'm rather strongly tempted to
invert the sense of the FINALIZE option, so that "simple" mode works out
as zero, ie, select no options. Maybe call it SKIPFINAL instead of
FINALIZE?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Zhidenkov 2016-06-26 18:05:52 Re: Memory leak in Pl/Python
Previous Message Julien Rouhaud 2016-06-26 10:27:27 Re: Rename max_parallel_degree?