| From: | "Alexander Staubo" <alex(at)purefiction(dot)net> |
|---|---|
| To: | "Matthew Hixson" <hixson(at)poindextrose(dot)org> |
| Cc: | "Postgres General" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: varchar as primary key |
| Date: | 2007-05-03 20:32:14 |
| Message-ID: | 88daf38c0705031332w375dd6det7ded15ff453a72d7@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 5/3/07, Matthew Hixson <hixson(at)poindextrose(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Edson | 2007-05-03 20:42:44 | Indexing questions: Index == key? And index vs substring - how successful? |
| Previous Message | david | 2007-05-03 20:16:14 | Re: Feature Request --- was: PostgreSQL Performance Tuning |