pgbench –help

初始化选项:

-i            调用初始化模式

-F NUM  填充因子

-s NUM   规模因子(与产生数据量大小有关)

Benchmarking选项:

-c NUM    数据库客户端并发数(默认:1)

-C (为每个事务建立新的连接)

-D VARNAME=VALUE 通过客户脚本为用户定义变量

-f FILENAME 从文件FILENAME读取事务脚本

-j NUM  线程数(默认:1)

-i  写事务时间到日志文件

-M{simple|extended|prepared} 给服务器提交查询的协议

-n 在测试之前不运行VACUUM

-N 不更新表“pgbench_tellers” “pgbench_branches”

-r 报告每条命令的平均延迟

-s NUM 在输出中报告规模因子

-S      执行 SELECT-only事务

-t NUM 每个客户端运行的事务数(默认:10)

-T NUM benchmark测试时间(单位:秒)

-v 在测试前清空所有的四个标准表

常用选项:

-d 输出打印调试信息

-h HOSTNAME 数据库服务器主机或socket 目录

-U USERNAME 指定数据库用户的连接

--help 显示帮助信息,然后退出

--version 输出版本信息,然后退出

生成数据

postgres=# create user benchmarksql with superuser password '123456';

CREATE ROLE

postgres=# create database benchmarksql owner benchmarksql;

CREATE DATABASE

[postgres@DELL-R720 bin]$ ./pgbench -i -F 100 -s 714 -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql #10GB dataset

[postgres@DELL-R720 bin]$ ./pgbench -i -F 100 -s 1428 -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql #20GB dataset

[postgres@DELL-R720 bin]$ ./pgbench -i -F 100 -s 5712 -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql #80GB dataset

[postgres@DELL-R720 bin]$ ./pgbench -i -F 100 -s 11424 -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql #160GB dataset

连接的数据

[postgres@DELL-R720 bin]$ ./psql -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql

查看数据库大小

select pg_database_size('benchmarksql')/1024/1024/1024|| 'GB';

or

select pg_size_pretty(pg_database_size('benchmarksql'));

开始测试

[postgres@DELL-R720 bin]$ ./pgbench -c 10 –j –t  -r  -T 1800 -h 127.0.0.1 -p 6432 -U benchmarksql

transaction type: TPC-B (sort of)

scaling factor: 1428

query mode: prepared

number of clients: 10

number of threads: 10

duration: 1800 s

number of transactions actually processed: 1294479

latency average: 13.905 ms

tps = 715.507310 (including connections establishing)

tps = 715.510043 (excluding connections establishing)

statement latencies in milliseconds:

0.002768 \set nbranches 1 * :scale

0.000647 \set ntellers 10 * :scale

0.000562 \set naccounts 100000 * :scale

0.000823 \setrandom aid 1 :naccounts

0.000640 \setrandom bid 1 :nbranches

0.000684 \setrandom tid 1 :ntellers

0.000615 \setrandom delta -5000 5000

0.054656 BEGIN;

6.063291 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;

0.092079 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;

2.897447 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;

2.026997 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;

1.640868 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);

1.184043 END;

[postgres@DELL-R720 bin]$ ./pgbench -c 20 -j 20 -M prepared -n -s 1428 -T 1800 -r -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql

transaction type: TPC-B (sort of)

scaling factor: 1428

query mode: prepared

number of clients: 20

number of threads: 20

duration: 1800 s

number of transactions actually processed: 1503569

latency average: 23.943 ms

tps = 829.034591 (including connections establishing)

tps = 829.038294 (excluding connections establishing)

statement latencies in milliseconds:

0.003509 \set nbranches 1 * :scale

0.001146 \set ntellers 10 * :scale

0.000805 \set naccounts 100000 * :scale

0.001075 \setrandom aid 1 :naccounts

0.000881 \setrandom bid 1 :nbranches

0.000874 \setrandom tid 1 :ntellers

0.000881 \setrandom delta -5000 5000

0.077150 BEGIN;

9.083130 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;

0.123980 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;

6.025891 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;

3.595181 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;

3.098900 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);

2.098509 END;

transaction type: TPC-B (sort of)

scaling factor: 1428

query mode: prepared

number of clients: 30

number of threads: 10

duration: 1800 s

number of transactions actually processed: 1468864

latency average: 36.763 ms

tps = 815.178087 (including connections establishing)

tps = 815.184313 (excluding connections establishing)

statement latencies in milliseconds:

0.003654 \set nbranches 1 * :scale

0.001164 \set ntellers 10 * :scale

0.001123 \set naccounts 100000 * :scale

0.001288 \setrandom aid 1 :naccounts

0.001202 \setrandom bid 1 :nbranches

0.001106 \setrandom tid 1 :ntellers

0.001129 \setrandom delta -5000 5000

0.154459 BEGIN;

13.228743        UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;

0.212691 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;

9.070507 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;

4.904218 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;

5.595383 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);

3.612066 END;

[postgres@DELL-R720 bin]$ ./pgbench -c 50 -j 50 -M prepared -n -s 1428 -T 1800 -r -h 127.0.0.1 -p 6432 -U benchmarksql benchmarksql

transaction type: TPC-B (sort of)

scaling factor: 1428

query mode: prepared

number of clients: 50

number of threads: 50

duration: 1800 s

number of transactions actually processed: 1641175

latency average: 54.839 ms

tps = 901.460449 (including connections establishing)

tps = 901.475075 (excluding connections establishing)

statement latencies in milliseconds:

0.005079 \set nbranches 1 * :scale

0.001588 \set ntellers 10 * :scale

0.001257 \set naccounts 100000 * :scale

0.001768 \setrandom aid 1 :naccounts

0.001328 \setrandom bid 1 :nbranches

0.001424 \setrandom tid 1 :ntellers

0.001316 \setrandom delta -5000 5000

0.256724 BEGIN;

19.791906        UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;

0.284488 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;

13.638615        UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;

8.232851 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;

7.664059 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);

5.561957 END;

使用pgbench测试PostgreSQL的更多相关文章

  1. 使用BenchmarkSQL测试PostgreSQL

    BenchmarkSQL是一款经典的开源数据库测试工具,内嵌了TPCC测试脚本,可以对EnterpriseDB.PostgreSQL.MySQL.Oracle以及SQL Server等数据库直接进行测 ...

  2. [原创]使用benchmarksql和pgbench对PostgreSQL Plus Advanced Server进行性能测试

    一.测试环境 benchmarksql version:4.0.8 rhel 6.3 vmware esxi 二.理解benchmarksql性能测试原理TPC-C 1.理解TPC-C TPC-C模拟 ...

  3. benchmark测试PostgreSQL数据库OLTP性能

    1,安装配置PostgreSQL数据库 2,下载地址:http://sourceforge.net/projects/benchmarksql/?source=navbar Required:JDK7 ...

  4. postgresql压力测试工具用法以及参数解读

    pgbench是PostgreSQL自带的一个数据库压力测试工具, 支持TPC-B测试模型, 或自定义测试模型. 自定义测试模型支持元命令, 调用shell脚本, 设置随机数, 变量等等. 支持3种异 ...

  5. PostgreSQL Performance Monitoring Tools

    PostgreSQL Performance Monitoring Tools https://github.com/CloudServer/postgresql-perf-tools This pa ...

  6. PostgreSQL Insight Monitor pgstat

    PostgreSQL Insight Monitor  pgstat pgstat 是一个连接到数据库并获取数据库的活动状态的命令行工具. PostgreSQL有许多状态: archiver for ...

  7. PostgreSQL Monitor pg_view

    PostgreSQL Monitor pg_view https://github.com/zalando/pg_view Requirements Linux 2.6, python 2.6, ps ...

  8. PostgreSQL Monitor pg_activity

    PostgreSQL Monitor pg_activity Command line tool for PostgreSQL server activity monitoring. https:// ...

  9. Postgresql集群解决方案测试报告

    1 测试主体 本次测试的主体有3个,分别为: GreenPlum集群,下文简称为GP Postgres-XC集群,下文简称为XC Postgresql单数据库实例,下文简称为pgsql GP和XC都选 ...

随机推荐

  1. 类库引用EF

    安装EntityFramework 添加引用system.data.entity;

  2. linux命令篇

    普通用户登陆,充值root密码: sudo passwd root

  3. jfinal

    http://blog.csdn.net/zb0567/article/details/21083021

  4. C# Json时间类型的转换

    DateTime dt1 = new DateTime(1970, 1, 1); dt1 = dt1.AddMilliseconds(long.Parse(list.Items[i].UpdatedA ...

  5. Node的Buffer

    var buf3 = new Buffer([1,2,3,4,-10,256],'utf8');//默认为utf8 console.log(buf3[0]);//正常的范围是0~255 console ...

  6. iOS开发教程之:iPhone开发环境搭建

    安装条件: 硬件:一台拥有支持虚拟技术的64位双核处理器和2GB以上内存的PC. 注意:运行MAC OS,需要电脑支持虚拟技术(VT),安装时,需要将VT启动,在BIOS中开启. 软件: Window ...

  7. 查看sqlserver版本及其补丁

    select @@version select serverproperty('productlevel')

  8. nodejs技术面试问题整理

    1.meteor 是如何解决多回调的问题 参考 http://www.cnblogs.com/meteorcn/p/MeteorJS_Async_Fiber_Future_Wrap.html 2.一个 ...

  9. Maven-002-eclipse 插件安装及实例

    因为平常编码的时候,习惯了使用 eclipse 进行编码,因而需要将 eclipse 安装 maven 的插件,安装步骤如下所示: 一.安装 选择菜单: help -> Install New  ...

  10. JMeter学习-012-JMeter 配置元件之-HTTP Cookie管理器-实现 Cookie 登录

    前文我们讲过了若何获取登录后的 Cookie 信息,不知如何获取登录 Cookie 的朋友,敬请参阅我之前写的博文:Fiddler-005-获取 Cookie 信息.参阅上篇文章,获取到 Cookie ...