0

I'd like to move away from incremental IDs that can easily be guessed and implement something truly random, but still highly indexable to the tune of millions of records.

I thought about using random alphanumeric ID like the ones used in short links (s36rb94kpw59v0h3w6s) but I have a suspicion it'll result in an extremely bloated index and poor optimization.

I also consider UUIDS but i'm not sure how they perform in terms of SELECT. I still want the speed of fetching incremental ID but I just want some sort of non-guessable ID format that wouldn't quadruple my server costs.

P.S. non postgresql solutions are out of the question unfortunately.

CodeOverload
  • 47,274
  • 54
  • 131
  • 219
  • Look at the `pseudo_random` function on the PostgreSQL wiki. For bonus performance points re-implement it as a C extension. – Craig Ringer Mar 31 '17 at 05:01
  • Or: http://stackoverflow.com/questions/33760630/generate-unique-random-numbers-in-postgresql-with-fixed-length –  Mar 31 '17 at 05:48
  • I don't think a UUID is that much slower then an integer. But it apparently depends on your workload and use-case –  Mar 31 '17 at 05:50

0 Answers0