Re: PATCH: decreasing memory needlessly consumed by array_agg

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: decreasing memory needlessly consumed by array_agg
Date: 2015-01-20 00:03:08
Message-ID: CAMp0ubdqh617FjLrxC7dvMfcURB36QC3Gyp=h5iX-SQ-JyjfAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 14, 2015 at 1:52 PM, Tomas Vondra
<tomas(dot)vondra(at)2ndquadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2015-01-20 00:44:29 New CF app: changing email sender
Previous Message Michael Paquier 2015-01-19 23:47:56 Re: Error check always bypassed in tablefunc.c