Re: varchar as primary key

Поиск
Список
Период
Сортировка
От Alexander Staubo
Тема Re: varchar as primary key
Дата
Msg-id 88daf38c0705031332w375dd6det7ded15ff453a72d7@mail.gmail.com
обсуждение исходный текст
Ответ на varchar as primary key  (Matthew Hixson <hixson@poindextrose.org>)
Ответы Re: varchar as primary key  (Jeff Davis <pgsql@j-davis.com>)
Re: varchar as primary key  ("Merlin Moncure" <mmoncure@gmail.com>)
Список pgsql-general
On 5/3/07, Matthew Hixson <hixson@poindextrose.org> wrote:
>    Is there a significant performance difference between using int
> primary keys and string primary keys in Postgres?

PostgreSQL uses B-trees for its indexes, insertion time is logarithmic
regardless of the type of the key, but strings have a larger overhead
since they involve character comparisons; (i - j) is a lot faster than
strcmp(i, j). If you do go for strings, I would suggest that the
beginning of the key be statistically distributed as widely as
possible; ie., avoid common prefixes.

Alexander.

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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: varchar as primary key
Следующее
От: Andrew Edson
Дата:
Сообщение: Indexing questions: Index == key? And index vs substring - how successful?