Re: Performance optimization of btree binary search

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, 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-05 14:18:17
Message-ID: 20131205141817.GH14419@alap2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-12-05 08:58:55 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > I don't think we can get rid of that dance in record_image_eq - it very
> > well could used on records originally generated when those bits haven't
> > been guaranteed to be zeroed.
>
> No, you're failing to think about the context here.

Ah yes. I was completely forgetting that
heap_form_tuple()/heap_fill_tuple() will properly take care to only use
meaningful parts of the (to-be-)stored data, not random padding.

Thanks.

> The risk we take by simplifying comparisons in a more general context
> is that some function somewhere might've been sloppy about doing a
> native-type-to-Datum conversion on its result. In the case of V0
> functions that risk is unavoidable except by adding some explicit cleanup
> code, but I'm a bit worried that somebody, particularly third-party code,
> might've sloppily written "return foo" in a V1 function when "return
> Int32GetDatum(foo)" would be correct. In that case, the resultant Datum
> might have not-per-spec high-order bits, and if it reaches the fast
> comparator without ever having been squeezed into a physical tuple,
> we've got a problem.

Too bad V1 hasn't insisted on using PG_RETURN_* macros. That would have
allowed asserts checking against such cases by setting
fcinfo->has_returned = true or such...

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message MauMau 2013-12-05 14:24:00 [bug fix] pg_ctl always uses the same event source
Previous Message Andres Freund 2013-12-05 14:00:42 Re: same-address mappings vs. relative pointers