pgbench的使用简介

来源:互联网 发布:tiva数据库 编辑:程序博客网 时间:2024/06/05 18:21

pgbench是基于tpc-b模型的postgresql测试工具。它属于开源软件,主要为数据管理人员提供性能测试使用。

pgbench 是对 PostgreSQL 进行压力测试的一款简单程序, SQL 命令可以在一个连接中顺序地
执行,通常会开多个数据库 Session, 并且在测试最后形成测试报告,得出每秒平均事务数,pgbench
可以测试 select,update,insert,delete 命令,用户可以编写自己的脚本进行测试。

安装:

在postgresql安装源包中,进入源码的contrib目录,进入pgbench目录,通过make all  ;make install单独安装。

先创建一个数据库,名字为:pgbench
createdb pgbench
初使用pgbench的数据:
pgbench -i pgbench
pgbehch的使用帮助:
pgbehch --help
 
测试命令:
pgbench -c 10 -t 100 pgbench

osdba@osdba:~$ pgbench -c 10 -t 100 pgbench
starting vacuum...end.
transaction type: TPC-B (sort of)
scaling factor: 1
query mode: simple
number of clients: 10
number of transactions per client: 100
number of transactions actually processed: 1000/1000
tps = 80.658281 (including connections establishing)
tps = 81.499400 (excluding connections establishing)

-c clients 模拟的客户数,也就是并发数据库会话数目。缺省是 1。
-t transactions 每个客户端跑的事务数目。缺省是 10。
 
详细的参数介绍将在下一篇文章中列出