Re: [PATCH] backend: compare word-at-a-time in bcTruelen

From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: tomas(at)tuxteam(dot)de, "Dimitri Fontaine" <dfontaine(at)hi-media(dot)com>, "Jeremy Kerr" <jk(at)ozlabs(dot)org>, "Stephen Frost" <sfrost(at)snowman(dot)net>, "Stefan Kaltenbrunner" <stefan(at)kaltenbrunner(dot)cc>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Subject: Re: [PATCH] backend: compare word-at-a-time in bcTruelen
Date: 2009-06-26 16:15:44
Message-ID: 49669.71.76.58.95.1246032944.squirrel@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, June 26, 2009 11:39 am, Tom Lane wrote:
> tomas(at)tuxteam(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kris Jurka 2009-06-26 17:02:26 Re: gettext version problem exposed by buildfarm failures on "canary"
Previous Message Tom Lane 2009-06-26 15:39:51 Re: [PATCH] backend: compare word-at-a-time in bcTruelen