On Fri, 2007-05-04 at 13:52 -0400, Tom Lane wrote:
> Jeff Davis <pgsql@j-davis.com> writes:
> > I used strcmp() and strcoll() in a tight loop, and the result was
> > indistinguishable.
>
> That's not particularly credible ... were you testing this in a
> standalone test program? If so, did you remember to do setlocale()
> first? Without that, you'll be in C locale regardless of environment
> contents.
I have attached a revised cmp.c that includes some extra checks. It
looks like the locale is being set correctly and still I don't see a
difference.
------------------------------------------------------------------------
$ gcc --version
gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
$ uname -a
_____________ 2.6.9-34.ELsmp #1 SMP Wed Mar 8 00:27:03 CST 2006 i686
i686 i386 GNU/Linux
$ ./cmp
locale set to: en_US.UTF-8
strcmp time elapsed: 2034183 us
strcoll time elapsed: 2019880 us
------------------------------------------------------------------------
If I had to guess, I'd say maybe strcoll() optimizes the simple cases
somehow.
[ checks FreeBSD ... ]
On FreeBSD, it's a different story. strcoll() really hurts there
(painfully so). I'm glad you pointed that out, because I have my
production boxes on FreeBSD.
Regards,
Jeff Davis