What is an efficient way to store Java generated UUIDs in Oracle DB? Will removing or removing a hyphen in a UUID be any use?

What is an efficient way to store Java generated UUIDs in Oracle DB? Will removing or removing a hyphen in a UUID be any use - storage / performance?

Will store

07b319dc-7e64-4047-a3e3-63ab43864d81 since this
OR storage 07b319dc-7e64-4047-a3e3-63ab43864d81 as 07b319dc7e644047a3e363ab43864d81

irrelevant?

+8
oracle uuid store hyphen
source share
1 answer

Removing hyphens will save you exactly 4 characters per line in the database, which is actually not worth the effort. Due to these four characters, Oracle will not be much slower or faster. Worse, if you want to select the value back into your Java application and recreate the java.util.UUID object, you need to insert the hyphens again in the right place.

If you want to keep a small amount of memory in the database, RAW(16) (like the vcsjones mentioned in the comment on your question) will have a minimum size. However, if you want to use the RAW type, you need to parse the UUIDs into a byte[] array. This is a bit complicated since java.util.UUID only returns a String representation or two long values. Recovering a UUID from a byte[] array is even more difficult.

+9
source share

All Articles