pgbench: Function to generate random permutations

Enterprise / PostgreSQL - Dean Rasheed [] - 6 April 2021 10:50 UTC

This adds a new function, permute(), that generates pseudorandom permutations of arbitrary sizes. This can be used to randomly shuffle a set of values to remove unwanted correlations. For example, permuting the output from a non-uniform random distribution so that all the most common values aren't collocated, allowing more realistic tests to be performed.

Formerly, hash() was recommended for this purpose, but that suffers from collisions that might alter the distribution, so recommend permute() for this purpose instead.

Fabien Coelho and Hironobu Suzuki, with additional hacking be me. Reviewed by Thomas Munro, Alvaro Herrera and Muhammad Usama.


6b258e3d68 pgbench: Function to generate random permutations.
doc/src/sgml/ref/pgbench.sgml | 81 ++++++++++++++---
src/bin/pgbench/exprparse.y | 17 ++++
src/bin/pgbench/pgbench.c | 131 +++++++++++++++++++++++++++
src/bin/pgbench/pgbench.h | 3 +-
src/bin/pgbench/t/ | 43 +++++++++
src/bin/pgbench/t/ | 10 ++
6 files changed, 273 insertions(+), 12 deletions(-)


  • Share