Re: Parallel Aggregates for string_agg and array_agg
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Stephen Frost <sfrost@snowman.net>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-03-26T21:54:32Z
Lists: pgsql-hackers
On 27 March 2018 at 10:20, Stephen Frost <sfrost@snowman.net> wrote: > 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. That was me. I originally skipped string_agg and array_agg as I thought parallelism would not be much use due to the growth of the size of the state. I thought the combine function could become very expensive as it has to work on each aggregated value, instead of a consolidated result, as the other aggregates provide. The reason for adding this now and not back then is: 1. I was wrong, parallel aggregation can improve performance for these aggregates, and; 2. It's annoying that a single non-partial aggregate in the query disabled parallel aggregation, and; 3. When I originally considered the performance I didn't consider that some queries may filter values before aggregation via a FILTER or a WHERE clause. 4. It's not just parallel aggregation that uses partial aggregation, we can now push aggregation below Append for partitioned tables in some cases. Hopefully, we'll also have "group before join" one day too. While 2 is still true, there should be a reduction in the times this happens. Just the json and xml aggs holding us back from the standard set now. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
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