当前位置:网站首页>pgbench基准测试《postgresql》
pgbench基准测试《postgresql》
2022-07-28 21:19:00 【liuyunshengsir】
pgbench是一种在PostgreSQL上运行基准测试的简单程序。它可能在并发的数据库会话中一遍一遍地运行相同序列的 SQL 命令,并且计算平均事务率(每秒的事务数)。默认情况下,pgbench会测试一种基于 TPC-B 但是要更宽松的场景,其中在每个事务中涉及五个SELECT、UPDATE以及INSERT命令。但是,通过编写自己的事务脚本文件很容易用来测试其他情况。
1.修改pg_hba.conf
host all all 10.6.8.0/24 trust
systemctl status postgresql-13
2.测试
2.1初始化
[[email protected] data]# /usr/pgsql-13/bin/pgbench -i --unlogged-tables -s 2 -U user001 -p 5432 -d db001 -h 10.6.8.238
dropping old tables...
creating tables...
generating data (client-side)...
200000 of 200000 tuples (100%) done (elapsed 0.07 s, remaining 0.00 s)
vacuuming...
creating primary keys...
done in 0.57 s (drop tables 0.03 s, create tables 0.03 s, client-side generate 0.24 s, vacuum 0.14 s, primary keys 0.12 s).
2.2 执行压力测试
-M prepared表示绑定变量形式的调用SQL,-r表示报告测试文件中每条SQL的平均执行延迟,
-c 8表示模拟8个客户端,-j 2表示pgbench的工作线程是2个,
-T 10表示压力测试的时间是10秒,-l表示把事务统计写入log,其余的是postgres连接相关的参数
以上参数,也可以结合命令帮助看出来
/usr/pgsql-13/bin/pgbench -M prepared -r -c 8 -j 2 -T 10 -U user001 -h 10.6.8.238 -p 5432 -d db001 -l
执行结果
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 2
query mode: prepared
number of clients: 8
number of threads: 2
duration: 10 s
number of transactions actually processed: 10945
latency average = 7.721 ms
tps = 1036.127306 (including connections establishing)
tps = 1036.693062 (excluding connections establishing)
statement latencies in milliseconds:
0.017 \set aid random(1, 100000 * :scale)
0.015 \set bid random(1, 1 * :scale)
0.014 \set tid random(1, 10 * :scale)
0.013 \set delta random(-5000, 5000)
0.572 BEGIN;
0.640 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
0.649 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
1.214 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
3.341 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
0.636 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
0.411 END;
边栏推荐
- Leetcode 199. right view of binary tree
- Padim [anomaly detection: embedded based]
- Fastflow [abnormal detection: normalizing flow]
- cnpm安装步骤
- Bullet frame mask layer "recommended collection"
- 记录一下关于三角函数交换积分次序的一道题
- Improvement 13 of yolov5: replace backbone network C3 with lightweight network efficientnetv2
- Mspba [anomaly detection: representation_based]
- Thesis reading (1) - zfnet of classification
- OSV_ q Expected all tensors to be on the same device, but found at least two devices, cuda:0
猜你喜欢
18张图,直观理解神经网络、流形和拓扑
LTE cell search process and sch/bch design
No code development platform management background tutorial
Shell script foundation - shell operation principle + variable and array definitions
记录一下关于三角函数交换积分次序的一道题
B站713故障后的多活容灾建设|TakinTalks大咖分享
Yolov5 improvement 5: improve the feature fusion network panet to bifpn
《Robust and Communication-Efficient Federated Learning From Non-i.i.d. Data》论文阅读
简单的es高亮实战
CGLIb 创建代理
随机推荐
Use the picture name to label the picture [tips]
OSV_ q AttributeError: ‘numpy. ndarray‘ object has no attribute ‘clone‘
No code development platform management background tutorial
芯华章宣布完成超2亿A轮融资,全面布局EDA2.0研发
Symbol符号类型
In 2020, the top ten domestic IC design enterprises will be exposed! These five industrial challenges still need to be overcome!
leetcode101. 对称二叉树
Labelme labels circular objects [tips]
leetcode 199. 二叉树的右视图
递归和迭代
The simple neural network model based on full connection layer MLP is changed to the model based on CNN convolutional neural network
Yolov5 improvement 7: loss function improvement
无代码开发平台通讯录入门教程
18张图,直观理解神经网络、流形和拓扑
Evaluation index of anomaly detection: rocauc et al. [tips]
记录一下关于三角函数交换积分次序的一道题
即将获售高通、联发科芯片,荣耀要超越华为做国内第一?
Summary of common formula notes for solving problems in Higher Mathematics
Wheel 7: TCP client
Migration from IPv4 to IPv6