Sorry Bill, I was thinking that the unique index was doing double duty and providing a search function. If not, then the MD5 way seems fine. Do you see any reason not to do it like this:
CREATE UNIQUE INDEX browse_entry_sort_value_value_key
ON metabib.browse_entry
USING btree (MD5(value || sort_value));
to avoid the doubled storage cost and only call the MD5 function once per row on each insert/update?
(NOTE: I tested the speed of a SHA-1 digest, which is less collision-y, but DIGEST(xxx,'sha1') is about 40% slower than the direct MD5() function.)
Sorry Bill, I was thinking that the unique index was doing double duty and providing a search function. If not, then the MD5 way seems fine. Do you see any reason not to do it like this:
CREATE UNIQUE INDEX browse_ entry_sort_ value_value_ key browse_ entry
ON metabib.
USING btree (MD5(value || sort_value));
to avoid the doubled storage cost and only call the MD5 function once per row on each insert/update?
(NOTE: I tested the speed of a SHA-1 digest, which is less collision-y, but DIGEST(xxx,'sha1') is about 40% slower than the direct MD5() function.)