postgresql/contrib/pgbench/README.pgbench_jis
Tatsuo Ishii ea21eea6a8 Change "tps" to "scale" to avoid confusion
Fix bug with handling default scaling factor in the default
scenarios
2006-09-13 00:39:19 +00:00

13 KiB

pgbench README 2006/07/26 Tatsuo Ishii
 
$B"#pgbench $B$H$O!)
 
pgbench $B$OPostgreSQL$B$N%Y%s%A%^!<%/%F%9%H$r9T$J$&%W%m%0%i%`$G$9!%
 
pgbench $B$O SELECT/UPDATE/INSERT $B$r4^$`%H%i%s%6%/%7%g%s$r<B9T$7!$A4BN$N
$B<B9T;~4V$H<B:]$K40N;$7$?%H%i%s%6%/%7%g%s$N?t$+$i 1 $BIC4V$K<B9T$G$-$?%H
$B%i%s%6%/%7%g%s?t (tps) $B$rI=<($7$^$9!%=hM}$NBP>]$H$J$k%F!<%V%k$O%G%U%)
$B%k%H$G$O 10$BK|%?%W%k$N%G!<%?$r4^$_$^$9!%
 
$B<B:]$NI=<($O0J2<$N$h$&$J46$8$G$9!%
 
number of clients: 4
number of transactions per client: 100
number of processed transactions: 400/400
tps = 19.875015(including connections establishing)
tps = 20.098827(excluding connections establishing)
 
pgbench $B$O JDBCBench $B$H$$$&!$$b$H$b$H$O MySQL $BMQ$K=q$+$l$? JDBC $BMQ$N%Y
$B%s%A%^!<%/%W%m%0%i%`$r;29M$K:n@.$5$l$^$7$?!%
 
$B"#pgbench $B$NFCD'
 
o C $B8@8l$H libpq $B$@$1$G=q$+$l$F$$$k$N$G0\?"@-$,9b$/!$4JC1$K%$%s%9%H!<
$B%k$G$-$^$9!%
 
o pgbench $B$O libpq $B$NHsF14|=hM}5!G=$r;H$C$F%^%k%A%f!<%64D6-$r%7%_%e%l!<
$B%H$7$^$9!%MF0W$KF1;~@\B34D6-$r%F%9%H$G$-$^$9!%
 
$B"#pgbench $B$N%$%s%9%H!<%k
 
PostgreSQL$B$r%3%s%Q%$%k!$%$%s%9%H!<%k$7$?8e
 
$ make
$ make install
 
$B$H$7$^$9!%
 
$B"#pgbench $B$N;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100$BG\!$1000$BG\$K$J$j$^$9!%%F!<%V%k$H%$%s%G%C%/%9$N%5
$B%$%:$O%G!<%?%Y!<%9%5%$%:$O35$M$=$l$>$l!$130MB$B!$1.3GB$B!$13GB$B$[$I$K$J$j$^
$B$9!%
 
$B$?$H$($P!$%9%1!<%j%s%0%U%!%/%?!<$r 10 $B$H$9$k$H!$
 
$B%F!<%V%kL> $B%?%W%k?t
-------------------------
branches 10
tellers 100
accounts 1000000
history 0
 
$B$K$J$j$^$9!%
 
$B"#!V%H%i%s%6%/%7%g%s!W$NDj5A
 
pgbench $B$G$O!$0J2<$N%7!<%1%s%9$rA4It40N;$7$F1$B%H%i%s%6%/%7%g%s$H?t$($F
$B$$$^$9!%
 
(1) begin;
 
(2) update accounts set abalance = abalance + :delta where aid = :aid;
$B$3$3$G!$:delta$B$O1$B$+$i1000$B$^$G$NCM$r<h$kMp?t!$:aid $B$O 1$B$+$i100000$B$^$G
$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
$BCf$G$OF1$8CM$r;H$$$^$9!%
 
(3) select abalance from accounts where aid = :aid;
$B$3$3$G$O1$B7o$@$18!:w$5$l$^$9!%
 
(4) update tellers set tbalance = tbalance + :delta where tid = :tid;
$B$3$3$G :tid $B$O 1$B$+$i10$B$N4V$NCM$r$H$kMp?t$G$9!%
 
(5) update branches set bbalance = bbalance + :delta where bid = :bid;
$B$3$3$G :bid $B$O 1 $B$+$i[$B%9%1%j%s%0%U%!%/%?!<]$B$N4V$NCM$r<h$kMp?t$G$9!%
 
(6) insert into history(tid,bid,aid,delta) values(:tid,:bid,:aid,:delta);
 
(7) end;
 
$B"#F~NO%U%!%$%k$N%U%)!<%^%C%H
 
-f $B%*%W%7%g%s$r;XDj$7$F%H%i%s%6%/%7%g%s$K4^$^$l$k SQL $B%3%^%s%I$NFbMF$r
$B5-=R$7$?%U%!%$%k$rFI$_9~$`$3$H$,$G$-$^$9!%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%/%?!< (-s $B%*%W%7%g%s
$B$G;XDj$7$?) $B$r 10 $BG\$7$?7k2L$r@_Dj$7$^$9!%
 
\setrandom name min max
 
$B:G>.CM min $B$H:GBgCM max $B$N4V$NCM$r<h$kMp?t$r!$name $BJQ?t$K@_Dj
$B$7$^$9!%
 
$BJQ?t$KMp?t$r@_Dj$9$k$K$O!$\setrandom $B%a%?%3%^%s%I$r;HMQ$7$F0J2<$N$h$&
$B$K5-=R$7$^$9!%
 
\setrandom aid 1 100000
 
$B$3$l$O!$JQ?t aid $B$K 1 $B$+$i 100000 $B$N4V$NMp?t$r@_Dj$7$^$9!%
 
$BJQ?t$O SQL $B%3%^%s%I$*$h$S%a%?%3%^%s%I$+$i;2>H$G$-$^$9!%$=$l$K$O0J2<$N
$B$h$&$KJQ?tL>$NA0$K%3%m%s$rIU$1$^$9!%
 
SELECT abalance FROM accounts WHERE aid = :aid
 
$BJQ?t$rDj5A$9$k$K$O%a%?%3%^%s%I0J30$K -D $B%*%W%7%g%s$r;HMQ$9$k$3$H$b$G$-
$B$^$9!% -D $B%*%W%7%g%s$GDj5A$7$?JQ?t$bJQ?tL>$NA0$K%3%m%s$rIU$1$F;2>H$7$^
$B$9!%
 
$BNc$($P!$TCP-B $B$KN`;w$7$?%Y%s%A%^!<%/$r7WB,$9$k$K$O!$0J2<$N$h$&$K%H%i%s
$B%6%/%7%g%s$NFbMF$r%U%!%$%k$K5-=R$7!$-f $B%*%W%7%g%s$K$h$C$F$=$N%U%!%$%k
$B$r;XDj$7$F pgbench $B$r<B9T$7$^$9!%
 
\set nbranches :scale
\set ntellers 10 * :scale
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\setrandom delta 1 10000
BEGIN
UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid
SELECT abalance FROM accounts WHERE aid = :aid
UPDATE tellers SET tbalance = tbalance + :delta WHERE tid = :tid
UPDATE branches SET bbalance = bbalance + :delta WHERE bid = :bid
INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, current_timestamp)
END
 
$B%9%1!<%j%s%0%U%!%/%?!<$r branches $B%F!<%V%k$N%?%W%k?t$+$i<+F0E*$K@_Dj$7
$B$?$$>l9g!$0J2<$N$h$&$K -s $B%*%W%7%g%s$H%7%'%k$N%3%^%s%ICV49$J$I$rAH$_9g
$B$o$;$^$9!%
 
pgbench -s $(psql -At -c "SELECT count(*) FROM branches") -f tpc_b.sql
 
$B$J$*!$-f $B%*%W%7%g%s$r;XDj$7$?>l9g!$%Y%s%A%^!<%/3+;OA0$K vacuum $B$H
history $B$N%/%j%"$O<+F0E*$K9T$o$l$^$;$s!%
 
$B"#:n<T$H%i%$%;%s%9>r7o
 
pgbench $B$O@P0f $BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O pgbench.c $B$N
$BKAF,$K=q$$$F$"$j$^$9!%$3$N>r7o$r<i$k8B$jL5=~$GMxMQ$7!$$^$?<+M3$K:FG[IU
$B$G$-$^$9!%
 
$B"#2~DjMzNr
 
2006/09/13
* $BJQ?ttps$B$OJ6$i$o$7$$$N$Gscale$B$KJQ99!%%G%U%)%k%H%7%J%j%*$N;~$K!$
$B%G%U%)%k%H$N%9%1!<%j%s%0%U%!%/%?$rbranches$B$+$i<h$C$F$3$J$$%P%0$r=$@5!%
 
2006/07/26
* $B:4F#$5$s$N%Q%C%A$rE,MQ!%0J2<$N5!G=DI2C!%PostgreSQL 8.2$B$K<h$j
$B9~$^$l$^$9!%
 
$BJQ?t tps
-s $B%*%W%7%g%s$G;XDj$7$?%9%1!<%j%s%0%U%!%/%?!<$r%U%!%$%kFb$GJQ?t$H$7
$B$F;2>H$9$k5!G=
-D $B%*%W%7%g%s
$B%3%^%s%I$N%*%W%7%g%s$H$7$FDj5A$7$?JQ?t$r%U%!%$%kFb$+$i;2>H$9$k5!G=
\set $B%3%^%s%I
$B%U%!%$%kFb$G;MB'1i;;$r9T$$!"$=$N7k2L$rJQ?t$KBeF~$9$k5!G=
 
2005/09/29
* $B:4F#$5$s$N%Q%C%A$rE,MQ!%-f $B%*%W%7%g%s$NDI2C!%
 
[$B$3$N4V$$$m$$$mJQ99$,$"$C$?$h$&$@$,README$B$O%a%$%s%F%J%s%9$5$l$F$$$J$$]
 
2003/11/26
* $BC+ED$5$s$N%Q%C%A$rE,MQ!%pgbench -i$B$N:]$K!$8e$+$i<g%-!<$r:n@.
$B$9$k$h$&$K$7$?!%$3$l$K$h$C$F=i4|2=$N<B9T;~4V$,BgI}$KC;=L$G$-
$B$k($B$O$:)$B!%
 
2003/06/10
* $B%a%b%j$,=i4|2=$5$l$F$$$J$$%P%0$r=$@5
* $B4D6-JQ?tPGHOST, PGPORT, PGUSER$B$rG'<1$9$k$h$&$K$7$?!%
 
2002/07/20
* Nei Conway$B$5$s$N%Q%C%A$rE,MQ!%
* -l $B%*%W%7%g%s$NDI2C!%
 
2002/02/24
* $B$3$3$+$i$O7.3$BMQ$NJQ99$G$9!%
* CHECKPOINT$B$NH/9T$r$d$a$^$7$?!%
* -N $B%*%W%7%g%s$rDI2C$7$^$7$?!%
 
2001/10/24
* PostgreSQL 7.2$B$G!$"time"$B$,M=Ls8l$K$J$C$?$N$G!$"mtime"$B$KJQ99
$B$7$?!%
 
2001/09/09
* PostgreSQL 7.2$BMQ$K!$-U, -P, -C $B%*%W%7%g%s$rDI2C$7$^$7$?!%
 
2000/1/15 pgbench-1.2 $B$O PostgreSQL $B$K contribute $B$5$l$^$7$?!%
* -v $B%*%W%7%g%sDI2C
 
1999/09/29 pgbench-1.1 $B%j%j!<%9
* $BC+ED$5$s$K$h$kcygwin$BBP1~%Q%C%A<h$j9~$_
* $B%P%C%/%(%s%I%/%i%C%7%e;~$NBP1~
* -S $B%*%W%7%g%sDI2C
 
1999/09/04 pgbench-1.0 $B%j%j!<%9