Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0abo-0000bl-BO for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 22:28:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0abn-0003O1-4S for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 22:28:55 +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.89) (envelope-from ) id 1f0abm-0003Nr-Tk for pgsql-hackers@lists.postgresql.org; Mon, 26 Mar 2018 22:28:54 +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.89) (envelope-from ) id 1f0abj-0001ut-G5 for pgsql-hackers@postgresql.org; Mon, 26 Mar 2018 22:28:54 +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 w2QMSk9F022069; Mon, 26 Mar 2018 18:28:46 -0400 From: Tom Lane To: David Rowley cc: Stephen Frost , Tomas Vondra , Andres Freund , PostgreSQL-development Subject: Re: Parallel Aggregates for string_agg and array_agg In-reply-to: References: <24abe018-b3c6-2117-b5b9-39e660db00bd@2ndquadrant.com> <1b6ee15c-c218-761e-0120-c1ed438e2db2@2ndquadrant.com> <657be73a-a21d-0ae1-5c62-870afbdfddd4@2ndquadrant.com> <20180326022647.GL24540@tamriel.snowman.net> <20180326132009.GN24540@tamriel.snowman.net> <6538.1522096067@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 27 Mar 2018 11:05:07 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22067.1522103326.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 26 Mar 2018 18:28:46 -0400 Message-ID: <22068.1522103326@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > On 27 March 2018 at 09:27, Tom Lane wrote: >> I do not think it is accidental that these aggregates are exactly the o= nes >> that do not have parallelism support today. Rather, that's because you >> just about always have an interest in the order in which the inputs get >> aggregated, which is something that parallel aggregation cannot support= . > This very much reminds me of something that exists in the 8.4 release no= tes: >> SELECT DISTINCT and UNION/INTERSECT/EXCEPT no longer always produce sor= ted output (Tom) That's a completely false analogy: we got a significant performance benefit for a significant fraction of users by supporting hashed aggregation. My argument here is that only a very tiny fraction of string_agg/array_agg users will not care about aggregation order, and thus I don't believe that this patch can help very many people. Against that, it's likely to hurt other people, by breaking their queries and forcing them to insert expensive explicit sorts to fix it. Even discounting the backwards-compatibility question, we don't normally adopt performance features for which it's unclear that the net gain over all users is positive. Maybe what that says is that rather than giving up on this altogether, we should shelve it till we have less stupid planner+executor behavior for ORDER BY inside aggregates. That's been on the to-do list for a long while, but not risen to the top ... regards, tom lane