Re: Drawbacks of using BYTEA for PK? - Mailing list pgsql-general

From D. Dante Lorenso
Subject Re: Drawbacks of using BYTEA for PK?
Date
Msg-id 4001C89B.1020302@lorenso.com
Whole thread Raw
In response to Drawbacks of using BYTEA for PK?  (David Garamond <lists@zara.6.isreserved.com>)
Responses Re: Drawbacks of using BYTEA for PK?
Re: Drawbacks of using BYTEA for PK?
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: how do I get the primary key
Next
From: Jeff Davis
Date:
Subject: SRF in C