For storing a 128 bits UUID there are multiple storage options:
- a byte[16] column
- two bigint/long(64 bits) columns
- a CHAR(36) column - 32 hex digits + 4 dashes.
- a UUID database specific column, if db supports it
From an indexing point of view which of those are the most efficient? If the db doesn't support a dedicated uuid type which of 1, 2, 3 are the best candidates?
raw(16)
in Oracle anduuid
in PostgreSQL.uuid
>>bytea
>>text
withCHECK
constraint >varchar(36)
>>char(36)
. See: dba.stackexchange.com/a/89433/3684 and dba.stackexchange.com/a/115316/3684.