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 1f0ZXP-0005EC-Cc for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 21:20:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0ZXO-0003Rm-1f for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 21:20:18 +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 1f0ZXI-0002nT-Ci for pgsql-hackers@lists.postgresql.org; Mon, 26 Mar 2018 21:20:12 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0ZXE-0000Kt-6B for pgsql-hackers@postgresql.org; Mon, 26 Mar 2018 21:20:11 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id D44055F79C; Mon, 26 Mar 2018 17:20:06 -0400 (EDT) Date: Mon, 26 Mar 2018 17:20:06 -0400 From: Stephen Frost To: Tomas Vondra Cc: Tom Lane , David Rowley , Andres Freund , PostgreSQL-development Subject: Re: Parallel Aggregates for string_agg and array_agg Message-ID: <20180326212006.GT24540@tamriel.snowman.net> References: <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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="gn1ylXQ+YRNuZICZ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --gn1ylXQ+YRNuZICZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Tomas Vondra (tomas.vondra@2ndquadrant.com) wrote: > On 03/26/2018 10:27 PM, Tom Lane wrote: > > I fear that what will happen, if we commit this, is that something like > > 0.01% of the users of array_agg and string_agg will be pleased, another > > maybe 20% will be unaffected because they wrote ORDER BY which prevents > > parallel aggregation, and the remaining 80% will scream because we broke > > their queries. Telling them they should've written ORDER BY isn't going > > to cut it, IMO, when the benefit of that breakage will accrue only to s= ome > > very tiny fraction of use-cases. >=20 > Isn't the ordering unreliable *already*? It depends on ordering of > tuples on the input. So if the table is scanned by index scan or > sequential scan, that will affect the array_agg/string_agg results. If > the input is a join, it's even more volatile. It's not even just that- for a seq scan, it'll also depend on if anyone else is also scanning the table as we might not start at the beginning of the table thanks to synchronize seq scans. > IMHO it's not like we're making the ordering unpredictable - it's been > like that since forever. Yeah, there certainly seems like a lot of opportunity for the ordering to end up being volatile already and queries depending on it not changing really shouldn't be making that assumption. I do think it was probably a bad move on our part to say that ordering a subquery will "usually" work in the documentation but having that slip-up in the documentation mean that we actually *are* going to guarantee it'll always work to use a subquery ordering to feed an aggregate is a pretty big stretch (and is it even really true today anyway? the documentation certainly doesn't seem to be clear on that...). > Also, how is this different from ORDER BY clause? If a user does not > specify an ORDER BY clause, I don't think we'd care very much about > changes to output ordering due to plan changes, for example. This seems like it boils down to "well, everyone *knows* that rows can come back in any order" combined with "our docs claim that an ordered subquery will *usually* work". In the end, I do tend to agree that we probably should add parallel support to these aggregates, but it'd also be nice to hear from those who had worked to add parallelism to the various aggregates as to if there was some reason these were skipped. Thanks! Stephen --gn1ylXQ+YRNuZICZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJauWQGAAoJEO1sijiDR2RVa2sQAId5/u+m8l17kG7oYB6QftsW aeJ7rNZPAhbbvvtH78BpmbifLv9h7bu7sP9CI6exZk+/yQar0McmAd5FpBVNQXgn R+onhBVfX1/CRYXrSOkGc1yXjgjo39pn4xdO6YP2rlnpNJ1vhfUc5vrnX+mKFLT0 YpNn5LnunXGrGRR0ECz5uq5M4zqMKtz9EAbcWZsY2kq2kp9krbUSbuYdWuUfsdHn C/GftzEmC46qf8DI/u4IbflNF2fGXxzLeD1ill5E6Vml5+S93KB0GNM0qxTEWTt3 DRBCFPeh6ORp4JinfzOG6CNWKxvMA0nSf/yML1QLHnp6ygKqL7iZvFs5IRdtNkZY lGxvDzAiHl4D1Ul10p2BMwo+bNmePbfZeWQ6dxi/fFbc2LaAQwINQBM6fgXseEXN Vd+PqAZN6eGwkuV9O2AKT/g+ij+e/0xkTTN7hfUkRavMo9JH4z5fwrEyVx2+0Hys xbtm8iNy083nyR3b0xRsroaO+uPvXJgaXg4gzxLfVmtQfjORgPHd9/h4gVcECgvn YkqWH6osQXW8Nxs3eIVEohOu9Es1GLApoWdLh0ehhvYvFI1+dL2Vi3+q772TdjsH 7SVABzC9ZeYvKdMe7jPDHbksRcOGP9TUk6YuoADVpA1rhybQmrwJYXYf3x3+GTuE pPjG+ZGt0l/1TeQiK5Mc =rwqJ -----END PGP SIGNATURE----- --gn1ylXQ+YRNuZICZ--