surrogate key or not?

Поиск
Список
Период
Сортировка
От Markus Bertheau
Тема surrogate key or not?
Дата
Msg-id 1090325769.3241.27.camel@dicaprio.akademie1.de
обсуждение исходный текст
Ответы Re: surrogate key or not?
Список 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 по дате отправления:

Предыдущее
От: Luis Sousa
Дата:
Сообщение: Re: Problem in age on a dates interval
Следующее
От: Lars Erik Thorsplass
Дата:
Сообщение: Stored procedures and "pseudo" fields..