在命令行执行语句:
$ pgbench -rf try.sql -c 4 -j 2 -T 60 testdb
遇到如下报错:
starting vacuum...ERROR: relation "pgbench_branches" does not exist
(ignoring this error and continuing anyway)
ERROR: relation "pgbench_tellers" does not exist
(ignoring this error and continuing anyway)
ERROR: relation "pgbench_history" does not exist
(ignoring this error and continuing anyway)
百度一下,查到新浪博客:http://blog.chinaunix.net/uid-26600678-id-4014523.html
原因,testdb并不是使用pgbench -i db_name建立的,在使用pgbench测试时,不要vacuum,即要在pgbench命令中加上-n 选项,指定不vacuum。
查阅pgbench使用手册:
-n
--no-vacuumPerform no vacuuming after initialization.
修改语句如下并重新执行语句:
$ pgbench -rf try.sql -c 4 -j 2 -T 60 -n testdb
成功执行:
transaction type: Custom query
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 2
duration: 60 s
number of transactions actually processed: 8
latency average: 52155.963 ms
tps = 0.076693 (including connections establishing)
tps = 0.076699 (excluding connections establishing)
statement latencies in milliseconds:
52146.602000 SELECT sum(l_extendedprice * l_discount) as revenue FROM lineitem WHERE l_shipdate >= date '1994-01-01' and l_shipdate < date '1994-01-01' + interval '1' year and l_discount between .06 - 0.01 and .06 + 0.01 and l_quantity < 24;