UUID
Use uuid with gen_random_uuid()
uuid16 bytesRecommended
Primary keys in distributed systems, public-facing IDs, merge-safe keys.
Range
128-bit UUID
Performance
Compact 16 bytes (vs 36-char text). Supports btree and hash indexes natively.
Comparison
uuid vs text: uuid type is 16 bytes vs 36+ bytes for text. It validates format on insert and is faster to compare. Use gen_random_uuid() (built-in since PG 13) for v4 UUIDs.
SQL Example
CREATE TABLE accounts ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), name text NOT NULL );