Using the UUID data type with its 256 chars seems like overkill, while assigning an auto-increment int4 seems less robust.
Is there a more robust way to assign a record id without using uuid or an auto-increment int4?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
UUID has a fixed size of 16 bytes:
=> select typlen from pg_type where oid = 'uuid'::regtype; typlen -------- 16
int4, values have to be between
If that's too narrow, consider the 8-byte
int8, which goes from
9223372036854775807. Postgres sequences (
CREATE SEQUENCE...) use that range.
BIGSERIAL is equivalent to declaring an
int8 column tied to a sequence.