pgsql: Allow avoiding tuple copy within tuplesort_gettupleslot().

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Allow avoiding tuple copy within tuplesort_gettupleslot().
Date: 2017-04-06 21:50:02
Message-ID: E1cwFI2-0002a2-QN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Allow avoiding tuple copy within tuplesort_gettupleslot().

Add a "copy" argument to make it optional to receive a copy of caller
tuple that is safe to use following a subsequent manipulating of
tuplesort's state. This is a performance optimization. Most existing
tuplesort_gettupleslot() callers are made to opt out of copying.
Existing callers that happen to rely on the validity of tuple memory
beyond subsequent manipulations of the tuplesort request their own
copy.

This brings tuplesort_gettupleslot() in line with
tuplestore_gettupleslot(). In the future, a "copy"
tuplesort_getdatum() argument may be added, that similarly allows
callers to opt out of receiving their own copy of tuple.

In passing, clarify assumptions that callers of other tuplesort fetch
routines may make about tuple memory validity, per gripe from Tom
Lane.

Author: Peter Geoghegan
Discussion: CAM3SWZQWZZ_N=DmmL7tKy_OUjGH_5mN=N=A6h7kHyyDvEhg2DA(at)mail(dot)gmail(dot)com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/fa117ee40330db401da776e7b003f047098a7d4c

Modified Files
--------------
src/backend/executor/nodeAgg.c | 9 ++++++---
src/backend/executor/nodeSort.c | 5 +++--
src/backend/utils/adt/orderedsetaggs.c | 5 +++--
src/backend/utils/sort/tuplesort.c | 28 +++++++++++++++++-----------
src/include/utils/tuplesort.h | 2 +-
5 files changed, 30 insertions(+), 19 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Kevin Grittner 2017-04-06 22:03:20 Re: pgsql: Add infrastructure to support EphemeralNamedRelation references.
Previous Message David Rowley 2017-04-06 21:41:24 Re: [COMMITTERS] pgsql: Collect and use multi-column dependency stats