Re: pgbench - add pseudo-random permutation function
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: David Bowen <dmb0317@gmail.com>
Cc: Bruce Momjian <bruce@momjian.us>, Fabien COELHO <coelho@cri.ensmp.fr>, Alvaro Herrera <alvherre@2ndquadrant.com>,
David Steele <david@pgmasters.net>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>,
Thomas Munro <thomas.munro@gmail.com>, Hironobu SUZUKI <hironobu@interdb.jp>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-03-11T19:34:57Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pgbench: Function to generate random permutations.
- 6b258e3d688d 14.0 landed
-
Add basic support for using the POPCNT and SSE4.2s LZCNT opcodes
- 711bab1e4d19 12.0 cited
-
Further improve code for probing the availability of ARM CRC instructions.
- a7a7387575b8 11.0 cited
On Thu, 11 Mar 2021 at 19:06, David Bowen <dmb0317@gmail.com> wrote:
>
> The algorithm for generating a random permutation with a uniform distribution across all permutations is easy:
> for (i=0; i<n; i++) {
> swap a[n-i] with a[rand(n-i+1)]
> }
>
> where 0 <= rand(x) < x and a[i] is initially i (see Knuth, Section 3.4.2 Algorithm P)
>
True, but n can be very large, so that might use a lot of memory and
involve a lot of pre-processing.
Regards,
Dean