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

From Alexander Staubo
Subject Re: varchar as primary key
Date
Msg-id 88daf38c0705031332w375dd6det7ded15ff453a72d7@mail.gmail.com
Whole thread Raw
In response to varchar as primary key  (Matthew Hixson <hixson@poindextrose.org>)
Responses Re: varchar as primary key
Re: varchar as primary key
List 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 by date:

Previous
From: Jeff Davis
Date:
Subject: Re: varchar as primary key
Next
From: Andrew Edson
Date:
Subject: Indexing questions: Index == key? And index vs substring - how successful?