Re: int id's helpful for indexing, or just use text names? - Mailing list pgsql-sql

From Tom Lane
Subject Re: int id's helpful for indexing, or just use text names?
Date
Msg-id 18502.1034716018@sss.pgh.pa.us
Whole thread Raw
In response to int id's helpful for indexing, or just use text names?  (george young <gry@ll.mit.edu>)
List pgsql-sql
george young <gry@ll.mit.edu> writes:
> The question is: would I be better off losing all those integer ids
> and just using the text names as primary indices?  Is there much
> performance lost comparing text strings for every index operation?

Strings would be slower, but possibly not by enough to notice.  The
real question you should ask yourself is whether your text names are
really good candidates to be primary keys.  Are there ever any
duplicates?  Do you ever rename objects?  If your answer to either
is "yes" then the names won't do as unique identifiers.

There's an old saying that meaningful keys are bad database design;
check the mailing list archives for some examples.  (F'r instance,
I seem to recall a story about a bank that embedded branch numbers
into account numbers, and then had terrible troubles anytime a
customer moved...)
        regards, tom lane


pgsql-sql by date:

Previous
From: 2000 Informática
Date:
Subject: ADO with postgreSQL
Next
From: Jan Wieck
Date:
Subject: Re: SQL function triggers