Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0c124c5

Browse files
committed
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.
1 parent 7c115da commit 0c124c5

File tree

3 files changed

+67
-18
lines changed

3 files changed

+67
-18
lines changed

contrib/pgbench/README.pgbench

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pgbench README 2001/10/24 Tatsuo Ishii (t-ishii@sra.co.jp)
1+
pgbench README 2002/02/24 Tatsuo Ishii (t-ishii@sra.co.jp)
22

33
o What is pgbench?
44

@@ -122,6 +122,9 @@ o options
122122
-S
123123
Perform select only transactions instead of TPC-B.
124124

125+
-N
126+
Skip updation of "branches" and "tellers" table. This
127+
would result in lower contention of updates.
125128
-C
126129
Establish connection for each transaction, rather than
127130
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.
153156

154157
o History
155158

159+
2002/02/24
160+
* disable CHECKPOINT
161+
* add -N option
162+
156163
2001/10/24
157164
* "time"->"mtime"
158165

contrib/pgbench/README.pgbench_jis

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pgbench README 2001/09/09 Tatsuo Ishii (t-ishii@sra.co.jp)
1+
pgbench README 2002/02/24 Tatsuo Ishii (t-ishii@sra.co.jp)
22

33
$B"#(Bpgbench $B$H$O!)(B
44

@@ -97,6 +97,13 @@ pgbench $B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%(B
9797
-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
9898
$B<B9T$7$^$9!%8!:w%9%T!<%I$rB,Dj$7$?$$$H$-$K;H$$$^$9!%(B
9999

100+
-N
101+
"branches"$B$H(B"tellers"$B%F!<%V%k$N99?7$r9T$$$^$;$s!%$3$l(B
102+
$B$K$h$C$F(B"branches"$B$H(B"tellers"$B$X$NBgNL$N99?7$N6%9g$N$J(B
103+
$B$$>uBV$G$NB,Dj$r9T$$$^$9!%$7$?$,$C$F(BTPC-B$B$N%9%Z%C%/$K(B
104+
$B$OE,9g$7$J$/$J$j$^$9$,!$$h$j8=<BE*$JIi2Y$r%F%9%H$9$k$3(B
105+
$B$H$,$G$-$^$9!%(B
106+
100107
-C $B$3$N%*%W%7%g%s$r;XDj$9$k$H!$:G=i$K3NN)$7$?%3%M%/%7%g%s(B
101108
$B$r;H$$2s$9$N$G$O$J$/!$3F%H%i%s%6%/%7%g%s$4$H$K(BDB$B$X$N@\(B
102109
$BB3$r9T$$$^$9!%%3%M%/%7%g%s$N%*!<%P!<$X%C%I$rB,Dj$9$k$N(B
@@ -169,6 +176,11 @@ pgbench $B$O@P0f(B $BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O(B pgbench.c
169176

170177
$B"#2~DjMzNr(B
171178

179+
2002/02/24
180+
* $B$3$3$+$i$O(B7.3$BMQ$NJQ99$G$9!%(B
181+
* CHECKPOINT$B$NH/9T$r$d$a$^$7$?!%(B
182+
* -N $B%*%W%7%g%s$rDI2C$7$^$7$?!%(B
183+
172184
2001/10/24
173185
* PostgreSQL 7.2$B$G!$(B"time"$B$,M=Ls8l$K$J$C$?$N$G!$(B"mtime"$B$KJQ99(B
174186
$B$7$?!%(B

contrib/pgbench/pgbench.c

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.15 2002/02/18 05:46:41 momjian Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.16 2002/02/24 00:17:57 ishii Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
66
*
7-
* Copyright (c) 2000 Tatsuo Ishii
7+
* Copyright (c) 2000-2002 Tatsuo Ishii
88
*
99
* Permission to use, copy, modify, and distribute this software and
1010
* its documentation for any purpose and without fee is hereby
@@ -95,7 +95,7 @@ typedef struct
9595
static void
9696
usage()
9797
{
98-
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");
98+
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");
9999
fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n");
100100
}
101101

@@ -168,7 +168,7 @@ check(CState * state, PGresult *res, int n, int good)
168168

169169
/* process a transaction */
170170
static void
171-
doOne(CState * state, int n, int debug)
171+
doOne(CState * state, int n, int debug, int ttype)
172172
{
173173
char sql[256];
174174
PGresult *res;
@@ -295,12 +295,18 @@ doOne(CState * state, int n, int debug)
295295
sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
296296
break;
297297
case 3:
298-
sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n",
299-
st->delta, st->tid);
300-
break;
298+
if (ttype == 0)
299+
{
300+
sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n",
301+
st->delta, st->tid);
302+
break;
303+
}
301304
case 4:
302-
sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
303-
break;
305+
if (ttype == 0)
306+
{
307+
sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
308+
break;
309+
}
304310
case 5:
305311
sprintf(sql, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')",
306312
st->tid, st->bid, st->aid, st->delta);
@@ -548,6 +554,18 @@ init()
548554
fprintf(stderr, "PQendcopy failed\n");
549555
exit(1);
550556
}
557+
558+
#ifdef NOT_USED
559+
/*
560+
* do a checkpoint to purge the old WAL logs
561+
*/
562+
res = PQexec(con, "checkpoint");
563+
if (PQresultStatus(res) != PGRES_COMMAND_OK)
564+
{
565+
fprintf(stderr, "%s", PQerrorMessage(con));
566+
exit(1);
567+
}
568+
#endif /* NOT_USED */
551569
}
552570
}
553571

@@ -575,6 +593,7 @@ printResults(
575593
t2;
576594
int i;
577595
int normal_xacts = 0;
596+
char *s;
578597

579598
for (i = 0; i < nclients; i++)
580599
normal_xacts += state[i].cnt;
@@ -585,7 +604,14 @@ printResults(
585604
t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec);
586605
t2 = normal_xacts * 1000000.0 / t2;
587606

588-
printf("transaction type: %s\n", ttype == 0 ? "TPC-B (sort of)" : "SELECT only");
607+
if (ttype == 0)
608+
s = "TPC-B (sort of)";
609+
else if (ttype == 2)
610+
s = "Update only accounts";
611+
else
612+
s = "SELECT only";
613+
614+
printf("transaction type: %s\n", s);
589615
printf("scaling factor: %d\n", tps);
590616
printf("number of clients: %d\n", nclients);
591617
printf("number of transactions per client: %d\n", nxacts);
@@ -609,7 +635,8 @@ main(int argc, char **argv)
609635
int is_full_vacuum = 0; /* do full vacuum before testing? */
610636
int debug = 0; /* debug flag */
611637
int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT
612-
* only */
638+
* only
639+
2: skip updation of branches and tellers */
613640

614641
static CState state[MAXCLIENTS]; /* clients status */
615642

@@ -631,7 +658,7 @@ main(int argc, char **argv)
631658
PGconn *con;
632659
PGresult *res;
633660

634-
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != -1)
661+
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNS")) != -1)
635662
{
636663
switch (c)
637664
{
@@ -656,6 +683,9 @@ main(int argc, char **argv)
656683
case 'S':
657684
ttype = 1;
658685
break;
686+
case 'N':
687+
ttype = 2;
688+
break;
659689
case 'c':
660690
nclients = atoi(optarg);
661691
if (nclients <= 0 || nclients > MAXCLIENTS)
@@ -841,8 +871,8 @@ main(int argc, char **argv)
841871
/* send start up quries in async manner */
842872
for (i = 0; i < nclients; i++)
843873
{
844-
if (ttype == 0)
845-
doOne(state, i, debug);
874+
if (ttype == 0 || ttype == 2)
875+
doOne(state, i, debug, ttype);
846876
else if (ttype == 1)
847877
doSelectOnly(state, i, debug);
848878
}
@@ -905,8 +935,8 @@ main(int argc, char **argv)
905935
{
906936
if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask))
907937
{
908-
if (ttype == 0)
909-
doOne(state, i, debug);
938+
if (ttype == 0 || ttype == 2)
939+
doOne(state, i, debug, ttype);
910940
else if (ttype == 1)
911941
doSelectOnly(state, i, debug);
912942
}

0 commit comments

Comments
 (0)