Re: Performance optimization of btree binary search

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>
Subject: Re: Performance optimization of btree binary search
Date: 2013-12-04 23:48:44
Message-ID: CA+TgmobepaMkZ-QAJBG-hqpcqA1ZGxAJrFw0hcGRzOwxoJmv8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 4, 2013 at 6:33 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> On Wed, Dec 4, 2013 at 1:59 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> Yeah, I think if we can make something like this work, it would be
>> neat-o. Getting this working for int4 would be a good win, as Peter
>> says, but getting it working for both int4 and int8 with the same code
>> would be a significantly better one.
>
> No arguments here. I think I didn't initially suggest it myself out of
> passing concern about the guarantees around how unused Datum bits are
> initialized in all relevant contexts, but having looked at it for a
> second I see that we are of course disciplined there.

Hmm. And yet, there's this:

* When a type narrower than Datum is stored in a Datum, we place it in the
* low-order bits and are careful that the DatumGetXXX macro for it discards
* the unused high-order bits (as opposed to, say, assuming they are zero).
* This is needed to support old-style user-defined functions, since depending
* on architecture and compiler, the return value of a function returning char
* or short may contain garbage when called as if it returned Datum.

And record_image_eq does a rather elaborate dance around here, calling
the appropriate GET_x_BYTES macro depending on the type-width. If we
can really count on the high-order bits to be zero, that's all
completely unnecessary tomfoolery.

--
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 Álvaro Hernández Tortosa 2013-12-04 23:51:51 Re: RFC: programmable file format for postgresql.conf
Previous Message Tom Lane 2013-12-04 23:45:47 Re: Performance optimization of btree binary search