From 26a76cb64072df6fa5585c2c15df39970ccdce01 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 1 Apr 2019 17:37:26 -0400 Subject: Restrict pgbench's zipfian parameter to ensure good performance. Remove the code that supported zipfian distribution parameters less than 1.0, as it had undocumented performance hazards, and it's not clear that the case is useful enough to justify either fixing or documenting those hazards. Also, since the code path for parameter > 1.0 could perform badly for values very close to 1.0, establish a minimum allowed value of 1.001. This solution seems superior to the previous vague documentation warning about small values not performing well. Fabien Coelho, per a gripe from Tomas Vondra Discussion: https://postgr.es/m/b5e172e9-ad22-48a3-86a3-589afa20e8f7@2ndquadrant.com --- doc/src/sgml/ref/pgbench.sgml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml index f11d36620d6..ee2501be552 100644 --- a/doc/src/sgml/ref/pgbench.sgml +++ b/doc/src/sgml/ref/pgbench.sgml @@ -1543,29 +1543,17 @@ f(x) = PHI(2.0 * parameter * (x - mu) / (max - min + 1)) / middle quarter (1.0 / 4.0) of the interval (i.e. from 3.0 / 8.0 to 5.0 / 8.0) and 95% from the middle half (2.0 / 4.0) of the interval (second and third - quartiles). The minimum parameter is 2.0 for performance - of the Box-Muller transform. + quartiles). The minimum allowed parameter + value is 2.0. - random_zipfian generates an approximated bounded Zipfian - distribution. For parameter in (0, 1), an - approximated algorithm is taken from - "Quickly Generating Billion-Record Synthetic Databases", - Jim Gray et al, SIGMOD 1994. For parameter - in (1, 1000), a rejection method is used, based on - "Non-Uniform Random Variate Generation", Luc Devroye, p. 550-551, - Springer 1986. The distribution is not defined when the parameter's - value is 1.0. The function's performance is poor for parameter values - close and above 1.0 and on a small range. - - + random_zipfian generates a bounded Zipfian + distribution. parameter defines how skewed the distribution is. The larger the parameter, the more frequently values closer to the beginning of the interval are drawn. - The closer to 0 parameter is, - the flatter (more uniform) the output distribution. The distribution is such that, assuming the range starts from 1, the ratio of the probability of drawing k versus drawing k+1 is @@ -1576,6 +1564,13 @@ f(x) = PHI(2.0 * parameter * (x - mu) / (max - min + 1)) / itself is produced (3/2)*2.5 = 2.76 times more frequently than 3, and so on. + + pgbench's implementation is based on + "Non-Uniform Random Variate Generation", Luc Devroye, p. 550-551, + Springer 1986. Due to limitations of that algorithm, + the parameter value is restricted to + the range [1.001, 1000]. + -- cgit v1.2.3