pgsql: Optimize various aggregate deserialization functions, take 2

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Optimize various aggregate deserialization functions, take 2
Date: 2023-10-26 21:42:13
Message-ID: E1qw87J-002U2z-FB@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Optimize various aggregate deserialization functions, take 2

f0efa5aec added initReadOnlyStringInfo to allow a StringInfo to be
initialized from an existing buffer and also relaxed the requirement
that a StringInfo's buffer must be NUL terminated at data[len]. Now
that we have that, there's no need for these aggregate deserial
functions to use appendBinaryStringInfo() as that rather wastefully
palloc'd a new buffer and memcpy'd in the bytea's buffer. Instead, we can
just use the bytea's buffer and point the StringInfo directly to that
using the new initializer function.

In Amdahl's law, this speeds up the serial portion of parallel
aggregates and makes sum(numeric), avg(numeric), var_pop(numeric),
var_samp(numeric), variance(numeric), stddev_pop(numeric),
stddev_samp(numeric), stddev(numeric), array_agg(anyarray),
string_agg(text) and string_agg(bytea) scale better in parallel queries.

Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvr%3De-YOigriSHHm324a40HPqcUhSp6pWWgjz5WwegR%3DcQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0c882a298881056176a27ccc44c5c3bb7c8f308c

Modified Files
--------------
src/backend/utils/adt/array_userfuncs.c | 20 +++++++----------
src/backend/utils/adt/numeric.c | 40 +++++++++++++--------------------
src/backend/utils/adt/varlena.c | 10 ++++-----
3 files changed, 28 insertions(+), 42 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-10-27 02:17:46 pgsql: Remove buffers_backend and buffers_backend_fsync from pg_stat_ch
Previous Message Peter Eisentraut 2023-10-26 11:19:54 pgsql: Add "Add trailing commas to enum definitions" to .git-blame-igno