使用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都选 ...
随机推荐
- a read only variable
SHOW VARIABLES LIKE '%FORMAT%' SET DATE_FORMAT ='%Y-%m-%d' [SQL]SET DATE_FORMAT ='%Y-%m-%d' [Err] 12 ...
- java继承覆盖总结
Java基础(1) 版权声明:本文为博主原创文章,未经博主允许不得转载. java的继承与覆盖基本是java笔试中常出的题,也比较绕,我这里对java的继承覆盖做一个总结1.构造函数: ...
- 【转】Unity3D中脚本的执行顺序和编译顺序(vs工程引用关系)
http://www.cnblogs.com/champ/p/execorder.html 在Unity中可以同时创建很多脚本,并且可以分别绑定到不同的游戏对象上,它们各自都在自己的生命周期中运行.与 ...
- HashSet HashTable HashMap的区别
(1)HashSet是set的一个实现类,hashMap是Map的一个实现类,同时hashMap是hashTable的替代品(为什么后面会讲到). (2)HashSet以对象作为元素,而HashMap ...
- HBase的二级索引,以及phoenix的安装(需再做一次)
一:HBase的二级索引 1.讲解 uid+ts 11111_20161126111111:查询某一uid的某一个时间段内的数据 查询某一时间段内所有用户的数据:按照时间 索引表 rowkey:ts+ ...
- openssh-server 安装
sudo apt-get update sudo apt-get install openssh-server 1:ssh-keygen -t rsa -f ~/.ssh/id_rsa 这里会提示输入 ...
- Linq&Lumda---LINQ to DataSet的DataTable操作
1. DataTable读取列表 DataSet ds = new DataSet();// 省略ds的Fill代码DataTable products = ds.Tables["Produ ...
- android判断网络连接状态、联网类型、运营商
/** * 获取上网方式 * * @param mContext * @return */ public static String getNetType(Context mContext) { St ...
- ArcGIS API for Silverlight实现地图测距功能
原文:ArcGIS API for Silverlight实现地图测距功能 问题:如何实现地图测距功能? 地图工具栏 <Grid x:Name="gToolMenu" Hei ...
- 二级c程序设计题(2)
原文:http://www.cnblogs.com/imaker/p/6128049.html 所属年份:2010.9;2012.3编写函数fun,其功能是:根据以下公式求π的值(要求精度0.0005 ...