Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-08 Thread Gavin Flower
Please don't top post! See below for my comments. On 09/07/14 07:04, Kynn Jones wrote: Thanks to Gavin and Martijn for their suggestions. They're both simple good-ol' LCGs, and both avoid the need to check for collisions. I ultimately went with a multiplicative LCG, like Martijn's, mostly be

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-08 Thread Kynn Jones
Thanks to Gavin and Martijn for their suggestions. They're both simple good-ol' LCGs, and both avoid the need to check for collisions. I ultimately went with a multiplicative LCG, like Martijn's, mostly because I understand better how it avoids collisions, so it was easier for me to tweak it in v

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-05 Thread Martijn van Oosterhout
On Fri, Jul 04, 2014 at 09:24:31AM -0400, Kynn Jones wrote: > I'm looking for a way to implement pseudorandom primary keys in the range > 10..99. > > The randomization scheme does not need to be cryptographically strong. As > long as it is not easy to figure out in a few minutes it's good

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-04 Thread Gavin Flower
On 05/07/14 15:48, Gavin Flower wrote: On 05/07/14 01:24, Kynn Jones wrote: I'm looking for a way to implement pseudorandom primary keys in the range 10..99. The randomization scheme does not need to be cryptographically strong. As long as it is not easy to figure out in a few minute

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-04 Thread Gavin Flower
On 05/07/14 01:24, Kynn Jones wrote: I'm looking for a way to implement pseudorandom primary keys in the range 10..99. The randomization scheme does not need to be cryptographically strong. As long as it is not easy to figure out in a few minutes it's good enough. My starting point

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-04 Thread Tom Lane
Kynn Jones writes: > The requirements I've been given for the keys is that they be numeric, > reasonably easy to type (hence, no 40-digit keys), never beginning with 0, > and carrying no additional information content (or even suggesting it). Why not just (random()*89)::int + 10 This is

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-04 Thread Kynn Jones
On Fri, Jul 4, 2014 at 10:13 AM, hubert depesz lubaczewski wrote: > How many rows do you plan on having in this table? > Currently, only around 10K, but there's expectation that the number will grow. It's hard to predict how much, hence the generous extra space. > Why this particular key rang

Re: [GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-04 Thread hubert depesz lubaczewski
How many rows do you plan on having in this table? Why this particular key range? depesz On Fri, Jul 4, 2014 at 3:24 PM, Kynn Jones wrote: > I'm looking for a way to implement pseudorandom primary keys in the range > 10..99. > > The randomization scheme does not need to be cryptographi

[GENERAL] Random-looking primary keys in the range 100000..999999

2014-07-04 Thread Kynn Jones
I'm looking for a way to implement pseudorandom primary keys in the range 10..99. The randomization scheme does not need to be cryptographically strong. As long as it is not easy to figure out in a few minutes it's good enough. My starting point for this is the following earlier message