Re: Drawbacks of using BYTEA for PK?

Поиск
Список
Период
Сортировка
От D. Dante Lorenso
Тема Re: Drawbacks of using BYTEA for PK?
Дата
Msg-id 4001C89B.1020302@lorenso.com
обсуждение исходный текст
Ответ на Drawbacks of using BYTEA for PK?  (David Garamond <lists@zara.6.isreserved.com>)
Ответы Re: Drawbacks of using BYTEA for PK?  (Richard Huxton <dev@archonet.com>)
Re: Drawbacks of using BYTEA for PK?  (David Garamond <lists@zara.6.isreserved.com>)
Список pgsql-general
David Garamond wrote:

> Are there any drawbacks of using BYTEA for PK compared to using a
> primitive/atomic data types like INT/SERIAL? (like significant
> performance hit, peculiar FK behaviour, etc).
>
> I plan to use BYTEA for GUID (of course, temporarily I hope, until
> PostgreSQL officially supports GUID data type), since it seems to be
> the most convenient+compact compared to other data types currently
> available. I use GUIDs for most PK columns.

GUID?  Isn't that really nothing more than an MD5 on a sequence?

    SELECT (MD5(NEXTVAL('my_table_seq'))) AS my_guid;

Since 7.4 has the md5 function built-in, there's your support ;-)
Now just add that to your table's trigger and your good to go.
I think in MS products, they format the guid with dashes in the
style 8-4-4-4-12 but it still looks to me like a 32 character hex
string or a 16 byte (128 bit) value.  You can choose to store the
value however you like, I'm not sure what would be optimal, but
bits are bits, right?

Dante





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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: how do I get the primary key
Следующее
От: Jeff Davis
Дата:
Сообщение: SRF in C