2002-05-20 13:07:28 +08:00
|
|
|
pgbench README 2001/10/24 Tatsuo Ishii (t-ishii@sra.co.jp)
|
2000-06-19 22:02:16 +08:00
|
|
|
|
|
|
|
o What is pgbench?
|
|
|
|
|
|
|
|
pgbench is a simple program to run a benchmark test sort of
|
|
|
|
"TPC-B". pgbench is a client application of PostgreSQL and runs
|
|
|
|
with PostgreSQL only. It performs lots of small and simple
|
|
|
|
transactions including select/update/insert operations then
|
|
|
|
calculates number of transactions successfully completed within a
|
|
|
|
second (transactions per second, tps). Targeting data includes a
|
|
|
|
table with at least 100k tuples.
|
|
|
|
|
|
|
|
Example outputs from pgbench look like:
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
Similar program called "JDBCBench" already exists, but it requires
|
|
|
|
Java that may not be available on every platform. Moreover some
|
|
|
|
people concerned about the overhead of Java that might lead
|
|
|
|
inaccurate results. So I decided to write in pure C, and named
|
|
|
|
it "pgbench."
|
|
|
|
|
|
|
|
o features of pgbench
|
|
|
|
|
|
|
|
- pgbench is written in C using libpq only. So it is very portable
|
|
|
|
and easy to install.
|
|
|
|
|
|
|
|
- pgbench can simulate concurrent connections using asynchronous
|
|
|
|
capability of libpq. No threading is required.
|
|
|
|
|
|
|
|
o How to install pgbench
|
|
|
|
|
2001-02-17 05:41:53 +08:00
|
|
|
(1) Configure and build the standard Postgres distribution.
|
2000-06-19 22:02:16 +08:00
|
|
|
|
2001-02-17 05:41:53 +08:00
|
|
|
You can get away with just running configure at the top level
|
|
|
|
and doing "make all" in src/interfaces/libpq.
|
2000-06-19 22:02:16 +08:00
|
|
|
|
2001-02-17 05:41:53 +08:00
|
|
|
(2) Run make in this directory.
|
2000-06-19 22:02:16 +08:00
|
|
|
|
2001-02-17 05:41:53 +08:00
|
|
|
You will see an executable file "pgbench". You can run it here,
|
|
|
|
or install it with the standard Postgres programs by doing
|
|
|
|
"make install".
|
2000-06-19 22:02:16 +08:00
|
|
|
|
|
|
|
o How to use pgbench?
|
|
|
|
|
|
|
|
(1) Initialize database by:
|
|
|
|
|
|
|
|
pgbench -i <dbname>
|
|
|
|
|
|
|
|
where <dbname> is the name of database. pgbench uses four tables
|
|
|
|
accounts, branches, history and tellers. These tables will be
|
2001-02-17 05:41:53 +08:00
|
|
|
destroyed. Be very careful if you have tables having same
|
2000-06-19 22:02:16 +08:00
|
|
|
names. Default test data contains:
|
|
|
|
|
|
|
|
table # of tuples
|
|
|
|
-------------------------
|
|
|
|
branches 1
|
|
|
|
tellers 10
|
|
|
|
accounts 100000
|
|
|
|
history 0
|
|
|
|
|
|
|
|
You can increase the number of tuples by using -s option. See
|
|
|
|
below.
|
|
|
|
|
|
|
|
(2) Run the benchmark test
|
|
|
|
|
|
|
|
pgbench <dbname>
|
|
|
|
|
|
|
|
The default configuration is:
|
|
|
|
|
|
|
|
number of clients: 1
|
|
|
|
number of transactions per client: 10
|
|
|
|
|
|
|
|
o options
|
|
|
|
|
|
|
|
pgbench has number of options.
|
|
|
|
|
|
|
|
-h hostname
|
|
|
|
hostname where the backend is running. If this option
|
|
|
|
is omitted, pgbench will connect to the localhost via
|
|
|
|
Unix domain socket.
|
|
|
|
|
|
|
|
-p port
|
|
|
|
the port number that the backend is accepting. default is
|
2001-02-17 05:41:53 +08:00
|
|
|
libpq's default, usually 5432.
|
2000-06-19 22:02:16 +08:00
|
|
|
|
|
|
|
-c number_of_clients
|
|
|
|
Number of clients simulated. default is 1.
|
|
|
|
|
|
|
|
-t number_of_transactions
|
|
|
|
Number of transactions each client runs. default is 10.
|
|
|
|
|
|
|
|
-s scaling_factor
|
|
|
|
this should be used with -i (initialize) option.
|
|
|
|
number of tuples generated will be multiple of the
|
|
|
|
scaling factor. For example, -s 100 will imply 10M
|
|
|
|
(10,000,000) tuples in the accounts table.
|
|
|
|
default is 1.
|
|
|
|
|
2001-09-09 11:15:56 +08:00
|
|
|
-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.
|
|
|
|
|
2000-06-19 22:02:16 +08:00
|
|
|
-n
|
|
|
|
No vacuuming and cleaning the history table prior the
|
|
|
|
test is performed.
|
|
|
|
|
|
|
|
-v
|
|
|
|
Do vacuuming before testing. This will take some time.
|
2001-02-17 05:41:53 +08:00
|
|
|
With neither -n nor -v, pgbench will vacuum tellers and
|
2000-06-19 22:02:16 +08:00
|
|
|
branches tables only.
|
|
|
|
|
|
|
|
-S
|
|
|
|
Perform select only transactions instead of TPC-B.
|
|
|
|
|
2001-09-09 11:15:56 +08:00
|
|
|
-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.
|
|
|
|
|
2000-06-19 22:02:16 +08:00
|
|
|
-d
|
|
|
|
debug option.
|
|
|
|
|
|
|
|
|
|
|
|
o What is the "transaction" actually performed in pgbench?
|
|
|
|
|
|
|
|
(1) begin;
|
|
|
|
|
|
|
|
(2) update accounts set abalance = abalance + :delta where aid = :aid;
|
|
|
|
|
|
|
|
(3) select abalance from accounts where aid = :aid;
|
|
|
|
|
|
|
|
(4) update tellers set tbalance = tbalance + :delta where tid = :tid;
|
|
|
|
|
|
|
|
(5) update branches set bbalance = bbalance + :delta where bid = :bid;
|
|
|
|
|
|
|
|
(6) insert into history(tid,bid,aid,delta) values(:tid,:bid,:aid,:delta);
|
|
|
|
|
|
|
|
(7) end;
|
|
|
|
|
|
|
|
o License?
|
|
|
|
|
|
|
|
Basically it is same as BSD license. See pgbench.c for more details.
|
|
|
|
|
|
|
|
o History
|
|
|
|
|
2001-10-24 16:07:22 +08:00
|
|
|
2001/10/24
|
|
|
|
* "time"->"mtime"
|
|
|
|
|
2001-09-09 11:15:56 +08:00
|
|
|
2001/09/09
|
|
|
|
* Add -U, -P, -C options
|
|
|
|
|
2000-06-19 22:02:16 +08:00
|
|
|
2000/1/15 pgbench-1.2 contributed to PostgreSQL
|
|
|
|
* Add -v option
|
|
|
|
|
|
|
|
1999/09/29 pgbench-1.1 released
|
|
|
|
* Apply cygwin patches contributed by Yutaka Tanida
|
|
|
|
* More robust when backends die
|
|
|
|
* Add -S option (select only)
|
|
|
|
|
2001-10-24 16:07:22 +08:00
|
|
|
1999/09/04 pgbench-1.0 released
|