Re: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates
Date: 2015-12-18 04:43:40
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

On Wed, Dec 16, 2015 at 12:04 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
>> What kind of state is that? Can't we define this in terms of what it
>> is rather than how it gets that way?
> It's zeroed.
> I guess we can update everything, including existing comments, to reflect that.

Attached revision updates both the main commit (the optimization), and
the backpatch commit (updated the contract).


* Changes commit intended for backpatch to 9.5 to use new "zeroed"
terminology (not "void" representation).

* Puts fix within mergerun() (for this patch) in the same backpatch
commit. We might as well keep this consistent, even though the
correctness of 9.5 does not actually hinge upon having this change --
there is zero risk of breaking something in 9.5, and avoiding
backpatching this part can only lead to confusion in the future.

* Some minor tweaks to tuplesort.c. Make sure that
tuplesort_putdatum() zeroes datum1 directly for NULL values. Comment

* Add comment to the datum case, discussing restriction there.

I was wrong when I said that the datum sort case currently tacitly
acknowledges as possible/useful something that the revised SortSupport
contract will forbid (I wrote that e-mail in haste).

What I propose to make the SortSupport contract forbid here is
abbreviated keys that are *themselves* pass-by-reference. It is true
that today, we do not support pass-by-value types with abbreviated
keys for the datum case only (such opclass support could be slightly
useful for float8, for example -- int8 comparisons of an alternative
representation might be decisively cheaper). But that existing
restriction is entirely distinct to the new restriction I propose to
create. It seems like this distinction should be pointed out in
passing, which I've done.

Peter Geoghegan

Attachment Content-Type Size
0002-Reuse-abbreviated-keys-in-ordered-set-aggregates.patch text/x-patch 16.4 KB
0001-Tighten-SortSupport-abbreviated-key-contract.patch text/x-patch 9.0 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2015-12-18 04:46:55 [PATCH] Copy-pasteo in logical decoding
Previous Message Michael Paquier 2015-12-18 02:51:36 Re: Small fix in pg_rewind (redundant declaration)