Re: Parallel Aggregates for string_agg and array_agg
Magnus Hagander <magnus@hagander.net>
From: Magnus Hagander <magnus@hagander.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Rowley <david.rowley@2ndquadrant.com>,
Stephen Frost <sfrost@snowman.net>, Tomas Vondra <tomas.vondra@2ndquadrant.com>,
Andres Freund <andres@anarazel.de>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-03-27T07:06:59Z
Lists: pgsql-hackers
On Tue, Mar 27, 2018 at 12:28 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > David Rowley <david.rowley@2ndquadrant.com> writes: > > On 27 March 2018 at 09:27, Tom Lane <tgl@sss.pgh.pa.us> wrote: > >> I do not think it is accidental that these aggregates are exactly the > ones > >> 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 > notes: > >> SELECT DISTINCT and UNION/INTERSECT/EXCEPT no longer always produce > sorted 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. > I think you are quite wrong in claiming that only a tiny fraction of the users are going to care. This may, and quite probably does, hold true for string_agg(), but not for array_agg(). I see a lot of cases where people use that to load it into an unordered array/hashmap/set/whatever on the client side, which looses ordering *anyway*,and they would definitely benefit from it. -- Magnus Hagander Me: https://www.hagander.net/ <http://www.hagander.net/> Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
Commits
-
Fix unstable aggregate regression test
- f5d0e866404a 16.3 landed
- d6a6957d53e3 17.0 landed
-
Allow parallel aggregate on string_agg and array_agg
- 16fd03e95654 16.0 landed
-
Improve performance of ORDER BY / DISTINCT aggregates
- 1349d2790bf4 16.0 cited
-
Support ORDER BY within aggregate function calls, at long last providing a
- 34d26872ed81 9.0.0 cited
-
Fix broken markup.
- 6a6efb964092 9.0.0 cited