Re: [PATCH] backend: compare word-at-a-time in bcTruelen - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: [PATCH] backend: compare word-at-a-time in bcTruelen
Date
Msg-id 49669.71.76.58.95.1246032944.squirrel@dunslane.net
Whole thread Raw
In response to Re: [PATCH] backend: compare word-at-a-time in bcTruelen  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, June 26, 2009 11:39 am, Tom Lane wrote:
> tomas@tuxteam.de writes:
>> On Fri, Jun 26, 2009 at 05:03:11PM +0200, Dimitri Fontaine wrote:
>>> It's becoming somewhat tricky, but maybe the test to do for the
>>> optimisation to get used is n >= threshold && str[n-6] == 0x20, àla
>>> Boyer/Moore?
>
>> That's cute. What about comparing the last aligned word which completely
>> fits in the buffer? Something along the lines of (assuming four-byte
>> words)
>>    * (int*) (4 * ((int) &buf[0]) / 4)
>
> We're trying to avoid adding cycles to the optimization-is-useless case.
> The more expensive this test gets, the slower the unoptimizable case
> becomes.
>

Yeah. Like you, I like the idea of a switch based on string length. I
would suggest a cutoff of something like 36 (length of the string
representation of a UUID). But maybe that will miss lots of optimisable
cases like address fields. I guess those people should really be using
varchar(n) anyway.

cheers

andrew




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCH] backend: compare word-at-a-time in bcTruelen
Next
From: Kris Jurka
Date:
Subject: Re: gettext version problem exposed by buildfarm failures on "canary"