This isn't a UUID, and may have collisions if you're using it as one. Not likely, but worth noting. Easy fix would be to skip hashing entirely and have a unique constraint on (table, object_pk). What else is the hash needed for?