使用pgbench测试PostgreSQL
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的更多相关文章
- 使用BenchmarkSQL测试PostgreSQL
BenchmarkSQL是一款经典的开源数据库测试工具,内嵌了TPCC测试脚本,可以对EnterpriseDB.PostgreSQL.MySQL.Oracle以及SQL Server等数据库直接进行测 ...
- [原创]使用benchmarksql和pgbench对PostgreSQL Plus Advanced Server进行性能测试
一.测试环境 benchmarksql version:4.0.8 rhel 6.3 vmware esxi 二.理解benchmarksql性能测试原理TPC-C 1.理解TPC-C TPC-C模拟 ...
- benchmark测试PostgreSQL数据库OLTP性能
1,安装配置PostgreSQL数据库 2,下载地址:http://sourceforge.net/projects/benchmarksql/?source=navbar Required:JDK7 ...
- postgresql压力测试工具用法以及参数解读
pgbench是PostgreSQL自带的一个数据库压力测试工具, 支持TPC-B测试模型, 或自定义测试模型. 自定义测试模型支持元命令, 调用shell脚本, 设置随机数, 变量等等. 支持3种异 ...
- PostgreSQL Performance Monitoring Tools
PostgreSQL Performance Monitoring Tools https://github.com/CloudServer/postgresql-perf-tools This pa ...
- PostgreSQL Insight Monitor pgstat
PostgreSQL Insight Monitor pgstat pgstat 是一个连接到数据库并获取数据库的活动状态的命令行工具. PostgreSQL有许多状态: archiver for ...
- PostgreSQL Monitor pg_view
PostgreSQL Monitor pg_view https://github.com/zalando/pg_view Requirements Linux 2.6, python 2.6, ps ...
- PostgreSQL Monitor pg_activity
PostgreSQL Monitor pg_activity Command line tool for PostgreSQL server activity monitoring. https:// ...
- Postgresql集群解决方案测试报告
1 测试主体 本次测试的主体有3个,分别为: GreenPlum集群,下文简称为GP Postgres-XC集群,下文简称为XC Postgresql单数据库实例,下文简称为pgsql GP和XC都选 ...
随机推荐
- PHP中数组合并的两种方法及区别介绍
PHP数组合并两种方法及区别 如果是关联数组,如下: 复制代码代码如下: $a = array( 'where' => 'uid=1', 'order' => 'uid', ); $b = ...
- memcached 命中率问题 分析 **
Memcached, 人所皆知的remote distribute cache(不知道的可以javaeye一下下,或者google一下下,或者baidu一下下,但是鉴于baidu的排名商业味道太浓(从 ...
- Apache Kafka源码分析 - KafkaApis
kafka apis反映出kafka broker server可以提供哪些服务,broker server主要和producer,consumer,controller有交互,搞清这些api就清楚了 ...
- 三 mybatis typeAlias(别名)使用和resultMap使用
1.MyBatis提供的typeAlias
- WAMP数据库环境搭建
php.ini: date.timezone = Etc/GMT-8//设置北京时间 my.ini: character_set_server=utf8//设置utf8 innodb_force_re ...
- android硬件调试之无法识别android设备解决办法
DDMS 中无法识别华为荣耀六手机, 用豌豆荚开始显示无法连接, 用豌豆荚安装完驱动后,就可以连接了 http://www.zhihu.com/question/30588024 http://w ...
- Scrum 的相关概念
Scrum 的相关概念 4.1 Scrum 的起源 Scrum 是一种灵活的敏捷软件开发管理过程,这个名词来源于英式橄榄球.Scrum方法由Ken Schwaber和Jeff Sutherland ...
- 原因是未找到“sgen.exe”,或未安装 .NET Framework SDK v2.0
visual studio编译出现错误:错误 2 任务失败,原因是未找到“sgen.exe”,或未安装 .NET Framework SDK v2.0.该任务正在注册表项 HKEY_LOCAL_MAC ...
- magento url rewrite using config.xml
magento url rewrite using config.xml 2012-08-03 14:34:22| 分类: magento|举报|字号 订阅 郁闷了两天啊 http://12 ...
- 关于lnmp下搭thinkPHP无法找到指定静态页面
我在lnmp 下架了一个thinkPHP框架,非常奇怪,在环境都配置好后,我在url里输入localhost:10007/index.php/member/login,正常来说应该显示login.ht ...