postgresqldatabase-designuuid

Use data type uuid or varchar(36) for my UUID column?


I'm using PostgreSQL in my project. The primary key column in my table is a character type with length of 36. I generate guids in the backend and store them in the table. Do I need to change the column type as uuid? Can it have the same performance?


Solution

  • Store UUIDs as data type uuid, not as varchar or text. That would require more space in RAM and on disk, be slower to process and more error prone. See: