UUID in PostgreSQL
Generated Primary and Foreign Keys for Distributed Databases
- unique to identify table row across databases.
- ordered for efficient clustered index performance.
UUID is not effective when data is spread across multi-master replication (MMR) scenario. It fails condition #2 above.
-- to enable gen_random_uuid() function CREATE EXTENSION pgcrypto; CREATE SCHEMA IF NOT EXISTS core; create table core.user ( userPK UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(), created timestamp without time zone NOT NULL, updated timestamp without time zone NOT NULL );
UUID Primary Keys in PostgreSQL
2nd Alternative to UUID Generation appears to be based somewhat on #2.