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 1fDcXa-0004NN-Rg for pgsql-hackers@arkaria.postgresql.org; Tue, 01 May 2018 21:10:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fDcXZ-0001RQ-3E for pgsql-hackers@arkaria.postgresql.org; Tue, 01 May 2018 21:10: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 1fDcX6-0006ns-Pv for pgsql-hackers@lists.postgresql.org; Tue, 01 May 2018 21:09:57 +0000 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fDcX2-0008Lk-Dh for pgsql-hackers@postgresql.org; Tue, 01 May 2018 21:09:55 +0000 Received: by mail-pg0-x232.google.com with SMTP id g20-v6so2377045pgv.1 for ; Tue, 01 May 2018 14:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=7ys1Tn/7IXYUX9TNNfQkOvdk8R4nOO/vrOS8sitjqyU=; b=OaVO9myb8z9fL43LiwK+chIigYq+xVKg0UhGozVCdC/di9Rq8Zh8lz/00Dzlr4oAtZ XJU4v+u0ByvtiI78QH/E8P/ff5WjWZ497kjGrVsSlUjxAZrflXhkZy5zQj5J/TX/HfQD V37KA94VPXHrc3/5F7nPIbXk6KjkIEF2bUPtY3AaIoi7GF6AsbQhB/508WAfIEAaYFD7 OouFPafk5uH1vw6buLqcwzE4AL65yPpzX0KdsJQXWcvOna3P9SaQ1R/IuX6WQdEl1mtr 5vrlVN7rDMVjuMUvla/EtDQEafxunQ9ivkhEpQ8xKK/zZecC01oHSV2Ai1UznXoXfUUc f7Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=7ys1Tn/7IXYUX9TNNfQkOvdk8R4nOO/vrOS8sitjqyU=; b=JEIJBRmCv48bHWf5d7v/Wg3HanEPJ5v/bziQZF62RM62YTYq/dqRH5PQZQqtmUkreg YRWarRgSo38YgF7ZvWvvzFvumdAnPzRXWX0v5gBY2dm6bRRFHzOInPnabZZhQHQUfvTy prO+NH3jGJbFE4eGTomXqJmbucOdK0ViZzXIu7JVRmb8Tz1isGEVb0H1EcJW9qUHCeLY 7GME6gW6lYrc1opxEEBXx6PLRBz3+e1mjEoyIEMdzm4srnVRUsp2C2S0Kj0dXlhQkeBZ 5TgS3MVfE+REyfCyuIw683JFYitVI7F3XfFgMuH/OyHHDlt8+C84+KL1c4q+j3GTjNLK uQsA== X-Gm-Message-State: ALQs6tBIKE8Hhbk3fCGnBC/3SI9Pgafkme8YRcWsT9Coypy8Fi6nglNU X+N4gI+/w6nRDPf9daFwPOg= X-Google-Smtp-Source: AB8JxZo/eTftm798z7Hp3ZPj6NOtSxHtUQL0T0u1+Co/mEag9PShyW+PVYdpxVrW7GW4xMErgjyrMA== X-Received: by 2002:a17:902:3343:: with SMTP id a61-v6mr7494436plc.241.1525208989741; Tue, 01 May 2018 14:09:49 -0700 (PDT) Received: from [192.168.2.121] (24-113-186-59.wavecable.com. [24.113.186.59]) by smtp.gmail.com with ESMTPSA id j9sm17353907pff.46.2018.05.01.14.09.48 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 May 2018 14:09:49 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: Parallel Aggregates for string_agg and array_agg From: Mark Dilger In-Reply-To: <13700.1522162694@sss.pgh.pa.us> Date: Tue, 1 May 2018 14:09:39 -0700 Cc: David Rowley , Alvaro Herrera , Stephen Frost , Tomas Vondra , Andres Freund , PostgreSQL-development Content-Transfer-Encoding: quoted-printable Message-Id: <1C2959D0-56F2-4067-B2AC-DF9A3B1D0FB5@gmail.com> References: <20180327002617.fjgkgxmeojfkti7b@alvherre.pgsql> <13700.1522162694@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3124) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Mar 27, 2018, at 7:58 AM, Tom Lane wrote: >=20 > David Rowley writes: >> On 27 March 2018 at 13:26, Alvaro Herrera = wrote: >>> synchronized_seqscans is another piece of precedent in the area, = FWIW. >=20 >> This is true. I guess the order of aggregation could be made more >> certain if we remove the cost based optimiser completely, and just >> rely on a syntax based optimiser. >=20 > None of this is responding to my point. I think the number of people > who actually don't care about aggregation order for these aggregates > is negligible, and none of you have argued against that; you've = instead > selected straw men to attack. I frequently care about the order, but only to the extent that the order is stable between aggregates of several different columns, along the = lines of: select array_agg(a) AS x, array_agg(b) AS y from generate_a_b_func(foo); 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. I would expect a performance = regression from the two newly required sorts. So in that case I agree with Tom. But I also agree with others that I want the parallel aggregation = functionality. Could we perhaps introduce some option for the aggregate to force it to = be stable? Something like: select array_agg(a order undisturbed) AS x, array_agg(b order = undisturbed) AS y from generate_a_b_func(foo); which would not perform an extra sort operation but would guarantee to = not disturb the pre-existing sort order coming from generate_a_b_func(foo)? I don't care about the syntax / keywords in the example above. I'm just looking to get the benefits of the parallel aggregation when I don't = care about ordering while preserving the order for these cases where it = matters. mark=20