UUIDs in MySQL follow up

Last week my blog post on UUIDs in MySQL stirred a discussion on Hacker News.

I wrote the post in about half an hour and stupidly enough, I did not think about UUID v1. I knew about v1 (from the Melissa virus case), v4 and v3 & v5 (which I once used to generate deterministic UUIDs). I just didn't link my case to UUID v1 because I've hard-wired UUID with UUIDv4 in my head.

Here are two observations from the discussion on HN.

First: over time, the first characters of UUIDv1 are still uniformly distributed.



for i in $(seq 10); do uuid v1; sleep 1; done
cfb84790-2dd7-11e9-bf24-d7119ae2d1f1
d05b6560-2dd7-11e9-b1ec-7741959a2db9
d0fc8760-2dd7-11e9-a109-a559ffed0b17
d19ebad0-2dd7-11e9-826c-91dfdee76140
d2411550-2dd7-11e9-80b6-8918b1061e5e
d2e348c0-2dd7-11e9-9611-1782751eac1c
d385a340-2dd7-11e9-b240-5d8c2d636711
d42872f0-2dd7-11e9-a307-f581cc850936
d4cbdee0-2dd7-11e9-b1d8-9d336aace739
d56e1250-2dd7-11e9-a91f-31f757a43890
view raw uuids.sh hosted with ❤ by GitHub
The only reason I had the same prefix was because I filled in all values with one UPDATE query when I initialized the column. If on the other hand you use UUID() whenever you create a new row, the first characters will be distributed evenly.

Second: the different UUID versions should be more clearly distinguished in general. The Zen of Python has a line:
"Explicit is better than implicit."
In following this, I think it's better not to expose any UUID() function, but only explicitly offer the typed versions UUIDv1(), UUIDv4() etc. This is already what most libraries do as far as I've seen.

Popular posts from this blog

"Security Is Our Top Priority" is BS

The long long tail of AI applications

The Future of Programming Systems - four thoughts