Re: Drawbacks of using BYTEA for PK?

From: "D(dot) Dante Lorenso" <dante(at)lorenso(dot)com>
To: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Drawbacks of using BYTEA for PK?
Date: 2004-01-11 22:05:15
Message-ID: 4001C89B.1020302@lorenso.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2004-01-11 23:09:13 SRF in C
Previous Message Tom Lane 2004-01-11 20:30:14 Re: how do I get the primary key