]> granicus.if.org Git - postgresql/commitdiff
Add -U, -P, -C options. See README.pgbench for more details.
authorTatsuo Ishii <ishii@postgresql.org>
Sun, 9 Sep 2001 03:15:56 +0000 (03:15 +0000)
committerTatsuo Ishii <ishii@postgresql.org>
Sun, 9 Sep 2001 03:15:56 +0000 (03:15 +0000)
contrib/pgbench/README.pgbench
contrib/pgbench/README.pgbench_jis
contrib/pgbench/pgbench.c

index d062b01e816bb4c121f74ec983325387310da954..de51b2c7bc27235408aa75eb23a7465d02449b12 100644 (file)
@@ -1,4 +1,4 @@
-pgbench 1.2 README             2000/1/15 Tatsuo Ishii (t-ishii@sra.co.jp)
+pgbench 1.3 README             2001/09/09 Tatsuo Ishii (t-ishii@sra.co.jp)
 
 o What is pgbench?
 
@@ -101,6 +101,15 @@ o options
                (10,000,000) tuples in the accounts table.
                default is 1.
 
+        -U login
+               Specify db user's login name if it is different from
+               the Unix login name.
+
+       -P password
+               Specify the db password. CAUTION: using this option
+               might be a security hole since ps command will
+               show the password. Use this for TESTING PURPOSE ONLY.
+
        -n
                No vacuuming and cleaning the history table prior the
                test is performed.
@@ -113,6 +122,11 @@ o options
        -S
                Perform select only transactions instead of TPC-B.
 
+        -C
+               Establish connection for each transaction, rather than
+               doing it just once at begining of pgbench in the normal
+               mode. This is usefull to measure the connection overhead.
+
        -d
                debug option.
 
@@ -139,6 +153,9 @@ Basically it is same as BSD license. See pgbench.c for more details.
 
 o History
 
+2001/09/09
+       * Add -U, -P, -C options
+
 2000/1/15 pgbench-1.2 contributed to PostgreSQL
        * Add -v option
 
index 03d466b581a6ded35e4f9a7fbe5e0a6f17724f19..04a5900c65c3d9122c52bb633e8c0963b8084c6f 100644 (file)
@@ -1,16 +1,16 @@
-pgbench 1.2 README             2000/1/15 Tatsuo Ishii (t-ishii@sra.co.jp)
+pgbench 1.3 README             2001/09/09 Tatsuo Ishii (t-ishii@sra.co.jp)
 
 \e$B"#\e(Bpgbench \e$B$H$O!)\e(B
 
-pgbench \e$B$O\e(B TPC-B\e$B$K;w$?%Y%s%A%^!<%/%F%9%H$r9T$J$&%W%m%0%i%`$G$9!#:#$N$H\e(B
-\e$B$3$m\e(B PostgreSQL \e$B@lMQ$G$9!#\e(B
+pgbench \e$B$O\e(B TPC-B\e$B$K;w$?%Y%s%A%^!<%/%F%9%H$r9T$J$&%W%m%0%i%`$G$9!%:#$N$H\e(B
+\e$B$3$m\e(B PostgreSQL \e$B@lMQ$G$9!%\e(B
 
-pgbench \e$B$O\e(B select/update/insert \e$B$r4^$`%H%i%s%6%/%7%g%s$r<B9T$7!"A4BN$N\e(B
+pgbench \e$B$O\e(B select/update/insert \e$B$r4^$`%H%i%s%6%/%7%g%s$r<B9T$7!$A4BN$N\e(B
 \e$B<B9T;~4V$H<B:]$K40N;$7$?%H%i%s%6%/%7%g%s$N?t$+$i\e(B 1 \e$BIC4V$K<B9T$G$-$?%H\e(B
-\e$B%i%s%6%/%7%g%s?t\e(B (tps) \e$B$rI=<($7$^$9!#=hM}$NBP>]$H$J$k%F!<%V%k$O%G%U%)\e(B
-\e$B%k%H$G$O\e(B 10\e$BK|%?%W%k$N%G!<%?$r4^$_$^$9!#\e(B
+\e$B%i%s%6%/%7%g%s?t\e(B (tps) \e$B$rI=<($7$^$9!%=hM}$NBP>]$H$J$k%F!<%V%k$O%G%U%)\e(B
+\e$B%k%H$G$O\e(B 10\e$BK|%?%W%k$N%G!<%?$r4^$_$^$9!%\e(B
 
-\e$B<B:]$NI=<($O0J2<$N$h$&$J46$8$G$9!#\e(B
+\e$B<B:]$NI=<($O0J2<$N$h$&$J46$8$G$9!%\e(B
 
 number of clients: 4
 number of transactions per client: 100
@@ -18,16 +18,16 @@ number of processed transactions: 400/400
 tps = 19.875015(including connections establishing)
 tps = 20.098827(excluding connections establishing)
 
-pgbench \e$B$O\e(B JDBCBench \e$B$H$$$&!"$b$H$b$H$O\e(B MySQL \e$BMQ$K=q$+$l$?\e(B JDBC \e$BMQ$N%Y\e(B
-\e$B%s%A%^!<%/%W%m%0%i%`$r;29M$K:n@.$5$l$^$7$?!#\e(B
+pgbench \e$B$O\e(B JDBCBench \e$B$H$$$&!$$b$H$b$H$O\e(B MySQL \e$BMQ$K=q$+$l$?\e(B JDBC \e$BMQ$N%Y\e(B
+\e$B%s%A%^!<%/%W%m%0%i%`$r;29M$K:n@.$5$l$^$7$?!%\e(B
 
 \e$B"#\e(Bpgbench \e$B$NFCD'\e(B
 
-o C \e$B8@8l$H\e(B libpq \e$B$@$1$G=q$+$l$F$$$k$N$G0\?"@-$,9b$/!"4JC1$K%$%s%9%H!<\e(B
-\e$B%k$G$-$^$9!#\e(B
+o C \e$B8@8l$H\e(B libpq \e$B$@$1$G=q$+$l$F$$$k$N$G0\?"@-$,9b$/!$4JC1$K%$%s%9%H!<\e(B
+\e$B%k$G$-$^$9!%\e(B
 
 o pgbench \e$B$O\e(B libpq \e$B$NHsF14|=hM}5!G=$r;H$C$F%^%k%A%f!<%64D6-$r%7%_%e%l!<\e(B
-\e$B%H$7$^$9!#MF0W$KF1;~@\B34D6-$r%F%9%H$G$-$^$9!#\e(B
+\e$B%H$7$^$9!%MF0W$KF1;~@\B34D6-$r%F%9%H$G$-$^$9!%\e(B
 
 \e$B"#\e(Bpgbench \e$B$N%$%s%9%H!<%k\e(B
 
@@ -46,61 +46,72 @@ o pgbench \e$B$O\e(B libpq \e$B$NHsF14|=hM}5!G=$r;H$C$F%^%k%A%f!<%64D6-$r%7%_%e%l!<
 
 $ pgbench [\e$B%G!<%?%Y!<%9L>\e(B]
 
-\e$B$G$9!#%G!<%?%Y!<%9L>$r>JN,$9$k$H!"%f!<%6L>$HF1$8%G!<%?%Y!<%9$r;XDj$7$?\e(B
-\e$B$b$N$H$_$J$7$^$9!#%G!<%?%Y!<%9$O8e=R$N\e(B -i \e$B%*%W%7%g%s$r;H$C$F$"$i$+$8$a\e(B
-\e$B=i4|2=$7$F$*$/I,MW$,$"$j$^$9!#\e(B
+\e$B$G$9!%%G!<%?%Y!<%9L>$r>JN,$9$k$H!$%f!<%6L>$HF1$8%G!<%?%Y!<%9$r;XDj$7$?\e(B
+\e$B$b$N$H$_$J$7$^$9!%%G!<%?%Y!<%9$O8e=R$N\e(B -i \e$B%*%W%7%g%s$r;H$C$F$"$i$+$8$a\e(B
+\e$B=i4|2=$7$F$*$/I,MW$,$"$j$^$9!%\e(B
 
-pgbench \e$B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!#\e(B
+pgbench \e$B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%\e(B
 
 -h \e$B%[%9%HL>\e(B      PostgreSQL\e$B$N%G!<%?%Y!<%9%G!<%b%s\e(B postmaster \e$B$NF0\e(B
-               \e$B$$$F$$$k%[%9%HL>$r;XDj$7$^$9!#>JN,$9$k$H<+%[%9%H$K\e(B Unix domain
-               socket \e$B$G@\B3$7$^$9!#\e(B
+               \e$B$$$F$$$k%[%9%HL>$r;XDj$7$^$9!%>JN,$9$k$H<+%[%9%H$K\e(B Unix domain
+               socket \e$B$G@\B3$7$^$9!%\e(B
 
--p \e$B%]!<%HHV9f\e(B    postmaster \e$B$N;HMQ$9$k%]!<%HHV9f$r;XDj$7$^$9!#>JN,$9$k$H\e(B 5432
-               \e$B$,;XDj$5$l$?$b$N$H$_$J$7$^$9!#\e(B
+-p \e$B%]!<%HHV9f\e(B    postmaster \e$B$N;HMQ$9$k%]!<%HHV9f$r;XDj$7$^$9!%>JN,$9$k$H\e(B 5432
+               \e$B$,;XDj$5$l$?$b$N$H$_$J$7$^$9!%\e(B
 
--c \e$B%/%i%$%"%s%H?t\e(B        \e$BF1;~<B9T%/%i%$%"%s%H?t$r;XDj$7$^$9!#>JN,;~$O\e(B
-                       1 \e$B$H$J$j$^$9!#\e(Bpgbench \e$B$OF1;~<B9T%/%i%$%"%s%HKh$K\e(B
-                       \e$B%U%!%$%k%G%#%9%/%j%W%?$r;HMQ$9$k$N$G!";HMQ2DG=\e(B
+-c \e$B%/%i%$%"%s%H?t\e(B        \e$BF1;~<B9T%/%i%$%"%s%H?t$r;XDj$7$^$9!%>JN,;~$O\e(B
+                       1 \e$B$H$J$j$^$9!%\e(Bpgbench \e$B$OF1;~<B9T%/%i%$%"%s%HKh$K\e(B
+                       \e$B%U%!%$%k%G%#%9%/%j%W%?$r;HMQ$9$k$N$G!$;HMQ2DG=\e(B
                        \e$B%U%!%$%k%G%#%9%/%j%W%??t$r1[$($k%/%i%$%"%s%H?t$O\e(B
-                       \e$B;XDj$G$-$^$;$s!#;HMQ2DG=%U%!%$%k%G%#%9%/%j%W%??t\e(B
-                       \e$B$O\e(B limit \e$B$d\e(B ulimit \e$B%3%^%s%I$GCN$k$3$H$,$G$-$^$9!#\e(B
+                       \e$B;XDj$G$-$^$;$s!%;HMQ2DG=%U%!%$%k%G%#%9%/%j%W%??t\e(B
+                       \e$B$O\e(B limit \e$B$d\e(B ulimit \e$B%3%^%s%I$GCN$k$3$H$,$G$-$^$9!%\e(B
 
 -t \e$B%H%i%s%6%/%7%g%s?t\e(B    \e$B3F%/%i%$%"%s%H$,<B9T$9$k%H%i%s%6%/%7%g%s?t$r\e(B
-                       \e$B;XDj$7$^$9!#>JN,;~$O\e(B 10 \e$B$H$J$j$^$9!#\e(B
+                       \e$B;XDj$7$^$9!%>JN,;~$O\e(B 10 \e$B$H$J$j$^$9!%\e(B
 
 -s \e$B%9%1!<%j%s%0%U%!%/%?!<\e(B
 
-               -i \e$B%*%W%7%g%s$H0l=o$K;HMQ$7$^$9!#\e(B
-               \e$B%9%1!<%j%s%0%U%!%/%?!<$O\e(B1\e$B0J>e$N@0?t!#%9%1!<%j%s%0%U%!\e(B
-               \e$B%/%?!<$rJQ$($k$3$H$K$h$j!"%F%9%H$NBP>]$H$J$k%F!<%V%k$N\e(B
-               \e$BBg$-$5$,\e(B 10\e$BK|\e(B x [\e$B%9%1!<%j%s%0%U%!%/%?!<\e(B]\e$B$K$J$j$^$9!#\e(B
-               \e$B%G%U%)%k%H$N%9%1!<%j%s%0%U%!%/%?!<$O\e(B 1 \e$B$G$9!#\e(B
+               -i \e$B%*%W%7%g%s$H0l=o$K;HMQ$7$^$9!%\e(B
+               \e$B%9%1!<%j%s%0%U%!%/%?!<$O\e(B1\e$B0J>e$N@0?t!%%9%1!<%j%s%0%U%!\e(B
+               \e$B%/%?!<$rJQ$($k$3$H$K$h$j!$%F%9%H$NBP>]$H$J$k%F!<%V%k$N\e(B
+               \e$BBg$-$5$,\e(B 10\e$BK|\e(B x [\e$B%9%1!<%j%s%0%U%!%/%?!<\e(B]\e$B$K$J$j$^$9!%\e(B
+               \e$B%G%U%)%k%H$N%9%1!<%j%s%0%U%!%/%?!<$O\e(B 1 \e$B$G$9!%\e(B
 
--v             \e$B$3$N%*%W%7%g%s$r;XDj$9$k$H!"%Y%s%A%^!<%/3+;OA0$K\e(B vacuum \e$B$H\e(B
-               history \e$B$N%/%j%"$r9T$J$$$^$9!#\e(B-v \e$B$H\e(B -n \e$B$r>JN,$9$k$H!"\e(B
-               \e$B:G>.8B$N\e(B vacuum \e$B$J$I$r9T$$$^$9!#$9$J$o$A!"\e(Bhistory \e$B$N:o=|!"\e(B
-               \e$B$H\e(B history, branches, history \e$B$N\e(B vacuum \e$B$r9T$$$^$9!#\e(B
-               \e$B$3$l$O!"\e(Bvacuum \e$B$N;~4V$r:G>.8B$K$7$J$,$i!"%Q%U%)!<%^%s%9$K\e(B
-               \e$B1F6A$9$k%4%_A]=|$r8z2LE*$K9T$$$^$9!#DL>o$O\e(B -v \e$B$H\e(B -n \e$B$r\e(B
-               \e$B>JN,$9$k$3$H$r$*$9$9$a$7$^$9!#\e(B
+-U login       DB\e$B%f!<%6$N%m%0%$%sL>$r;XDj$7$^$9!%\e(B
 
--n             \e$B$3$N%*%W%7%g%s$r;XDj$9$k$H!"%Y%s%A%^!<%/3+;OA0$K\e(B vacuum \e$B$H\e(B
-               history \e$B$N%/%j%"$r9T$J$$$^$;$s!#\e(B
+-P password    \e$B%Q%9%o!<%I$r;XDj$7$^$9!%$J$*!$$3$N%*%W%7%g%s$r;H$&$H!$\e(B
+               \e$B%Q%9%o!<%I$r\e(Bps\e$B%3%^%s%I$G8+$i$l$k$J$I!$%;%-%e%j%F%#%[!<\e(B
+               \e$B%k$K$J$k2DG=@-$,$"$k$N$G!$%F%9%HMQ$K$N$_$*;H$$2<$5$$!%\e(B
 
--S             TPC-B\e$B$N%H%i%s%6%/%7%g%s$G$O$J$/!"8!:w$N$_$N%H%i%s%6%/%7%g%s$r\e(B
-               \e$B<B9T$7$^$9!#8!:w%9%T!<%I$rB,Dj$7$?$$$H$-$K;H$$$^$9!#\e(B
+-n             \e$B$3$N%*%W%7%g%s$r;XDj$9$k$H!$%Y%s%A%^!<%/3+;OA0$K\e(B vacuum \e$B$H\e(B
+               history \e$B$N%/%j%"$r9T$J$$$^$;$s!%\e(B
 
--d             \e$B%G%P%C%0%*%W%7%g%s!#MM!9$J>pJs$,I=<($5$l$^$9!#\e(B
+-v             \e$B$3$N%*%W%7%g%s$r;XDj$9$k$H!$%Y%s%A%^!<%/3+;OA0$K\e(B vacuum \e$B$H\e(B
+               history \e$B$N%/%j%"$r9T$J$$$^$9!%\e(B-v \e$B$H\e(B -n \e$B$r>JN,$9$k$H!$\e(B
+               \e$B:G>.8B$N\e(B vacuum \e$B$J$I$r9T$$$^$9!%$9$J$o$A!$\e(Bhistory \e$B$N:o=|!$\e(B
+               \e$B$H\e(B history, branches, history \e$B$N\e(B vacuum \e$B$r9T$$$^$9!%\e(B
+               \e$B$3$l$O!$\e(Bvacuum \e$B$N;~4V$r:G>.8B$K$7$J$,$i!$%Q%U%)!<%^%s%9$K\e(B
+               \e$B1F6A$9$k%4%_A]=|$r8z2LE*$K9T$$$^$9!%DL>o$O\e(B -v \e$B$H\e(B -n \e$B$r\e(B
+               \e$B>JN,$9$k$3$H$r$*$9$9$a$7$^$9!%\e(B
+
+-S             TPC-B\e$B$N%H%i%s%6%/%7%g%s$G$O$J$/!$8!:w$N$_$N%H%i%s%6%/%7%g%s$r\e(B
+               \e$B<B9T$7$^$9!%8!:w%9%T!<%I$rB,Dj$7$?$$$H$-$K;H$$$^$9!%\e(B
+
+-C             \e$B$3$N%*%W%7%g%s$r;XDj$9$k$H!$:G=i$K3NN)$7$?%3%M%/%7%g%s\e(B
+               \e$B$r;H$$2s$9$N$G$O$J$/!$3F%H%i%s%6%/%7%g%s$4$H$K\e(BDB\e$B$X$N@\\e(B
+               \e$BB3$r9T$$$^$9!%%3%M%/%7%g%s$N%*!<%P!<$X%C%I$rB,Dj$9$k$N\e(B
+               \e$B$KM-8z$G$9!%\e(B
+
+-d             \e$B%G%P%C%0%*%W%7%g%s!%MM!9$J>pJs$,I=<($5$l$^$9!%\e(B
 
 \e$B"#%G!<%?%Y!<%9$N=i4|2=\e(B
 
-pgbench \e$B$G%Y%s%A%^!<%/%F%9%H$r<B;\$9$k$?$a$K$O!"$"$i$+$8$a%G!<%?%Y!<%9\e(B
-\e$B$r=i4|2=$7!"%F%9%H%G!<%?$r:n$kI,MW$,$"$j$^$9!#\e(B
+pgbench \e$B$G%Y%s%A%^!<%/%F%9%H$r<B;\$9$k$?$a$K$O!$$"$i$+$8$a%G!<%?%Y!<%9\e(B
+\e$B$r=i4|2=$7!$%F%9%H%G!<%?$r:n$kI,MW$,$"$j$^$9!%\e(B
 
 $ pgbench -i [\e$B%G!<%?%Y!<%9L>\e(B]
 
-\e$B$3$l$K$h$j0J2<$N%F!<%V%k$,:n$i$l$^$9\e(B(\e$B%9%1!<%j%s%0%U%!%/%?!<\e(B == 1 \e$B$N>l9g\e(B)\e$B!#\e(B
+\e$B$3$l$K$h$j0J2<$N%F!<%V%k$,:n$i$l$^$9\e(B(\e$B%9%1!<%j%s%0%U%!%/%?!<\e(B == 1 \e$B$N>l9g\e(B)\e$B!%\e(B
 
 \e$B!vCm0U!v\e(B
 \e$BF1$8L>A0$N%F!<%V%k$,$"$k$H:o=|$5$l$F$7$^$&$N$G$4Cm0U2<$5$$!*!*\e(B
@@ -112,9 +123,9 @@ tellers             10
 accounts       100000
 history                0
 
-\e$B%9%1!<%j%s%0%U%!%/%?!<$r\e(B 10,100,1000 \e$B$J$I$KJQ99$9$k$H!">e5-%?%W%k?t$O\e(B
-\e$B$=$l$K1~$8$F\e(B10\e$BG\!"\e(B100\e$BG\!"\e(B1000\e$BG\$K$J$j$^$9!#$?$H$($P!"%9%1!<%j%s%0%U%!\e(B
-\e$B%/%?!<$r\e(B 10 \e$B$H$9$k$H!"\e(B
+\e$B%9%1!<%j%s%0%U%!%/%?!<$r\e(B 10,100,1000 \e$B$J$I$KJQ99$9$k$H!$>e5-%?%W%k?t$O\e(B
+\e$B$=$l$K1~$8$F\e(B10\e$BG\!$\e(B100\e$BG\!$\e(B1000\e$BG\$K$J$j$^$9!%$?$H$($P!$%9%1!<%j%s%0%U%!\e(B
+\e$B%/%?!<$r\e(B 10 \e$B$H$9$k$H!$\e(B
 
 \e$B%F!<%V%kL>\e(B       \e$B%?%W%k?t\e(B
 -------------------------
@@ -123,28 +134,28 @@ tellers           100
 accounts       1000000
 history                0
 
-\e$B$K$J$j$^$9!#\e(B
+\e$B$K$J$j$^$9!%\e(B
 
 \e$B"#!V%H%i%s%6%/%7%g%s!W$NDj5A\e(B
 
-pgbench \e$B$G$O!"0J2<$N%7!<%1%s%9$rA4It40N;$7$F\e(B1\e$B%H%i%s%6%/%7%g%s$H?t$($F\e(B
-\e$B$$$^$9!#\e(B
+pgbench \e$B$G$O!$0J2<$N%7!<%1%s%9$rA4It40N;$7$F\e(B1\e$B%H%i%s%6%/%7%g%s$H?t$($F\e(B
+\e$B$$$^$9!%\e(B
 
 (1) begin;
 
 (2) update accounts set abalance = abalance + :delta where aid = :aid;
-    \e$B$3$3$G!"\e(B:delta\e$B$O\e(B1\e$B$+$i\e(B1000\e$B$^$G$NCM$r<h$kMp?t!"\e(B:aid \e$B$O\e(B 1\e$B$+$i\e(B100000\e$B$^$G\e(B
-    \e$B$NCM$r<h$kMp?t$G$9!#0J2<!"Mp?t$NCM$O$=$l$>$l$3$N%H%i%s%6%/%7%g%s$N\e(B
-    \e$BCf$G$OF1$8CM$r;H$$$^$9!#\e(B
+    \e$B$3$3$G!$\e(B:delta\e$B$O\e(B1\e$B$+$i\e(B1000\e$B$^$G$NCM$r<h$kMp?t!$\e(B:aid \e$B$O\e(B 1\e$B$+$i\e(B100000\e$B$^$G\e(B
+    \e$B$NCM$r<h$kMp?t$G$9!%0J2<!$Mp?t$NCM$O$=$l$>$l$3$N%H%i%s%6%/%7%g%s$N\e(B
+    \e$BCf$G$OF1$8CM$r;H$$$^$9!%\e(B
 
 (3) select abalance from accounts where aid = :aid;
-    \e$B$3$3$G$O\e(B1\e$B7o$@$18!:w$5$l$^$9!#\e(B
+    \e$B$3$3$G$O\e(B1\e$B7o$@$18!:w$5$l$^$9!%\e(B
 
 (4) update tellers set tbalance = tbalance + :delta where tid = :tid;
-    \e$B$3$3$G\e(B :tid \e$B$O\e(B 1\e$B$+$i\e(B10\e$B$N4V$NCM$r$H$kMp?t$G$9!#\e(B
+    \e$B$3$3$G\e(B :tid \e$B$O\e(B 1\e$B$+$i\e(B10\e$B$N4V$NCM$r$H$kMp?t$G$9!%\e(B
 
 (5) update branches set bbalance = bbalance + :delta where bid = :bid;
-    \e$B$3$3$G\e(B :bid \e$B$O\e(B 1 \e$B$+$i\e(B[\e$B%9%1%j%s%0%U%!%/%?!<\e(B]\e$B$N4V$NCM$r<h$kMp?t$G$9!#\e(B
+    \e$B$3$3$G\e(B :bid \e$B$O\e(B 1 \e$B$+$i\e(B[\e$B%9%1%j%s%0%U%!%/%?!<\e(B]\e$B$N4V$NCM$r<h$kMp?t$G$9!%\e(B
 
 (6) insert into history(tid,bid,aid,delta) values(:tid,:bid,:aid,:delta);
 
@@ -152,13 +163,16 @@ pgbench \e$B$G$O!"0J2<$N%7!<%1%s%9$rA4It40N;$7$F\e(B1\e$B%H%i%s%6%/%7%g%s$H?t$($F\e(
 
 \e$B"#:n<T$H%i%$%;%s%9>r7o\e(B
 
-pgbench \e$B$O@P0f\e(B \e$BC#IW$K$h$C$F=q$+$l$^$7$?!#%i%$%;%s%9>r7o$O\e(B pgbench.c \e$B$N\e(B
-\e$BKAF,$K=q$$$F$"$j$^$9!#$3$N>r7o$r<i$k8B$jL5=~$GMxMQ$7!"$^$?<+M3$K:FG[IU\e(B
-\e$B$G$-$^$9!#\e(B
+pgbench \e$B$O@P0f\e(B \e$BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O\e(B pgbench.c \e$B$N\e(B
+\e$BKAF,$K=q$$$F$"$j$^$9!%$3$N>r7o$r<i$k8B$jL5=~$GMxMQ$7!$$^$?<+M3$K:FG[IU\e(B
+\e$B$G$-$^$9!%\e(B
 
 \e$B"#2~DjMzNr\e(B
 
-2000/1/15 pgbench-1.2 \e$B$O\e(B PostgreSQL \e$B$K\e(B contribute \e$B$5$l$^$7$?!#\e(B
+2001/09/09
+       * PostgreSQL 7.2\e$BMQ$K!$\e(B-U, -P, -C \e$B%*%W%7%g%s$rDI2C$7$^$7$?!%\e(B
+
+2000/1/15 pgbench-1.2 \e$B$O\e(B PostgreSQL \e$B$K\e(B contribute \e$B$5$l$^$7$?!%\e(B
        * -v \e$B%*%W%7%g%sDI2C\e(B
 
 1999/09/29 pgbench-1.1 \e$B%j%j!<%9\e(B
index eadc57bdf3251b7aac9f496834270b9c51969abb..6cb15bd2cab8ec72efcab099a6de498138f0c902 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.9 2001/08/01 01:08:17 ishii Exp $
+ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.10 2001/09/09 03:15:56 ishii Exp $
  *
  * pgbench: a simple TPC-B like benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -67,6 +67,16 @@ int                  tps = 1;
 
 int                    remains;                        /* number of remained clients */
 
+int                    is_connect;                     /* establish connection  for each transactoin */
+
+char      *pghost = "";
+char      *pgport = NULL;
+char      *pgoptions = NULL;
+char      *pgtty = NULL;
+char      *login = NULL;
+char      *pwd = NULL;
+char      *dbName;
+
 typedef struct
 {
        PGconn     *con;                        /* connection handle to DB */
@@ -85,8 +95,8 @@ typedef struct
 static void
 usage()
 {
-       fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-v][-S][-d][dbname]\n");
-       fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-d][dbname]\n");
+       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");
 }
 
 /* random number generator */
@@ -96,6 +106,34 @@ getrand(int min, int max)
        return (min + (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)));
 }
 
+/* set up a connection to the backend */
+static PGconn *doConnect()
+{
+    PGconn *con;
+
+    con = PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName,
+                               login, pwd);
+    if (con == NULL)
+    {
+       fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
+       fprintf(stderr, "Memory allocatin problem?\n");
+       return(NULL);
+    }
+    
+    if (PQstatus(con) == CONNECTION_BAD)
+    {
+       fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
+
+       if (PQerrorMessage(con))
+           fprintf(stderr, "%s", PQerrorMessage(con));
+       else
+           fprintf(stderr, "No explanation from the backend\n");
+
+       return(NULL);
+    }
+    return (con);
+}
+
 /* throw away response from backend */
 static void
 discard_response(CState * state)
@@ -110,6 +148,7 @@ discard_response(CState * state)
        } while (res);
 }
 
+/* check to see if the SQL result was good */
 static int
 check(CState * state, PGresult *res, int n, int good)
 {
@@ -123,7 +162,7 @@ check(CState * state, PGresult *res, int n, int good)
                st->con = NULL;
                return (-1);
        }
-       return (0);
+       return (0);     /* OK */
 }
 
 /* process a transaction */
@@ -201,11 +240,20 @@ doOne(CState * state, int n, int debug)
                                PQclear(res);
                                discard_response(st);
 
+                               if (is_connect)
+                               {
+                                   PQfinish(st->con);
+                                   st->con = NULL;
+                               }
+
                                if (++st->cnt >= nxacts)
                                {
                                        remains--;      /* I've done */
-                                       PQfinish(st->con);
-                                       st->con = NULL;
+                                       if (st->con != NULL)
+                                       {
+                                           PQfinish(st->con);
+                                           st->con = NULL;
+                                       }
                                        return;
                                }
                                break;
@@ -217,6 +265,19 @@ doOne(CState * state, int n, int debug)
                        st->state = 0;
        }
 
+       if (st->con == NULL)
+       {
+           if ((st->con = doConnect()) == NULL)
+           {
+               fprintf(stderr, "Client %d aborted in establishing connection.\n",
+                       n);
+               remains--;              /* I've aborted */
+               PQfinish(st->con);
+               st->con = NULL;
+               return;
+           }
+       }
+
        switch (st->state)
        {
                case 0:                 /* about to start */
@@ -295,11 +356,20 @@ doSelectOnly(CState * state, int n, int debug)
                                PQclear(res);
                                discard_response(st);
 
+                               if (is_connect)
+                               {
+                                   PQfinish(st->con);
+                                   st->con = NULL;
+                               }
+
                                if (++st->cnt >= nxacts)
                                {
                                        remains--;      /* I've done */
-                                       PQfinish(st->con);
-                                       st->con = NULL;
+                                       if (st->con != NULL)
+                                       {
+                                           PQfinish(st->con);
+                                           st->con = NULL;
+                                       }
                                        return;
                                }
                                break;
@@ -311,6 +381,19 @@ doSelectOnly(CState * state, int n, int debug)
                        st->state = 0;
        }
 
+       if (st->con == NULL)
+       {
+           if ((st->con = doConnect()) == NULL)
+           {
+               fprintf(stderr, "Client %d aborted in establishing connection.\n",
+                       n);
+               remains--;              /* I've aborted */
+               PQfinish(st->con);
+               st->con = NULL;
+               return;
+           }
+       }
+
        switch (st->state)
        {
                case 0:
@@ -349,7 +432,7 @@ disconnect_all(CState * state)
 
 /* create tables and setup data */
 static void
-init(char *pghost, char *pgport, char *dbName)
+init()
 {
        PGconn     *con;
        PGresult   *res;
@@ -366,13 +449,8 @@ init(char *pghost, char *pgport, char *dbName)
 
        int                     i;
 
-       con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-       if (PQstatus(con) == CONNECTION_BAD)
-       {
-               fprintf(stderr, "Connection to database '%s' on %s failed.\n", dbName, pghost);
-               fprintf(stderr, "%s", PQerrorMessage(con));
-               exit(1);
-       }
+       if ((con = doConnect()) == NULL)
+           exit(1);
 
        for (i = 0; i < (sizeof(DDLs) / sizeof(char *)); i++)
        {
@@ -524,6 +602,7 @@ printResults(
        printf("tps = %f(excluding connections establishing)\n", t2);
 }
 
+
 int
 main(int argc, char **argv)
 {
@@ -532,9 +611,6 @@ main(int argc, char **argv)
                                opterr,
                                optopt;
        int                     c;
-       char       *pghost = NULL;
-       char       *pgport = NULL;
-       char       *dbName;
        int                     is_init_mode = 0;               /* initialize mode? */
        int                     is_no_vacuum = 0;               /* no vacuum at all before
                                                                                 * testing? */
@@ -564,7 +640,7 @@ main(int argc, char **argv)
        PGconn     *con;
        PGresult   *res;
 
-       while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:S")) != EOF)
+       while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CS")) != EOF)
        {
                switch (c)
                {
@@ -615,6 +691,9 @@ main(int argc, char **argv)
                                }
 #endif  /* #ifndef __CYGWIN__ */
                                break;
+                       case 'C':
+                             is_connect = 1;
+                             break;
                        case 's':
                                tps = atoi(optarg);
                                if (tps <= 0)
@@ -631,6 +710,12 @@ main(int argc, char **argv)
                                        exit(1);
                                }
                                break;
+                       case 'U':
+                               login = optarg;
+                               break;
+                       case 'P':
+                               pwd = optarg;
+                               break;
                        default:
                                usage();
                                exit(1);
@@ -649,7 +734,7 @@ main(int argc, char **argv)
 
        if (is_init_mode)
        {
-               init(pghost, pgport, dbName);
+               init();
                exit(0);
        }
 
@@ -662,7 +747,10 @@ main(int argc, char **argv)
        }
 
        /* opening connection... */
-       con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
+       con = doConnect();
+       if (con == NULL)
+           exit(1);
+
        if (PQstatus(con) == CONNECTION_BAD)
        {
                fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
@@ -746,16 +834,14 @@ main(int argc, char **argv)
        /* get start up time */
        gettimeofday(&tv1, 0);
 
-       /* make connections to the database */
-       for (i = 0; i < nclients; i++)
+       if (is_connect == 0)
        {
-               state[i].con = PQsetdb(pghost, pgport, NULL, NULL, dbName);
-               if (PQstatus(state[i].con) == CONNECTION_BAD)
-               {
-                       fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
-                       fprintf(stderr, "%s", PQerrorMessage(state[i].con));
-                       exit(1);
-               }
+           /* make connections to the database */
+           for (i = 0; i < nclients; i++)
+           {
+               if ((state[i].con = doConnect()) == NULL)
+                   exit(1);
+           }
        }
 
        /* time after connections set up */