pgbench has #defines for number of branches, tellers, and accounts. There
authorTatsuo Ishii <[email protected]>
Thu, 10 Sep 2009 13:59:57 +0000 (13:59 +0000)
committerTatsuo Ishii <[email protected]>
Thu, 10 Sep 2009 13:59:57 +0000 (13:59 +0000)
are used to populate the tables with -i, but when running actual benchmark
it has values separately hard-coded in the query metacommands.  This patch
makes the metacommands obtain their values from the relevant #defines.

Patch provided by Jeff Janes.

contrib/pgbench/pgbench.c

index 91d26cbbc8a95abfe35b1a762ba64a74097119b4..8a6437fa9248d26b8d1d0778ffefd3229981f564 100644 (file)
@@ -132,7 +132,7 @@ int                 fillfactor = 100;
  * end of configurable parameters
  *********************************************************************/
 
-#define nbranches      1
+#define nbranches      1  /* Makes little sense to change this.  Change -s instead */
 #define ntellers       10
 #define naccounts      100000
 
@@ -232,9 +232,9 @@ static int                  debug = 0;                              /* debug flag */
 
 /* default scenario */
 static char *tpc_b = {
-       "\\set nbranches :scale\n"
-       "\\set ntellers 10 * :scale\n"
-       "\\set naccounts 100000 * :scale\n"
+       "\\set nbranches " CppAsString2(nbranches) " * :scale\n"
+       "\\set ntellers " CppAsString2(ntellers) " * :scale\n"
+       "\\set naccounts " CppAsString2(naccounts) " * :scale\n"
        "\\setrandom aid 1 :naccounts\n"
        "\\setrandom bid 1 :nbranches\n"
        "\\setrandom tid 1 :ntellers\n"
@@ -250,9 +250,9 @@ static char *tpc_b = {
 
 /* -N case */
 static char *simple_update = {
-       "\\set nbranches :scale\n"
-       "\\set ntellers 10 * :scale\n"
-       "\\set naccounts 100000 * :scale\n"
+       "\\set nbranches " CppAsString2(nbranches) " * :scale\n"
+       "\\set ntellers " CppAsString2(ntellers) " * :scale\n"
+       "\\set naccounts " CppAsString2(naccounts) " * :scale\n"
        "\\setrandom aid 1 :naccounts\n"
        "\\setrandom bid 1 :nbranches\n"
        "\\setrandom tid 1 :ntellers\n"
@@ -266,7 +266,7 @@ static char *simple_update = {
 
 /* -S case */
 static char *select_only = {
-       "\\set naccounts 100000 * :scale\n"
+       "\\set naccounts " CppAsString2(naccounts) " * :scale\n"
        "\\setrandom aid 1 :naccounts\n"
        "SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n"
 };