Summary
UUIDs are easy to generate, easy to share between distributed systems and guarantee uniqueness. Postgres has a dedicated data type for UUIDs: uuid. UUID is a 128 bit data type, so storing single value takes 16 bytes. Storing string takes 1 or 4 bytes overhead plus storing the actual string.
Java's UUID.randomUUID() - returns UUID v4 - which is a pseudo-random value. For us the more interesting one is UUIDv7 - which produces time-sorted values. Each time new Uuid v7 is generated, a greater value it has. And that makes it a good fit for B-Tree index.