Commit 0c124c57 authored by Tatsuo Ishii's avatar Tatsuo Ishii

Add -N option which disables updation of branches and tellers tables.

So there would be less contention with -N, that might be more realistic
test.
parent 7c115da7
pgbench README 2001/10/24 Tatsuo Ishii (t-ishii@sra.co.jp) pgbench README 2002/02/24 Tatsuo Ishii (t-ishii@sra.co.jp)
o What is pgbench? o What is pgbench?
...@@ -122,6 +122,9 @@ o options ...@@ -122,6 +122,9 @@ o options
-S -S
Perform select only transactions instead of TPC-B. Perform select only transactions instead of TPC-B.
-N
Skip updation of "branches" and "tellers" table. This
would result in lower contention of updates.
-C -C
Establish connection for each transaction, rather than Establish connection for each transaction, rather than
doing it just once at begining of pgbench in the normal doing it just once at begining of pgbench in the normal
...@@ -153,6 +156,10 @@ Basically it is same as BSD license. See pgbench.c for more details. ...@@ -153,6 +156,10 @@ Basically it is same as BSD license. See pgbench.c for more details.
o History o History
2002/02/24
* disable CHECKPOINT
* add -N option
2001/10/24 2001/10/24
* "time"->"mtime" * "time"->"mtime"
......
pgbench README 2001/09/09 Tatsuo Ishii (t-ishii@sra.co.jp) pgbench README 2002/02/24 Tatsuo Ishii (t-ishii@sra.co.jp)
$B"#(Bpgbench $B$H$O!)(B $B"#(Bpgbench $B$H$O!)(B
...@@ -97,6 +97,13 @@ pgbench $B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%(B ...@@ -97,6 +97,13 @@ pgbench $B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%(B
-S TPC-B$B$N%H%i%s%6%/%7%g%s$G$O$J$/!$8!:w$N$_$N%H%i%s%6%/%7%g%s$r(B -S TPC-B$B$N%H%i%s%6%/%7%g%s$G$O$J$/!$8!:w$N$_$N%H%i%s%6%/%7%g%s$r(B
$B<B9T$7$^$9!%8!:w%9%T!<%I$rB,Dj$7$?$$$H$-$K;H$$$^$9!%(B $B<B9T$7$^$9!%8!:w%9%T!<%I$rB,Dj$7$?$$$H$-$K;H$$$^$9!%(B
-N
"branches"$B$H(B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ls8l$K$J$C$?$N$G!$(B"mtime"$B$KJQ99(B
$B$7$?!%(B $B$7$?!%(B
......
/* /*
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.15 2002/02/18 05:46:41 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.16 2002/02/24 00:17:57 ishii Exp $
* *
* pgbench: a simple TPC-B like benchmark program for PostgreSQL * pgbench: a simple TPC-B like benchmark program for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
* *
* Copyright (c) 2000 Tatsuo Ishii * Copyright (c) 2000-2002 Tatsuo Ishii
* *
* Permission to use, copy, modify, and distribute this software and * Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby * its documentation for any purpose and without fee is hereby
...@@ -95,7 +95,7 @@ typedef struct ...@@ -95,7 +95,7 @@ typedef struct
static void static void
usage() usage()
{ {
fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-C][-v][-S][-U login][-P password][-d][dbname]\n"); fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-C][-v][-S][-N][-U login][-P password][-d][dbname]\n");
fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n"); fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n");
} }
...@@ -168,7 +168,7 @@ check(CState * state, PGresult *res, int n, int good) ...@@ -168,7 +168,7 @@ check(CState * state, PGresult *res, int n, int good)
/* process a transaction */ /* process a transaction */
static void static void
doOne(CState * state, int n, int debug) doOne(CState * state, int n, int debug, int ttype)
{ {
char sql[256]; char sql[256];
PGresult *res; PGresult *res;
...@@ -295,12 +295,18 @@ doOne(CState * state, int n, int debug) ...@@ -295,12 +295,18 @@ doOne(CState * state, int n, int debug)
sprintf(sql, "select abalance from accounts where aid = %d", st->aid); sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
break; break;
case 3: case 3:
if (ttype == 0)
{
sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n", sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n",
st->delta, st->tid); st->delta, st->tid);
break; break;
}
case 4: case 4:
if (ttype == 0)
{
sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid); sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
break; break;
}
case 5: case 5:
sprintf(sql, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')", sprintf(sql, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')",
st->tid, st->bid, st->aid, st->delta); st->tid, st->bid, st->aid, st->delta);
...@@ -548,6 +554,18 @@ init() ...@@ -548,6 +554,18 @@ init()
fprintf(stderr, "PQendcopy failed\n"); fprintf(stderr, "PQendcopy failed\n");
exit(1); exit(1);
} }
#ifdef NOT_USED
/*
* do a checkpoint to purge the old WAL logs
*/
res = PQexec(con, "checkpoint");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "%s", PQerrorMessage(con));
exit(1);
}
#endif /* NOT_USED */
} }
} }
...@@ -575,6 +593,7 @@ printResults( ...@@ -575,6 +593,7 @@ printResults(
t2; t2;
int i; int i;
int normal_xacts = 0; int normal_xacts = 0;
char *s;
for (i = 0; i < nclients; i++) for (i = 0; i < nclients; i++)
normal_xacts += state[i].cnt; normal_xacts += state[i].cnt;
...@@ -585,7 +604,14 @@ printResults( ...@@ -585,7 +604,14 @@ printResults(
t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec); t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec);
t2 = normal_xacts * 1000000.0 / t2; t2 = normal_xacts * 1000000.0 / t2;
printf("transaction type: %s\n", ttype == 0 ? "TPC-B (sort of)" : "SELECT only"); if (ttype == 0)
s = "TPC-B (sort of)";
else if (ttype == 2)
s = "Update only accounts";
else
s = "SELECT only";
printf("transaction type: %s\n", s);
printf("scaling factor: %d\n", tps); printf("scaling factor: %d\n", tps);
printf("number of clients: %d\n", nclients); printf("number of clients: %d\n", nclients);
printf("number of transactions per client: %d\n", nxacts); printf("number of transactions per client: %d\n", nxacts);
...@@ -609,7 +635,8 @@ main(int argc, char **argv) ...@@ -609,7 +635,8 @@ main(int argc, char **argv)
int is_full_vacuum = 0; /* do full vacuum before testing? */ int is_full_vacuum = 0; /* do full vacuum before testing? */
int debug = 0; /* debug flag */ int debug = 0; /* debug flag */
int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT
* only */ * only
2: skip updation of branches and tellers */
static CState state[MAXCLIENTS]; /* clients status */ static CState state[MAXCLIENTS]; /* clients status */
...@@ -631,7 +658,7 @@ main(int argc, char **argv) ...@@ -631,7 +658,7 @@ main(int argc, char **argv)
PGconn *con; PGconn *con;
PGresult *res; PGresult *res;
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != -1) while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNS")) != -1)
{ {
switch (c) switch (c)
{ {
...@@ -656,6 +683,9 @@ main(int argc, char **argv) ...@@ -656,6 +683,9 @@ main(int argc, char **argv)
case 'S': case 'S':
ttype = 1; ttype = 1;
break; break;
case 'N':
ttype = 2;
break;
case 'c': case 'c':
nclients = atoi(optarg); nclients = atoi(optarg);
if (nclients <= 0 || nclients > MAXCLIENTS) if (nclients <= 0 || nclients > MAXCLIENTS)
...@@ -841,8 +871,8 @@ main(int argc, char **argv) ...@@ -841,8 +871,8 @@ main(int argc, char **argv)
/* send start up quries in async manner */ /* send start up quries in async manner */
for (i = 0; i < nclients; i++) for (i = 0; i < nclients; i++)
{ {
if (ttype == 0) if (ttype == 0 || ttype == 2)
doOne(state, i, debug); doOne(state, i, debug, ttype);
else if (ttype == 1) else if (ttype == 1)
doSelectOnly(state, i, debug); doSelectOnly(state, i, debug);
} }
...@@ -905,8 +935,8 @@ main(int argc, char **argv) ...@@ -905,8 +935,8 @@ main(int argc, char **argv)
{ {
if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask)) if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask))
{ {
if (ttype == 0) if (ttype == 0 || ttype == 2)
doOne(state, i, debug); doOne(state, i, debug, ttype);
else if (ttype == 1) else if (ttype == 1)
doSelectOnly(state, i, debug); doSelectOnly(state, i, debug);
} }
......
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