Saturday, January 06, 2024

Using UUIDs in SQLite

 Using UUIDs in SQLite - Stack Overflow

SQLite does not have any features that directly support UUID's.

a column (or multiple columns) of any type can be used as a primary key. So you could store the UUID as a formatted, human-readable string and make that your table's key. And since a UUID is just a 128-bit integer, you could also store the integer's bytes as a BLOB

Datatypes In SQLite

ios - How to efficient insert and fetch UUID in Core Data - Stack Overflow

  • As expected, storing the raw UUID binary data is (2x) more efficient in terms of space.
  • The creation time is pretty close (the difference appearing to be based on the time to create the strings and the extra storage space required).
  • The query times seem almost identical, with the binary string appearing to be a tiny bit slower.
When you store binary data, it's hard to get a good visual on the data. 
For this reason may want to consider a base64 encoding (or some other encoding)

No comments: