Re: Generating random unique alphanumeric IDs - Mailing list pgsql-general

From Sam Mason
Subject Re: Generating random unique alphanumeric IDs
Date
Msg-id 20090817005523.GC5407@samason.me.uk
Whole thread Raw
In response to Re: Generating random unique alphanumeric IDs  (Bob Gobeille <bob.gobeille@hp.com>)
List pgsql-general
On Sun, Aug 16, 2009 at 04:53:01PM -0600, Bob Gobeille wrote:
> One way is to use a LFSR (linear feedback shift register function).  I
> haven't used one in a long time but I recall generating pseudo random
> numbers that are guaranteed not to repeat after billions of
> iterations.  It's very fast as well.  Then translate the resulting
> integer into the character sequence of your choosing.   Here is a
> reference:  http://en.wikipedia.org/wiki/Linear_feedback_shift_register

Not sure if this is very applicable; LFSRs can have a very long period,
or interval before they repeat (i.e. their internal state is the same as
it was before) but individual numbers *will* be repeated.

The performance claims tend only to apply to hardware implementations,
there are much faster pseudo-random number generators available for
software.  The fastest one I found recently is a SIMD implementation of
the "Mersenne Twister" called SFMT[1].

--
  Sam  http://samason.me.uk/

 [1] http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: plpgsql function to validate e-mail
Next
From: Bryan Murphy
Date:
Subject: Failover, Wal Logging, and Multiple Spares