Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most efficient data type for UUID in database besides a native UUID

What would be the most efficient data type to store a UUID/GUID in databases that do not have a native UUID/GUID data type? 2 BIGINTs?

And what would be the most efficient code (C# preferred) to convert to and from a GUID to that type?

Thanks.

like image 678
Fung Avatar asked Dec 17 '22 10:12

Fung


1 Answers

It's hard to say what would be the most efficient without knowing the database you are using.

My first inclination would be to use a binary(16) column.

As for using that value in C#, the System.Guid type has a constructor that accepts a byte[] array, and a method ToByteArray() that returns a byte array.

like image 71
Brannon Avatar answered Jan 05 '23 23:01

Brannon