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. linux回到上次目录与历史命令查找快捷方式

    # cd -进入上次访问目录 二.历史命令搜索操作快捷键:[Ctrl + r], [Ctrl + p], [Ctrl + n] 在终端中按捉 [Ctrl] 键的同时 [r] 键,出现提示:(rever ...

  2. Java中测试对象的等价性

    Java中用于测试对象的等价性有三个操作符:== , != 和 Equals() 对于基本类型即int,boolean, byte 等等来说,==和 != 比较的是 基本类型的内容,这和c.c++是一 ...

  3. HBase的完全分布式的搭建与部署,以及多master

    一:前提准备 1.设置时间同步 2.清空logs,datas 3.格式化集群 bin/hdfs namenode -format 4.重启集群 sbin/start-dfs.sh sbin/start ...

  4. 大数据下的java client连接JDBC

    1.前提 启动hiveserver2服务 url,username,password 2.程序 3.结果 emp的第一列与第二列

  5. xdebug和xhprof

    在安装时出现不是:1% 不是有效的win32 应用程序原因可能是是下载了64位的.dll扩展与当前的php不兼容

  6. 判断是否是 首次 进入app,,以及Xcode7之后前导页的设置

    我的解决方案:... 1.在appdelegate.m中找到 “application:didFinishLaunchingWithOptions:”方法, 添加以下代码: /** *      前导 ...

  7. c#上传文件(二)使用文件流保存文件

    1.html代码: <asp:FileUpload runat="server" ID="UpLoadFile"/> <asp:Button ...

  8. 如何将XML文件写入数据库

    将xml文件转成string public string XMLDocumentToString(XmlDocument doc) { MemoryStream stream = new Memory ...

  9. 二级c程序设计题(2)

    原文:http://www.cnblogs.com/imaker/p/6128049.html 所属年份:2010.9;2012.3编写函数fun,其功能是:根据以下公式求π的值(要求精度0.0005 ...

  10. 查看CentOS上Apache位置,版本,停止,启动

    查看Apache是否被安装: [root@asg11 ~]# find / -name 'httpd'/etc/sysconfig/httpd/etc/httpd/etc/logrotate.d/ht ...