Re: [HACKERS] array_accum aggregate

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, pgsql-patches(at)postgresql(dot)org, Joe Conway <mail(at)joeconway(dot)com>
Subject: Re: [HACKERS] array_accum aggregate
Date: 2006-10-13 16:44:25
Message-ID: 20061013164425.GL24675@kenobi.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

* Tom Lane (tgl(at)sss(dot)pgh(dot)pa(dot)us) wrote:
> Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > The other issue is, in the above scenario
> > is it acceptable to modify the result of my_sfunc(null, 1) in the ,2
> > call?
>
> Yes, because the only place a nonnull value of the type could have come
> from is a my_sfunc call; since it's a pseudotype, we don't allow it on
> disk. (We might also need a hack to prevent the type from being used as
> a record-type component ... not sure if that comes for free with being a
> pseudotype currently.)

Ah, ok.

> > As for a type for each such aggregate, that seems reasonable to me,
> > honestly.
>
> The ugly part is that we'd still need a way for the planner to recognize
> this class of types.

Hrm, true. I would agree that they would need more memory than most
aggregates. It seems likely to me that worst offenders are going to be
of the array_accum type- store all tuples coming in. Therefore, my
suggestion would be that the memory usage be estimated along those lines
and allow for hashagg when there's enough memory to keep all the tuples
(or rather the portion of the tuple going into the aggregate) in memory
(plus some amount of overhead, maybe 10%). That doesn't help with how
to get the planner to recognize this class of types though. I don't
suppose we already have a class framework which the planner uses to
group types which have similar characteristics?

> > Additionally, we'd have to be
> > able to mark the types as being polymorhpic along the same lines as
> > anyelement/anyarray.
>
> What for?

So that the finalfunc can be polymorphic along the lines of my suggested
aaccum_sfunc(anyarray,anyelement) returns anyarray and
aaccum_ffunc(anyarray) returns anyarray. If the state type isn't
polymorphic then PG won't let me create a function from it which returns
a polymorphic, aiui.

Thanks,

Stephen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-10-13 16:45:23 Re: ./configure argument checking
Previous Message Zdenek Kotala 2006-10-13 16:42:51 Re: Updated version of FAQ_Solaris

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-10-13 17:06:17 Re: [HACKERS] array_accum aggregate
Previous Message Zdenek Kotala 2006-10-13 16:42:51 Re: Updated version of FAQ_Solaris