Re: varchar as primary key - Mailing list pgsql-general

From Jeff Davis
Subject Re: varchar as primary key
Date
Msg-id 1178315657.12793.43.camel@dogma.v10.wvs
Whole thread Raw
In response to Re: varchar as primary key  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
On Fri, 2007-05-04 at 23:45 +0200, Martijn van Oosterhout wrote:
> On Fri, May 04, 2007 at 03:42:45PM -0400, Tom Lane wrote:
> > It's hardly credible that you could do either strcmp or strcoll in 2 nsec
> > on any run-of-the-mill hardware.  What I think is happening is that the
> > compiler is aware that these are side-effect-free functions and is
> > removing the calls entirely, or at least moving them out of the loops;
> > these times would be credible for loops consisting only of an increment,
> > test, and branch.
>
> It's not the compiler, it's the C library. strcmp and strcoll are
> defined as:
>
>   extern int strcoll (__const char *__s1, __const char *__s2)
>      __THROW __attribute_pure__ __nonnull ((1, 2));
>
> In this context "pure" is essentially what IMMUTABLE is in postgres.
>
> Which doesn't change the fact that strcoll is expensive.
>

Thanks for clearing that up. I should have done a sanity check on those
numbers to begin with.

By the way, I didn't see the warning Tom mentioned using -Wall on either
system.

Regards,
    Jeff Davis


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Casting to varchar
Next
From: Bruce Momjian
Date:
Subject: Re: Update violating constraint