On Sunday 11 January 2004 22:05, D. Dante Lorenso wrote: > 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;
I think the point of a GUID is it's supposed to be unique across any number of machines without requiring those machines to coordinate their use of GUID values. I think the typical approach is to use something like: hash_fn( network_mac_address || other_hopefully_unique_constant || sequence_val ) and make sure that the probability of getting collisions is acceptably low. ISTR a long discussion a year or two back on one of the lists, for those that are interested. -- Richard Huxton Archonet Ltd ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match