From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow nodeSort to perform Datum sorts for byref types
Date: Thu, 27 Oct 2022 20:25:38 +0000
Message-ID: <E1oo9RZ-0014gy-ND@gemulon.postgresql.org> (raw)
Allow nodeSort to perform Datum sorts for byref types
Here we add a new 'copy' parameter to tuplesort_getdatum so that we can
instruct the function not to datumCopy() byref Datums before returning.
Similar to 91e9e89dc, this can provide significant performance
improvements in nodeSort when sorting by a single byref column and the
sort's targetlist contains only that column.
This allows us to re-enable Datum sorts for byref types which was disabled
in 3a5817695 due to a reported memory leak.
Additionally, here we slightly optimize DISTINCT aggregates so that we no
longer perform any datumCopy() when we find the current value not to be
distinct from the previous value. Previously the code would always take a
copy of the most recent Datum and pfree the previous value, even when the
values were the same. Testing shows a small but noticeable performance
increase when aggregate transitions are skipped due to the current
transition value being the same as the prior one.
Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvqS6wC5U==k9Hd26E4EQXH3QR67-T4=Q1rQ36NGvjfVSg@mail.gmail.com
Discussion: https://postgr.es/m/CAApHDvqHonfe9G1cVaKeHbDx70R_zCrM3qP2AGXpGrieSKGnhA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d37aa3d35832afde94e100c4d2a9618b3eb76472
Modified Files
--------------
src/backend/access/heap/heapam_handler.c | 8 ++------
src/backend/executor/nodeAgg.c | 31 +++++++++++++++++++-----------
src/backend/executor/nodeSort.c | 7 ++++---
src/backend/utils/adt/orderedsetaggs.c | 23 +++++++++++++---------
src/backend/utils/sort/tuplesortvariants.c | 18 +++++++++++++++--
src/include/utils/tuplesort.h | 2 +-
6 files changed, 57 insertions(+), 32 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: drowley@postgresql.org
Subject: Re: pgsql: Allow nodeSort to perform Datum sorts for byref types
In-Reply-To: <E1oo9RZ-0014gy-ND@gemulon.postgresql.org>
References: <E1oo9RZ-0014gy-ND@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox