Re: varchar as primary key

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: varchar as primary key
Дата
Msg-id 20070504214556.GC28680@svana.org
обсуждение исходный текст
Ответ на Re: varchar as primary key  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: varchar as primary key  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-general
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.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: Casting to varchar
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Casting to varchar