Random identifiers are poorly compressible
lemire.me
lemire.me
But those random identifiers have no intrinsic value. So long as your database is a complete view of the data you wish to compress (i.e. a closed graph with nothing from the outside world pointing in) then one distinct identifier is as good as another. You can consider a compression strategy that replaces uuid x with an (irreversible) one-to-one mapping value y as a form of lossy compression that gives you an equivalent but not identical dataset upon decompression.
Depending on where, how, and why the compression is taking place, that could be good enough. If there is an additional non-constrained channel available for the non-hot path, the mapping could also be exported separately to allow for reversing the mappings out-of-band.
This is why "modem sounds" are like white noise - both are maximum entropy. The probability of ANY state is maximized to the channel capacity. For binary words, that means every combination of bits would exist. That's not going to be as compressible as a situation with redundant bits or states.
Maximum compression is also related to this: if you have maximum entropy, you have maximum compression and maximum channel capacity. You also have "most perfect encryption" if the data has been encrypted - again redundancy means encryption can be broken faster/easier than maximum entropy.
All nicely related. All commonly dealt with in digital modulation and wireless technologies (I learned all this as an EE long before the digital communications revolution arrived - came in handy for sure).
The real question is, what does a dataset have to have a unique list of identifiers be such a significat part of it that this is worth worrying about? Many identifier-heavy datasets have lots of cross references (e.g. n:m relation tables), with lots of repeated identifiers that are actually easy to compress. Am I missing something?
> Do that! If you strip them out, the 529 kB document shrinks to 280 kB, which hardly seems worth the hassle, but when gzipped, this is a miniscule 13 kB! This is because those strings are hashes, which significantly reduces their compressibility compared to general JSON, which usually compresses very well.
This seems backwards. Each random, incompressible identifier must be stored verbatim exactly once. If you have relatively few identifiers, that are mentioned many times, it doesn't matter at all what you call them. A compressor can just put them in a dictionary and use their reference.
On the other hand, if you have a large number of identifiers, the cost of that dictionary becomes non-trivial.
Part of the reason is, presumably, that over a distributed system it's hard to coordinate choosing a deterministic globally unique identifier without a performance cost.
Does any one have any thoughts on implementing a globally unique identifier in a compressible/deterministic way?
My initial guess is choose some low-collision probability random part, and then glue on timestamp?
If you have only a single master DBMS server, then 64-bit integers should be sufficient when using this strategy. Otherwise, if you are using multi-master in a distributed environment, you could achieve lock/communication-free identifier generation by instead using a 128 bit integer and for example include the server identifier inside those 128 bits, similarly to snowflake, before encrypting it and exposing it to the user.
Side note, since the identifiers are sequential there is anther benefit in that, like snowflake, when you order by (created_date, user_id), it wouldn't incur any performance cost over just ordering by user_id.
If anyone knows anyone who uses this or why it would be a bad idea I would love to know.
Adding more things such as time stamp just adds entropy without being useful. The indexes should start at 0 and count up. The computer index is something that should be handed out once every time a computer is brought in.
-- https://datatracker.ietf.org/doc/html/draft-peabody-dispatch...