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

From: hubert depesz lubaczewski <depesz(at)gmail(dot)com>
To: Kynn Jones <kynnjo(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Random-looking primary keys in the range 100000..999999
Date: 2014-07-04 14:13:04
Message-ID: CAKrjmhdW=+yJWnM=t+UjZAKpdvfT-NjKD5HzamGF8pHvP6_RbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 <kynnjo(at)gmail(dot)com> wrote:

> I'm looking for a way to implement pseudorandom primary keys in the range
> 100000..999999.
>
> 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 to this list:
>
> http://www.postgresql.org/message-id/49F96730.4000706@postnewspapers.com.au
>
> The answer given to it here
>
>
> http://www.postgresql.org/message-id/448163db-cac5-4e99-8c4c-57cbc6f6af78@mm
>
> ...is really cool, but I don't see how to modify it for the case where the
> domain of the permutation has a cardinality that is not a power of 2, as it
> is in my case (cardinality = 900000).
>
> ---
>
> (In the crypto world there are "format preserving encryption" techniques
> that probably could do what I want to do, but their focus on cryptographic
> strength makes learning and implementing them tough going, plus, the
> performance will probably be poor, since high workloads are an asset for
> such crypto applications. Since cryptographic strength is not something I
> need, I'm trying to find non-crypt-grade alternatives.)
>
> Thanks in advance!
>
> kynn
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2014-07-04 14:19:38 Re: pg_dump slower than pg_restore
Previous Message Kynn Jones 2014-07-04 13:24:31 Random-looking primary keys in the range 100000..999999