PG Bench

How To Benchmark Postgres
  1. Setup a database to use the pgbench tool.
    createdb pgbench
  2. Have pgbench populate the database.
    pgbench -i -s 10 pgbench
  3. Put the following into a sh file (or download here pgb.sh)
    #!/bin/sh
    HOST=localhost
    USER=postgres
    DB=pgbench
    totxacts=1000
    for c in 10
    do
    t=`expr $totxacts / $c`
    psql -h $HOST -U $USER -c 'vacuum analyze' $DB
    psql -h $HOST -U $USER -c 'checkpoint' $DB
    echo "===== sync ======" 1>&2
    sync;sync;sync;sleep 10
    echo $c concurrent users... 1>&2
    /usr/bin/pgbench -n -U $USER -t $t -h $HOST -c $c $DB
    done
  4. chmod +x the file you just created
  5. run the file

Using this method I have achieved ~450 TPS (transactions per second) on a Dell 1600SC Server. 205 GB Raid 5 array, dual HT 2.4 Xeon's 1 Gig of ram, running SuSE 9.0


The biggest performance increase I can tell you to do is to start the postmaster with the -F flag. That will tell the postmaster to not write to disk with every transaction, greatly increasing your speed.


If you use this method to benchmark your postgres install I would like to hear your results. Simply follow the email me link that is on every page. If i get enough responses I may create another page to let people showcase their benchmarks.