Hacker News new | past | comments | ask | show | jobs | submit login

What are the benefits of using the Postgres uuid type (versus using TEXT or VARCHAR)?



Stored in binary format, validation, more efficient due to non-cast, faster access due to non char*, being able to split the high-low, indexing and uniqueness at the byte level.


What validation? "Postgres doesn’t care what you store in it as long as it has the correct length."


I mean, if(len(O) == 32) technically is a validation but you’re right, by default it just fits for size.


It's 16 bytes versus 36 bytes.


totally tangential to this but just have to share

learned this last week that md5's are also 128 bits and so will fit perfectly in a uuid type in postgres, saving space in the physical table and indexes, and giving better index performance. So if youre storing md5 hashes, use UUID!


It’s stored in binary format (16 bytes) instead of text (36 bytes)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: