Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

Will storing

07b319dc-7e64-4047-a3e3-63ab43864d81 as it is
OR storing
07b319dc-7e64-4047-a3e3-63ab43864d81 as 07b319dc7e644047a3e363ab43864d81

make any difference?

like image 854
ashish p Avatar asked Nov 28 '12 16:11

ashish p


People also ask

How do you save a database UUID?

The UUID_TO_BIN() function is used to convert the UUID values from a human-readable format into a compact format for storing it in the databases. The BIN_TO_UUID() function is used to convert the UUID from the compact format to a human-readable format for displaying.

How fast is UUID generation?

About 20 microseconds per UUID.

What is Java UUID?

Java UUID Class A UUID is a class that represents an immutable Universally Unique Identifier (UUID). A UUID represents a 128-bit long value that is unique to all practical purpose. It is used to identify information in the computer system. The UUID class belongs to java. util package.

What is the purpose of a unique identifier Oracle?

The SID is a unique identifier that is used to distinguish this instance from other Oracle Database instances that you may create later and run concurrently on your system. The global database name is the full name of the database that uniquely distinguishes it from any other database.


1 Answers

Removing the hyphens will save you exactly 4 characters per row on the database, which is not really worth the effort. Oracle will not be significantly slower or faster because of these four characters. Even worse, if you want to select the the value back to your Java application and recreate an java.util.UUID object, you need to re-insert the hyphens at the correct place.

If you want to save a little memory on the database, RAW(16) (as vcsjones mentioned in the comment of your question) would have the smallest footprint. However, if you want to use the RAW type, you need to disassemble the UUID into a byte[] array. This is a bit tricky since java.util.UUID only returns a String representation or two long values. Recreation of a UUID object from a byte[] array is even trickier.

like image 62
Stefan Ferstl Avatar answered Sep 20 '22 02:09

Stefan Ferstl