Re: PATCH: decreasing memory needlessly consumed by array_agg - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: PATCH: decreasing memory needlessly consumed by array_agg
Date
Msg-id CAMp0ubdqh617FjLrxC7dvMfcURB36QC3Gyp=h5iX-SQ-JyjfAw@mail.gmail.com
Whole thread Raw
In response to Re: PATCH: decreasing memory needlessly consumed by array_agg  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
On Wed, Jan 14, 2015 at 1:52 PM, Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:
> Attached is v8 patch, with a few comments added:
>
> 1) before initArrayResult() - explaining when it's better to use a
>    single memory context, and when it's more efficient to use a
>    separate memory context for each array build state
>
> 2) before makeArrayResult() - explaining that it won't free memory
>    when allocated in a single memory context (and that a pfree()
>    has to be used if necessary)
>
> 3) before makeMdArrayResult() - explaining that it's illegal to use
>    release=true unless using a subcontext
>

I understand there is history to this API, and we need to be
compatible, but the end result is awkward.

I'm wondering whether it would be better to just have a new set of
functions like accumArrayResultElem, etc., and only allow astate=NULL
in the original accumArrayResult(). That cure might be worse than the
disease though.

Regards,    Jeff Davis



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Error check always bypassed in tablefunc.c
Next
From: Kyotaro HORIGUCHI
Date:
Subject: New CF app: changing email sender