Re: B-Tree support function number 3 (strxfrm() optimization)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, Marti Raudsepp <marti(at)juffo(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>, Greg Stark <stark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Thom Brown <thom(at)linux(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: B-Tree support function number 3 (strxfrm() optimization)
Date: 2014-09-09 21:25:34
Message-ID: CA+TgmoYEFG56kyweqD=anE=1igaoStkuFQ162Rq91WeEKJxLnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 5, 2014 at 10:45 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> While I gave serious consideration to your idea of having a dedicated
> abbreviation comparator, and not duplicating sortsupport state when
> abbreviated keys are used (going so far as to almost fully implement
> the idea), I ultimately decided that my vote says we don't do that. It
> seemed to me that there were negligible benefits for increased
> complexity. In particular, I didn't want to burden tuplesort with
> having to worry about whether or not abbreviation was aborted during
> tuple copying, or was not used by the opclass in the first place -
> implementing your scheme makes that distinction relevant. It's very
> convenient to have comparetup_heap() "compare the leading sort key"
> (that specifically looks at SortTuple.datum1 pairs) indifferently,
> using the same comparator for "abbreviated" and "not abbreviated"
> cases indifferently. comparetup_heap() does not seem like a great
> place to burden with caring about each combination any more than
> strictly necessary.
>
> I like that I don't have to care about every combination, and can
> treat abbreviation abortion as the special case with the extra step,
> in line with how I think of the optimization conceptually. Does that
> make sense?

No. comparetup_heap() is hip-deep in this optimization as it stands,
and what I proposed - if done correctly - isn't going to make that
significantly worse. In fact, it really ought to make things better:
you should be able to set things up so that ssup->comparator is always
the test that should be applied first, regardless of whether we're
aborted or not-aborted or not doing this in the first place; and then
ssup->tiebreak_comparator, if not NULL, can be applied after that.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-09-09 21:30:44 Re: Spinlocks and compiler/memory barriers
Previous Message Andres Freund 2014-09-09 21:09:43 Re: Spinlocks and compiler/memory barriers