Index: pgbench/README.pgbench =================================================================== RCS file: /cvsroot/pgsql/contrib/pgbench/README.pgbench,v retrieving revision 1.4 diff -c -r1.4 README.pgbench *** pgbench/README.pgbench 2001/10/24 08:07:19 1.4 --- pgbench/README.pgbench 2002/01/09 01:31:26 *************** *** 122,127 **** --- 122,130 ---- -S 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 Establish connection for each transaction, rather than doing it just once at begining of pgbench in the normal Index: pgbench/pgbench.c =================================================================== RCS file: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v retrieving revision 1.13 diff -c -r1.13 pgbench.c *** pgbench/pgbench.c 2001/11/05 17:46:23 1.13 --- pgbench/pgbench.c 2002/01/09 01:31:26 *************** *** 4,10 **** * pgbench: a simple TPC-B like benchmark program for PostgreSQL * written by Tatsuo Ishii * ! * Copyright (c) 2000 Tatsuo Ishii * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby --- 4,10 ---- * pgbench: a simple TPC-B like benchmark program for PostgreSQL * written by Tatsuo Ishii * ! * Copyright (c) 2000-2002 Tatsuo Ishii * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby *************** *** 95,101 **** static void 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, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n"); } --- 95,101 ---- static void usage() { ! 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"); } *************** *** 168,174 **** /* process a transaction */ static void ! doOne(CState * state, int n, int debug) { char sql[256]; PGresult *res; --- 168,174 ---- /* process a transaction */ static void ! doOne(CState * state, int n, int debug, int ttype) { char sql[256]; PGresult *res; *************** *** 295,306 **** sprintf(sql, "select abalance from accounts where aid = %d", st->aid); break; case 3: ! sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n", ! st->delta, st->tid); ! break; case 4: ! sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid); ! break; case 5: sprintf(sql, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')", st->tid, st->bid, st->aid, st->delta); --- 295,312 ---- sprintf(sql, "select abalance from accounts where aid = %d", st->aid); break; case 3: ! if (ttype == 0) ! { ! sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n", ! st->delta, st->tid); ! break; ! } case 4: ! if (ttype == 0) ! { ! sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid); ! break; ! } case 5: sprintf(sql, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')", st->tid, st->bid, st->aid, st->delta); *************** *** 549,554 **** --- 555,561 ---- exit(1); } + #ifdef NOT_USED /* * do a checkpoint to purge the old WAL logs */ *************** *** 558,563 **** --- 565,571 ---- fprintf(stderr, "%s", PQerrorMessage(con)); exit(1); } + #endif /* NOT_USED */ } } *************** *** 585,590 **** --- 593,599 ---- t2; int i; int normal_xacts = 0; + char *s; for (i = 0; i < nclients; i++) normal_xacts += state[i].cnt; *************** *** 594,601 **** t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec); t2 = normal_xacts * 1000000.0 / t2; ! printf("transaction type: %s\n", ttype == 0 ? "TPC-B (sort of)" : "SELECT only"); printf("scaling factor: %d\n", tps); printf("number of clients: %d\n", nclients); printf("number of transactions per client: %d\n", nxacts); --- 603,617 ---- t2 = (tv3->tv_sec - tv2->tv_sec) * 1000000.0 + (tv3->tv_usec - tv2->tv_usec); t2 = normal_xacts * 1000000.0 / t2; + + 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("number of clients: %d\n", nclients); printf("number of transactions per client: %d\n", nxacts); *************** *** 619,625 **** int is_full_vacuum = 0; /* do full vacuum before testing? */ int debug = 0; /* debug flag */ int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT ! * only */ static CState state[MAXCLIENTS]; /* clients status */ --- 635,642 ---- int is_full_vacuum = 0; /* do full vacuum before testing? */ int debug = 0; /* debug flag */ int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT ! * only ! 2: skip updation of branches and tellers */ static CState state[MAXCLIENTS]; /* clients status */ *************** *** 641,647 **** PGconn *con; PGresult *res; ! while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != EOF) { switch (c) { --- 658,664 ---- PGconn *con; PGresult *res; ! while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNS")) != EOF) { switch (c) { *************** *** 666,671 **** --- 683,691 ---- case 'S': ttype = 1; break; + case 'N': + ttype = 2; + break; case 'c': nclients = atoi(optarg); if (nclients <= 0 || nclients > MAXCLIENTS) *************** *** 851,858 **** /* send start up quries in async manner */ for (i = 0; i < nclients; i++) { ! if (ttype == 0) ! doOne(state, i, debug); else if (ttype == 1) doSelectOnly(state, i, debug); } --- 871,878 ---- /* send start up quries in async manner */ for (i = 0; i < nclients; i++) { ! if (ttype == 0 || ttype == 2) ! doOne(state, i, debug, ttype); else if (ttype == 1) doSelectOnly(state, i, debug); } *************** *** 915,922 **** { if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask)) { ! if (ttype == 0) ! doOne(state, i, debug); else if (ttype == 1) doSelectOnly(state, i, debug); } --- 935,942 ---- { if (state[i].con && FD_ISSET(PQsocket(state[i].con), &input_mask)) { ! if (ttype == 0 || ttype == 2) ! doOne(state, i, debug, ttype); else if (ttype == 1) doSelectOnly(state, i, debug); } [t-ishii@srapc1474 contrib]$