Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2n6Z-00018b-1D for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Oct 2017 23:41:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2n6Y-0002JL-EH for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Oct 2017 23:41:30 +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 1e2n6X-0002IJ-Ax for pgsql-hackers@postgresql.org; Thu, 12 Oct 2017 23:41:29 +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 1e2n6U-0001Ym-O1 for pgsql-hackers@postgresql.org; Thu, 12 Oct 2017 23:41:28 +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 v9CNfEek006043; Thu, 12 Oct 2017 19:41:14 -0400 From: Tom Lane To: David Rowley cc: Heikki Linnakangas , PostgreSQL-development Subject: Re: Aggregate transition state merging vs. hypothetical set functions In-reply-to: References: <4834.1507849699@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Fri, 13 Oct 2017 12:29:32 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6041.1507851674.1@sss.pgh.pa.us> Date: Thu, 12 Oct 2017 19:41:14 -0400 Message-ID: <6042.1507851674@sss.pgh.pa.us> 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 13 October 2017 at 12:08, Tom Lane wrote: >> Therefore, I think we need to bite the bullet and provide an aggregate >> property (CREATE AGGREGATE argument / pg_aggregate column) that tells >> whether the aggregate supports transition state merging. Likely this >> should have been in the state-merging patch to begin with, but better >> late than never. > Are you considering that this is an option only for ordered-set > aggregates or for all? All. > If the user defines their normal aggregate as not safe for merging, > then surely it'll not be suitable to be used as a window function > either, since the final function will also be called there multiple > times per state. Yeah, we would probably also want to check the flag in nodeWindowAgg. Not sure exactly how that should play out --- maybe we end up with a tri-valued property "works as normal agg without merging, works as normal agg with merging, works as window agg". But this would arguably be an improvement over the current situation. Right now I'm sure there are user-written aggs out there that will just crash if used as a window agg, and the authors don't have much choice because the performance costs of not modifying the transition state in the finalfn are higher than they're willing to bear. At least with a flag they could ensure that the case will fail cleanly. 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