uuidstring-hashing

Partial uuids a good idea?


I need to generate and store a identifier per row in a distributed database (high write throughput). There are constraints on length of the Id, preferring it to be as small as possible. Id must be in a utf8.

I was considering generating a uuidv4, converting to base16 encoding, removing the hyphens and taking a partial subset of characters, and in the future if we need more characters we take a larger partial subset.

e.g. Uuid = 123e4567-e89b-12d3-a456-426655440000

Subset = 123e4567e89b

Are there foreseeable issues with this?


Solution

  • You cannot guarantee that partial UUID’s will be universally unique. Now, depending on the number of UUIDs generated, this might not be an issue - especially if you check for duplicates...but perhaps its better just to write your own ID generator with the length specification that you need. I suppose the actual specification for UUIDs requires a certain number of bits for each to be deemed universally unique, but your requirements limit length. They do not require the use of actual UUIDs.