1
pgbench README 2003/11/26 Tatsuo Ishii (t-ishii@sra.co.jp)
5
pgbench is a simple program to run a benchmark test sort of
6
"TPC-B". pgbench is a client application of PostgreSQL and runs
7
with PostgreSQL only. It performs lots of small and simple
8
transactions including select/update/insert operations then
9
calculates number of transactions successfully completed within a
10
second (transactions per second, tps). Targeting data includes a
11
table with at least 100k tuples.
13
Example outputs from pgbench look like:
16
number of transactions per client: 100
17
number of processed transactions: 400/400
18
tps = 19.875015(including connections establishing)
19
tps = 20.098827(excluding connections establishing)
21
Similar program called "JDBCBench" already exists, but it requires
22
Java that may not be available on every platform. Moreover some
23
people concerned about the overhead of Java that might lead
24
inaccurate results. So I decided to write in pure C, and named
29
- pgbench is written in C using libpq only. So it is very portable
32
- pgbench can simulate concurrent connections using asynchronous
33
capability of libpq. No threading is required.
35
o How to install pgbench
37
(1) Configure and build the standard Postgres distribution.
39
You can get away with just running configure at the top level
40
and doing "make all" in src/interfaces/libpq.
42
(2) Run make in this directory.
44
You will see an executable file "pgbench". You can run it here,
45
or install it with the standard Postgres programs by doing
50
(1) Initialize database by:
54
where <dbname> is the name of database. pgbench uses four tables
55
accounts, branches, history and tellers. These tables will be
56
destroyed. Be very careful if you have tables having same
57
names. Default test data contains:
60
-------------------------
66
You can increase the number of tuples by using -s option. See
69
(2) Run the benchmark test
73
The default configuration is:
76
number of transactions per client: 10
80
pgbench has number of options.
83
hostname where the backend is running. If this option
84
is omitted, pgbench will connect to the localhost via
88
the port number that the backend is accepting. default is
89
libpq's default, usually 5432.
92
Number of clients simulated. default is 1.
94
-t number_of_transactions
95
Number of transactions each client runs. default is 10.
98
this should be used with -i (initialize) option.
99
number of tuples generated will be multiple of the
100
scaling factor. For example, -s 100 will imply 10M
101
(10,000,000) tuples in the accounts table.
102
default is 1. NOTE: scaling factor should be at least
103
as large as the largest number of clients you intend
104
to test; else you'll mostly be measuring update contention.
107
Specify db user's login name if it is different from
111
Specify the db password. CAUTION: using this option
112
might be a security hole since ps command will
113
show the password. Use this for TESTING PURPOSE ONLY.
116
No vacuuming and cleaning the history table prior to the
120
Do vacuuming before testing. This will take some time.
121
With neither -n nor -v, pgbench will vacuum tellers and
122
branches tables only.
125
Perform select only transactions instead of TPC-B.
128
Establish connection for each transaction, rather than
129
doing it just once at beginning of pgbench in the normal
130
mode. This is useful to measure the connection overhead.
133
Write the time taken by each transaction to a logfile,
134
with the name "pgbench_log.xxx", where xxx is the PID
135
of the pgbench process. The format of the log is:
137
client_id transaction_no time
139
where time is measured in microseconds.
145
o What is the "transaction" actually performed in pgbench?
149
(2) update accounts set abalance = abalance + :delta where aid = :aid;
151
(3) select abalance from accounts where aid = :aid;
153
(4) update tellers set tbalance = tbalance + :delta where tid = :tid;
155
(5) update branches set bbalance = bbalance + :delta where bid = :bid;
157
(6) insert into history(tid,bid,aid,delta) values(:tid,:bid,:aid,:delta);
163
Basically it is same as BSD license. See pgbench.c for more details.
168
* create indexes after data insertion to reduce time.
169
patch from Yutaka Tanida.
172
* fix uninitialized memory bug
173
* add support for PGHOST, PGPORT, PGUSER environment variables
176
* patch contributed by Neil Conway.
177
* code/document clean up and add -l option.
180
* do not CHECKPOINT anymore while initializing benchmark
181
* database. Add -N option.
187
* Add -U, -P, -C options
189
2000/1/15 pgbench-1.2 contributed to PostgreSQL
192
1999/09/29 pgbench-1.1 released
193
* Apply cygwin patches contributed by Yutaka Tanida
194
* More robust when backends die
195
* Add -S option (select only)
197
1999/09/04 pgbench-1.0 released