Re: Avoiding surrogate keys

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Avoiding surrogate keys
Дата
Msg-id 20100421194324.GB3762@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: Avoiding surrogate keys  (Bill Moran <wmoran@potentialtech.com>)
Список pgsql-general
Bill Moran escribió:

> One thing that a lot of people seem to get confused about is that they
> subconsciously think that ints or bigints take up less space when the
> numbers are small.  I.e.: I want to use an int for my state identifier
> instead of the 2-digit code, because it will use less space -- wrong,
> an int is 4 bytes, but a 2 byte char column is 1/2 that ... even if the
> number never gets higher than 50.

Eh, a 2 byte char column uses 3 bytes -- there's one byte of overhead.
(Unless one of the chars is multibyte in which case it can be longer).
Earlier versions of Postgres use 6 bytes to store the 2 chars (4 bytes
of overhead), so it would be larger than the int.

Not that this invalidates the argument -- just nitpicking here.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

В списке pgsql-general по дате отправления:

Предыдущее
От: Bill Moran
Дата:
Сообщение: Re: Avoiding surrogate keys
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Avoiding surrogate keys