Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2nbE-0003Bg-U4 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2017 00:13:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e2nbE-0007ob-Dr for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Oct 2017 00:13:12 +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 1e2nbD-0007nR-7d for pgsql-hackers@postgresql.org; Fri, 13 Oct 2017 00:13:11 +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 1e2nbA-0002DC-5w for pgsql-hackers@postgresql.org; Fri, 13 Oct 2017 00:13:10 +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 v9D0CpOm007198; Thu, 12 Oct 2017 20:12:51 -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> <6042.1507851674@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Fri, 13 Oct 2017 12:58:17 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7196.1507853571.1@sss.pgh.pa.us> Date: Thu, 12 Oct 2017 20:12:51 -0400 Message-ID: <7197.1507853571@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:41, Tom Lane wrote: >> 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". > hmm, maybe I'm lacking imagination here, but surely the final function > is either destructive or it's not? I can't understand what the > difference between nodeAgg.c calling the finalfn multiple times on the > same state and nodeWindowAgg.c doing it. Maybe there's something I'm > not accounting for that you are? nodeWindowAgg is doing something more: not only is it calling the finalfn repeatedly, but it's continuing to mutate the transition state in between. The ordered-set aggs provide a counterexample to considering that to be equivalent to state merging. The OSAs can cope with state merging as long as they have a flag to make sure only the first finalfn does tuplesort_performsort ... but that's not good enough to make them workable as window aggs. Once we sort, we can't absorb more rows into the tuplesort object. 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