Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG64U-0001cU-Iq for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jun 2016 14:57:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bG64U-0007i9-5U for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jun 2016 14:57:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bG64T-0007gq-DM for pgsql-hackers@postgresql.org; Thu, 23 Jun 2016 14:57:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bG64Q-00074j-Hs for pgsql-hackers@postgresql.org; Thu, 23 Jun 2016 14:57:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u5NEvQ1w018444; Thu, 23 Jun 2016 10:57:27 -0400 From: Tom Lane To: David Rowley cc: Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Parallelized polymorphic aggs, and aggtype vs aggoutputtype In-reply-to: References: <8229.1466109074@sss.pgh.pa.us> <14538.1466116810@sss.pgh.pa.us> <22037.1466129876@sss.pgh.pa.us> <27247.1466185504@sss.pgh.pa.us> <10050.1466637736@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Thu, 23 Jun 2016 15:16:12 +1200" Date: Thu, 23 Jun 2016 10:57:26 -0400 Message-ID: <18443.1466693846@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org David Rowley writes: > On 23 June 2016 at 11:22, Tom Lane wrote: >> The behavior that I'd expect (and that I documented) for a deserialization >> function is that it just allocates its result in the current, short-lived >> memory context, since it will be the combine function's responsibility to >> merge that into the long-lived transition state. But it looks to me like >> the deserialization functions in numeric.c are allocating their results >> in the aggregate context, which will mean a leak. (For example, >> numeric_avg_deserialize creates its result using makeNumericAggState >> which forces the result into the agg context.) > Yes, you're right. > In the end I decided to add a makeNumericAggStateCurrentContext() > function which does not perform any memory context switching at all. > It seems like this can be used for the combine functions too, since > they've already switched to the aggregate memory context. This should > save a few cycles during aggregate combine, and not expend any extra > as some alternatives, like adding a flag to makeNumericAggState(). You missed the ones using makePolyNumAggState --- I fixed that and pushed it. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers