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 1fDcdP-0004oN-9R for pgsql-hackers@arkaria.postgresql.org; Tue, 01 May 2018 21:16:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fDcdN-0007wD-DO for pgsql-hackers@arkaria.postgresql.org; Tue, 01 May 2018 21:16:25 +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 1fDcdN-0007w2-5u for pgsql-hackers@lists.postgresql.org; Tue, 01 May 2018 21:16:25 +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 1fDcdK-000081-63 for pgsql-hackers@postgresql.org; Tue, 01 May 2018 21:16:24 +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 w41LGG94016903; Tue, 1 May 2018 17:16:16 -0400 From: Tom Lane To: Andres Freund cc: Mark Dilger , David Rowley , Alvaro Herrera , Stephen Frost , Tomas Vondra , PostgreSQL-development Subject: Re: Parallel Aggregates for string_agg and array_agg In-reply-to: <20180501211147.3balprbggw3pdpxk@alap3.anarazel.de> References: <20180327002617.fjgkgxmeojfkti7b@alvherre.pgsql> <13700.1522162694@sss.pgh.pa.us> <1C2959D0-56F2-4067-B2AC-DF9A3B1D0FB5@gmail.com> <20180501211147.3balprbggw3pdpxk@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 01 May 2018 14:11:47 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16901.1525209376.1@sss.pgh.pa.us> Date: Tue, 01 May 2018 17:16:16 -0400 Message-ID: <16902.1525209376@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-05-01 14:09:39 -0700, Mark Dilger wrote: >> I don't care which order the data is in, as long as x[i] and y[i] are >> matched correctly. It sounds like this patch would force me to write >> that as, for example: >> >> select array_agg(a order by a, b) AS x, array_agg(b order by a, b) AS y >> from generate_a_b_func(foo); >> >> which I did not need to do before. > Why would it require that? Rows are still processed row-by-row even if > there's parallelism, no? Yeah, as long as we distribute all the aggregates in the same way, it seems like they'd all see the same random-ish input ordering. I can vaguely conceive of future optimizations that might break that, but not what we have today. regards, tom lane