Allow parallel aggregate on string_agg and array_agg

Enterprise / PostgreSQL - David Rowley [postgresql.org] - 23 January 2023 04:35 UTC

This adds combine, serial and deserial functions for the array_agg() and string_agg() aggregate functions, thus allowing these aggregates to partake in partial aggregations. This allows both parallel aggregation to take place when these aggregates are present and also allows additional partition-wise aggregation plan shapes to include plans that require additional aggregation once the partially aggregated results from the partitions have been combined.

Author: David Rowley

16fd03e956 Allow parallel aggregate on string_agg and array_agg
doc/src/sgml/func.sgml | 6 +-
src/backend/optimizer/prep/prepagg.c | 28 +-
src/backend/parser/parse_agg.c | 37 +-
src/backend/utils/adt/array_userfuncs.c | 624 +++++++++++++++++++++++++++++++
src/backend/utils/adt/arrayfuncs.c | 20 +-
src/backend/utils/adt/varlena.c | 207 +++++++++-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_aggregate.dat | 13 +-
src/include/catalog/pg_proc.dat | 27 ++
src/include/parser/parse_agg.h | 2 +
src/include/utils/array.h | 3 +
src/test/regress/expected/aggregates.out | 98 +++++
src/test/regress/sql/aggregates.sql | 62 +++
13 files changed, 1101 insertions(+), 28 deletions(-)

Upstream: git.postgresql.org


  • Share