Commit 46d9c2ec authored by Tatsuo Ishii's avatar Tatsuo Ishii

Change the delta val from 0 and 10000 to -5000 and 5000 per recent

discussion in hackers list.  Also enhance predefined benchmark
scenarios to reflect the scaling factor parameter flexibly.
parent 51175d1d
/* /*
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.50 2006/07/26 07:24:50 ishii Exp $ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.51 2006/07/28 22:58:26 ishii Exp $
* *
* pgbench: a simple benchmark program for PostgreSQL * pgbench: a simple benchmark program for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
...@@ -134,10 +134,13 @@ int num_files; /* its number */ ...@@ -134,10 +134,13 @@ int num_files; /* its number */
/* default scenario */ /* default scenario */
static char *tpc_b = { static char *tpc_b = {
"\\setrandom aid 1 100000\n" "\\set nbranches :tps\n"
"\\setrandom bid 1 1\n" "\\set ntellers 10 * :tps\n"
"\\setrandom tid 1 10\n" "\\set naccounts 100000 * :tps\n"
"\\setrandom delta 1 10000\n" "\\setrandom aid 1 :naccounts\n"
"\\setrandom bid 1 :nbranches\n"
"\\setrandom tid 1 :ntellers\n"
"\\setrandom delta -5000 5000\n"
"BEGIN;\n" "BEGIN;\n"
"UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n" "UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n"
"SELECT abalance FROM accounts WHERE aid = :aid;\n" "SELECT abalance FROM accounts WHERE aid = :aid;\n"
...@@ -149,10 +152,13 @@ static char *tpc_b = { ...@@ -149,10 +152,13 @@ static char *tpc_b = {
/* -N case */ /* -N case */
static char *simple_update = { static char *simple_update = {
"\\setrandom aid 1 100000\n" "\\set nbranches :tps\n"
"\\setrandom bid 1 1\n" "\\set ntellers 10 * :tps\n"
"\\setrandom tid 1 10\n" "\\set naccounts 100000 * :tps\n"
"\\setrandom delta 1 10000\n" "\\setrandom aid 1 :naccounts\n"
"\\setrandom bid 1 :nbranches\n"
"\\setrandom tid 1 :ntellers\n"
"\\setrandom delta -5000 5000\n"
"BEGIN;\n" "BEGIN;\n"
"UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n" "UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n"
"SELECT abalance FROM accounts WHERE aid = :aid;\n" "SELECT abalance FROM accounts WHERE aid = :aid;\n"
...@@ -162,7 +168,8 @@ static char *simple_update = { ...@@ -162,7 +168,8 @@ static char *simple_update = {
/* -S case */ /* -S case */
static char *select_only = { static char *select_only = {
"\\setrandom aid 1 100000\n" "\\set naccounts 100000 * :tps\n"
"\\setrandom aid 1 :naccounts\n"
"SELECT abalance FROM accounts WHERE aid = :aid;\n" "SELECT abalance FROM accounts WHERE aid = :aid;\n"
}; };
...@@ -570,12 +577,14 @@ top: ...@@ -570,12 +577,14 @@ top:
else else
min = atoi(argv[2]); min = atoi(argv[2]);
#ifdef NOT_USED
if (min < 0) if (min < 0)
{ {
fprintf(stderr, "%s: invalid minimum number %d\n", argv[0], min); fprintf(stderr, "%s: invalid minimum number %d\n", argv[0], min);
st->ecnt++; st->ecnt++;
return; return;
} }
#endif
if (*argv[3] == ':') if (*argv[3] == ':')
{ {
...@@ -597,6 +606,9 @@ top: ...@@ -597,6 +606,9 @@ top:
return; return;
} }
#ifdef DEBUG
printf("min: %d max: %d random: %d\n", min, max, getrand(min, max));
#endif
snprintf(res, sizeof(res), "%d", getrand(min, max)); snprintf(res, sizeof(res), "%d", getrand(min, max));
if (putVariable(st, argv[1], res) == false) if (putVariable(st, argv[1], res) == false)
...@@ -1477,38 +1489,21 @@ main(int argc, char **argv) ...@@ -1477,38 +1489,21 @@ main(int argc, char **argv)
/* process bultin SQL scripts */ /* process bultin SQL scripts */
switch (ttype) switch (ttype)
{ {
char buf[128];
case 0: case 0:
sql_files[0] = process_builtin(tpc_b); sql_files[0] = process_builtin(tpc_b);
snprintf(buf, sizeof(buf), "%d", 100000 * tps);
sql_files[0][0]->argv[3] = strdup(buf);
snprintf(buf, sizeof(buf), "%d", 1 * tps);
sql_files[0][1]->argv[3] = strdup(buf);
snprintf(buf, sizeof(buf), "%d", 10 * tps);
sql_files[0][2]->argv[3] = strdup(buf);
snprintf(buf, sizeof(buf), "%d", 10000 * tps);
sql_files[0][3]->argv[3] = strdup(buf);
num_files = 1; num_files = 1;
break; break;
case 1: case 1:
sql_files[0] = process_builtin(select_only); sql_files[0] = process_builtin(select_only);
snprintf(buf, sizeof(buf), "%d", 100000 * tps);
sql_files[0][0]->argv[3] = strdup(buf);
num_files = 1; num_files = 1;
break; break;
case 2: case 2:
sql_files[0] = process_builtin(simple_update); sql_files[0] = process_builtin(simple_update);
snprintf(buf, sizeof(buf), "%d", 100000 * tps);
sql_files[0][0]->argv[3] = strdup(buf);
snprintf(buf, sizeof(buf), "%d", 1 * tps);
sql_files[0][1]->argv[3] = strdup(buf);
snprintf(buf, sizeof(buf), "%d", 10 * tps);
sql_files[0][2]->argv[3] = strdup(buf);
snprintf(buf, sizeof(buf), "%d", 10000 * tps);
sql_files[0][3]->argv[3] = strdup(buf);
num_files = 1; num_files = 1;
break; break;
default: default:
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment