surrogate key or not? - Mailing list pgsql-sql

From Markus Bertheau
Subject surrogate key or not?
Date
Msg-id 1090325769.3241.27.camel@dicaprio.akademie1.de
Whole thread Raw
Responses Re: surrogate key or not?  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
Hi,

I have a database that has types in them with unique names. These types
are referenced from other tables through a surrogate integer key. I'm
now wondering if I should eliminate that surrogate key and just use the
name as the primary key. Afaiu, surrogate keys are primarily there to
make joining tables or otherwise searching for a record faster, because
it's faster to compare two integers than it is to compare two strings.

Now when I want to search for a type in types or another table that
references types(type_id), under what circumstances is it advisable to
have a surrogate integer key and not use the unique type name? Is
searching for an integer as fast as is searching for a string when both
have an index? How many records in the type table do I need to make a
surrogate key a not unsignificantly faster way to retrieve a row? What
about joins? Are these the right questions?

Thanks.

-- 
Markus Bertheau <twanger@bluetwanger.de>



pgsql-sql by date:

Previous
From: Luis Sousa
Date:
Subject: Re: Problem in age on a dates interval
Next
From: Lars Erik Thorsplass
Date:
Subject: Stored procedures and "pseudo" fields..