Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c57c83

Browse files
committed
New features contributed by Tomoaki Sato.
- predefined variable "tps" The value of variable tps is taken from the scaling factor specified by -s option.- -D option Variable values can be defined by -D option.- \set command now allows arithmetic calculations.
1 parent88b3963 commit0c57c83

File tree

3 files changed

+333
-61
lines changed

3 files changed

+333
-61
lines changed

‎contrib/pgbench/README.pgbench

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
pgbench README2005/10/04 Tatsuo Ishii
1+
pgbench README2006/07/26 Tatsuo Ishii
22

33
o What is pgbench?
44

5-
pgbench is a simple program to run a benchmark test sort of
6-
"TPC-B". pgbench is aclient application of PostgreSQL and runs
7-
with PostgreSQL only. Itperforms lots of small and simple
8-
transactions including select/update/insert operations then
9-
calculates number oftransactions successfully completed within a
10-
second (transactionsper second, tps). Targeting data includes a
11-
table with at least 100ktuples.
5+
pgbench is a simple program to run a benchmark test. pgbench is a
6+
client application of PostgreSQL and runs with PostgreSQL only. It
7+
performs lots of small and simple transactions including
8+
SELECT/UPDATE/INSERT operations then calculates number of
9+
transactions successfully completed within a second (transactions
10+
per second, tps). Targeting data includes a table with at least 100k
11+
tuples.
1212

1313
Example outputs from pgbench look like:
1414

@@ -39,7 +39,7 @@ o How to install pgbench
3939

4040
o How to use pgbench?
4141

42-
(1) Initialize database by:
42+
(1)(optional)Initialize database by:
4343

4444
pgbench -i <dbname>
4545

@@ -95,6 +95,10 @@ o options
9595
as large as the largest number of clients you intend
9696
to test; else you'll mostly be measuring update contention.
9797

98+
-D varname=value
99+
Define a variable. It can be refereed to by a script
100+
provided by using -f option. Multile -D options are allowed.
101+
98102
-U login
99103
Specify db user's login name if it is different from
100104
the Unix login name.
@@ -173,6 +177,15 @@ o -f option
173177
slash). A meta command takes some arguments separted by white
174178
spaces. Currently following meta command is supported:
175179

180+
\set name operand1 [ operator operand2 ]
181+
set the calculated value using "operand1" "operator"
182+
"operand2" to variable "name". If "operator" and "operand2"
183+
are omitted, the value of operand1 is set to variable "name".
184+
185+
example:
186+
187+
\set ntellers 10 * :tps
188+
176189
\setrandom name min max
177190

178191
assign random integer to name between min and max
@@ -188,12 +201,17 @@ o -f option
188201

189202
SELECT abalance FROM accounts WHERE aid = :aid
190203

191-
For example, TPC-B like benchmark can be defined as follows(scaling
204+
Variables can also be defined by using -D option.
205+
206+
Example, TPC-B like benchmark can be defined as follows(scaling
192207
factor = 1):
193208

194-
\setrandom aid 1 100000
195-
\setrandom bid 1 1
196-
\setrandom tid 1 10
209+
\set nbranches :tps
210+
\set ntellers 10 * :tps
211+
\set naccounts 100000 * :tps
212+
\setrandom aid 1 :naccounts
213+
\setrandom bid 1 :nbranches
214+
\setrandom tid 1 :ntellers
197215
\setrandom delta 1 10000
198216
BEGIN
199217
UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid
@@ -203,12 +221,30 @@ UPDATE branches SET bbalance = bbalance + :delta WHERE bid = :bid
203221
INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, 'now')
204222
END
205223

224+
If you want to automatically set the scaling factor from the number of
225+
tuples in branches table, use -s option and shell command like this:
226+
227+
pgbench -s $(psql -At -c "SELECT count(*) FROM branches") -f tpc_b.sql
228+
229+
Notice that -f option does not execute vacuum and clearing history
230+
table before starting benchmark.
231+
206232
o License?
207233

208234
Basically it is same as BSD license. See pgbench.c for more details.
209235

210236
o History
211237

238+
2006/07/26
239+
* New features contributed by Tomoaki Sato.
240+
241+
* predefined variable "tps"
242+
The value of variable tps is taken from the scaling factor
243+
specified by -s option.
244+
* -D option
245+
Variable values can be defined by -D option.
246+
* \set command now allows arithmetic calculations.
247+
212248
2005/09/29
213249
* add -f option. contributed by Tomoaki Sato.
214250

‎contrib/pgbench/README.pgbench_jis

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
pgbench README2005/09/29 Tatsuo Ishii
1+
pgbench README2006/07/26 Tatsuo Ishii
22

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

5-
pgbench $B$O%Y%s%A%^!<%/%F%9%H$r9T$J$&%W%m%0%i%`$G$9!%:#$N$H$3$m(B
6-
PostgreSQL $B@lMQ$G$9!%(B
5+
pgbench $B$O(BPostgreSQL$B$N%Y%s%A%^!<%/%F%9%H$r9T$J$&%W%m%0%i%`$G$9!%(B
76

8-
pgbench $B$O(Bselect/update/insert $B$r4^$`%H%i%s%6%/%7%g%s$r<B9T$7!$A4BN$N(B
7+
pgbench $B$O(BSELECT/UPDATE/INSERT $B$r4^$`%H%i%s%6%/%7%g%s$r<B9T$7!$A4BN$N(B
98
$B<B9T;~4V$H<B:]$K40N;$7$?%H%i%s%6%/%7%g%s$N?t$+$i(B 1 $BIC4V$K<B9T$G$-$?%H(B
109
$B%i%s%6%/%7%g%s?t(B (tps) $B$rI=<($7$^$9!%=hM}$NBP>]$H$J$k%F!<%V%k$O%G%U%)(B
1110
$B%k%H$G$O(B 10$BK|%?%W%k$N%G!<%?$r4^$_$^$9!%(B
@@ -44,7 +43,8 @@ $ pgbench [$B%G!<%?%Y!<%9L>(B]
4443

4544
$B$G$9!%%G!<%?%Y!<%9L>$r>JN,$9$k$H!$%f!<%6L>$HF1$8%G!<%?%Y!<%9$r;XDj$7$?(B
4645
$B$b$N$H$_$J$7$^$9!%%G!<%?%Y!<%9$O8e=R$N(B -i $B%*%W%7%g%s$r;H$C$F$"$i$+$8$a(B
47-
$B=i4|2=$7$F$*$/I,MW$,$"$j$^$9!%(B
46+
$B=i4|2=$7$F$*$/$3$H$,$G$-$^$9!%(B-f$B%*%W%7%g%s$r;H$C$FFH<+$N%H%i%s%6%/%7%g(B
47+
$B%s$rDj5A$9$k>l9g$O!$<+J,$G%G!<%?%Y!<%9$N=i4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%*%W%7%g%s$r;H$C$FFH<+(B
141+
$B$N%H%i%s%6%/%7%g%s$rDj5A$9$k>l9g$O!$<+J,$G%G!<%?%Y!<%9$N=i4|2=$r$7$F$*(B
142+
$B$/I,MW$,$"$j$^$9!%(B
133143

134144
$ pgbench -i [$B%G!<%?%Y!<%9L>(B]
135145

@@ -146,8 +156,11 @@ accounts100000
146156
history0
147157

148158
$B%9%1!<%j%s%0%U%!%/%?!<$r(B 10,100,1000 $B$J$I$KJQ99$9$k$H!$>e5-%?%W%k?t$O(B
149-
$B$=$l$K1~$8$F(B10$BG\!$(B100$BG\!$(B1000$BG\$K$J$j$^$9!%$?$H$($P!$%9%1!<%j%s%0%U%!(B
150-
$B%/%?!<$r(B 10 $B$H$9$k$H!$(B
159+
$B$=$l$K1~$8$F(B10$BG\!$(B100$BG\!$(B1000$BG\$K$J$j$^$9!%%F!<%V%k$H%$%s%G%C%/%9$N%5(B
160+
$B%$%:$O%G!<%?%Y!<%9%5%$%:$O35$M$=$l$>$l!$(B130MB$B!$(B1.3GB$B!$(B13GB$B$[$I$K$J$j$^(B
161+
$B$9!%(B
162+
163+
$B$?$H$($P!$%9%1!<%j%s%0%U%!%/%?!<$r(B 10 $B$H$9$k$H!$(B
151164

152165
$B%F!<%V%kL>(B$B%?%W%k?t(B
153166
-------------------------
@@ -201,37 +214,69 @@ pgbench $B$G$O!$0J2<$N%7!<%1%s%9$rA4It40N;$7$F(B1$B%H%i%s%6%/%7%g%s$H?t$($F(
201214

202215
$B8=:_$N$H$3$m!$0J2<$N%a%?%3%^%s%I$,Dj5A$5$l$F$$$^$9!%(B
203216

217+
\set name operand1 [ operator operand2 ]
218+
$BHo1i;;?t(B operand1 $B$H(B operand2 $B$r1i;;;R(B operator $B$K$h$C$F1i;;$7(B
219+
$B$?7k2L$rJQ?t(B name $B$K@_Dj$7$^$9!%8=>u$G$O@0?t$N;MB'1i;;$N$_$KBP(B
220+
$B1~$7$F$$$^$9!%$J$*!$1i;;;R$H(B 2 $B$DL\$NHo1i;;?t$r>JN,$9$k$HC1=c(B
221+
$B$K(B 1 $B$DL\$NHo1i;;?t$rJQ?t$K@_Dj$7$^$9!%(B
222+
223+
$BJQ?t$K1i;;$N7k2L$r@_Dj$9$k$K$O!$(B\set $B%a%?%3%^%s%I$r;HMQ$7$F0J(B
224+
$B2<$N$h$&$K5-=R$7$^$9!%(B
225+
226+
\set ntellers 10 * :tps
227+
228+
$B$3$l$O!$JQ?t(B ntellers $B$K%9%1!<%j%s%0%U%!%/%?!<(B (-s $B%*%W%7%g%s(B
229+
$B$G;XDj$7$?(B) $B$r(B 10 $BG\$7$?7k2L$r@_Dj$7$^$9!%(B
230+
204231
\setrandom name min max
232+
205233
$B:G>.CM(B min $B$H:GBgCM(B max $B$N4V$NCM$r<h$kMp?t$r!$(Bname $BJQ?t$K@_Dj(B
206234
$B$7$^$9!%(B
207235

208-
$BJQ?t$KMp?t$r@_Dj$9$k$K$O!$(B\setrandom $B%a%?%3%^%s%I$r;HMQ$7$F0J2<$N$h$&(B
209-
$B$K5-=R$7$^$9!%(B
236+
$BJQ?t$KMp?t$r@_Dj$9$k$K$O!$(B\setrandom $B%a%?%3%^%s%I$r;HMQ$7$F0J2<$N$h$&(B
237+
$B$K5-=R$7$^$9!%(B
238+
239+
\setrandom aid 1 100000
210240

211-
\setrandom aid1100000
241+
$B$3$l$O!$JQ?t(B aid$B$K(B 1 $B$+$i(B100000 $B$N4V$NMp?t$r@_Dj$7$^$9!%(B
212242

213-
$B$3$l$O!$JQ?t(B aid $B$K(B 1 $B$+$i(B 100000 $B$N4V$NMp?t$r@_Dj$7$^$9!%$^$?!$JQ?t$N(B
214-
$BCM$r(B SQL $B%3%^%s%I$KKd$a9~$`$K$O!$0J2<$N$h$&$K$=$NL>A0$NA0$K%3%m%s$rIU(B
215-
$B$1$^$9!%(B
243+
$BJQ?t$O(B SQL $B%3%^%s%I$*$h$S%a%?%3%^%s%I$+$i;2>H$G$-$^$9!%$=$l$K$O0J2<$N(B
244+
$B$h$&$KJQ?tL>$NA0$K%3%m%s$rIU$1$^$9!%(B
216245

217246
SELECT abalance FROM accounts WHERE aid = :aid
218247

248+
$BJQ?t$rDj5A$9$k$K$O%a%?%3%^%s%I0J30$K(B -D $B%*%W%7%g%s$r;HMQ$9$k$3$H$b$G$-(B
249+
$B$^$9!%(B -D $B%*%W%7%g%s$GDj5A$7$?JQ?t$bJQ?tL>$NA0$K%3%m%s$rIU$1$F;2>H$7$^(B
250+
$B$9!%(B
251+
219252
$BNc$($P!$(BTCP-B $B$KN`;w$7$?%Y%s%A%^!<%/$r7WB,$9$k$K$O!$0J2<$N$h$&$K%H%i%s(B
220253
$B%6%/%7%g%s$NFbMF$r%U%!%$%k$K5-=R$7!$(B-f $B%*%W%7%g%s$K$h$C$F$=$N%U%!%$%k(B
221254
$B$r;XDj$7$F(B pgbench $B$r<B9T$7$^$9!%(B
222255

223-
\setrandom aid 1 100000
224-
\setrandom bid 1 1
225-
\setrandom tid 1 10
256+
\set nbranches :tps
257+
\set ntellers 10 * :tps
258+
\set naccounts 100000 * :tps
259+
\setrandom aid 1 :naccounts
260+
\setrandom bid 1 :nbranches
261+
\setrandom tid 1 :ntellers
226262
\setrandom delta 1 10000
227263
BEGIN
228264
UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid
229265
SELECT abalance FROM accounts WHERE aid = :aid
230266
UPDATE tellers SET tbalance = tbalance + :delta WHERE tid = :tid
231267
UPDATE branches SET bbalance = bbalance + :delta WHERE bid = :bid
232-
INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta,'now')
268+
INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta,current_timestamp)
233269
END
234270

271+
$B%9%1!<%j%s%0%U%!%/%?!<$r(B branches $B%F!<%V%k$N%?%W%k?t$+$i<+F0E*$K@_Dj$7(B
272+
$B$?$$>l9g!$0J2<$N$h$&$K(B -s $B%*%W%7%g%s$H%7%'%k$N%3%^%s%ICV49$J$I$rAH$_9g(B
273+
$B$o$;$^$9!%(B
274+
275+
pgbench -s $(psql -At -c "SELECT count(*) FROM branches") -f tpc_b.sql
276+
277+
$B$J$*!$(B-f $B%*%W%7%g%s$r;XDj$7$?>l9g!$%Y%s%A%^!<%/3+;OA0$K(B vacuum $B$H(B
278+
history $B$N%/%j%"$O<+F0E*$K9T$o$l$^$;$s!%(B
279+
235280
$B"#:n<T$H%i%$%;%s%9>r7o(B
236281

237282
pgbench $B$O@P0f(B $BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O(B pgbench.c $B$N(B
@@ -240,6 +285,18 @@ pgbench $B$O@P0f(B $BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O(B pgbench.c
240285

241286
$B"#2~DjMzNr(B
242287

288+
2006/07/26
289+
* $B:4F#$5$s$N%Q%C%A$rE,MQ!%0J2<$N5!G=DI2C!%(BPostgreSQL 8.2$B$K<h$j(B
290+
$B9~$^$l$^$9!%(B
291+
292+
$BJQ?t(B tps
293+
-s $B%*%W%7%g%s$G;XDj$7$?%9%1!<%j%s%0%U%!%/%?!<$r%U%!%$%kFb$GJQ?t$H$7(B
294+
$B$F;2>H$9$k5!G=(B
295+
-D $B%*%W%7%g%s(B
296+
$B%3%^%s%I$N%*%W%7%g%s$H$7$FDj5A$7$?JQ?t$r%U%!%$%kFb$+$i;2>H$9$k5!G=(B
297+
\set $B%3%^%s%I(B
298+
$B%U%!%$%kFb$G;MB'1i;;$r9T$$!"$=$N7k2L$rJQ?t$KBeF~$9$k5!G=(B
299+
243300
2005/09/29
244301
* $B:4F#$5$s$N%Q%C%A$rE,MQ!%(B-f $B%*%W%7%g%s$NDI2C!%(B
245302

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp