[转帖]PostgreSQL 压测工具pgbench
1.命令
-
pgbench --help
-
-
pgbench is a benchmarking tool for PostgreSQL.
-
-
Usage:
-
pgbench [OPTION]... [DBNAME]
-
-
Initialization options:
-
-i, --initialize invokes initialization mode 初始化模式
-
-F, --fillfactor=NUM set fill factor
-
-n, --no-vacuum do not run VACUUM after initialization
-
-q, --quiet quiet logging (one message each 5 seconds)
-
-s, --scale=NUM scaling factor
-
--foreign-keys create foreign key constraints between tables
-
--index-tablespace=TABLESPACE
-
create indexes in the specified tablespace
-
--tablespace=TABLESPACE create tables in the specified tablespace
-
--unlogged-tables create tables as unlogged tables
-
-
Options to select what to run:
-
-b, --builtin=NAME[@W] add builtin script NAME weighted at W (default: 1)
-
(use "-b list" to list available scripts)
-
-f, --file=FILENAME[@W] add script FILENAME weighted at W (default: 1) 测试脚本位置(可以自定义)
-
-N, --skip-some-updates skip updates of pgbench_tellers and pgbench_branches
-
(same as "-b simple-update")
-
-S, --select-only perform SELECT-only transactions
-
(same as "-b select-only")
-
-
Benchmarking options:
-
-c, --client=NUM number of concurrent database clients (default: 1) 模拟客户端个数,相当于并发量
-
-C, --connect establish new connection for each transaction 设定为每一个事务建一个新连接
-
-D, --define=VARNAME=VALUE
-
define variable for use by custom script
-
-j, --jobs=NUM number of threads (default: 1) 启动线程数
-
-l, --log write transaction times to log file
-
-L, --latency-limit=NUM count transactions lasting more than NUM ms as late
-
-M, --protocol=simple|extended|prepared
-
protocol for submitting queries (default: simple)
-
-n, --no-vacuum do not run VACUUM before tests
-
-P, --progress=NUM show thread progress report every NUM seconds 每隔数秒显示线程进度报告
-
-r, --report-latencies report average latency per command 报告每个命令的平均延迟
-
-R, --rate=NUM target rate in transactions per second
-
-s, --scale=NUM report this scale factor in output
-
-t, --transactions=NUM number of transactions each client runs (default: 10)
-
-T, --time=NUM duration of benchmark test in seconds 测试时间,单位:秒
-
-v, --vacuum-all vacuum all four standard tables before tests
-
--aggregate-interval=NUM aggregate data over NUM seconds
-
--progress-timestamp use Unix epoch timestamps for progress
-
--sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%)
-
-
Common options:
-
-d, --debug print debugging output
-
-h, --host=HOSTNAME database server host or socket directory
-
-p, --port=PORT database server port number
-
-U, --username=USERNAME connect as specified database user
-
-V, --version output version information, then exit
-
-?, --help show this help, then exit
2.初始化
-
su - postgres
-
-
# 使用postgres作为测试库
-
pgbench -i -d postgres
-
-
# 使用默认参数创造的测试表,各表的数据量:
-
pgbench_accounts:100000
-
pg_branches:1
-
pg_tellers:10
pgbench -i -F 100 -s 100 -d postgres
3.压力测试
(1)测试一个客户端session(用户)
pgbench -c 1 -T 20 -r -d postgres
(2)测试30个客户端session(用户)
pgbench -c 30 -T 20 -r -d postgres
4.自定义脚本压力测试
create table test(id int primary key, info text, crt_time timestamp);
-
vi test.sql
-
\set id random(1,100000000)
-
insert into test (id,info,crt_time) values (:id, md5(random()::text), now()) on conflict (id) do update set info=excluded.info, crt_time=excluded.crt_time;
pgbench -M prepared -r -f ./test.sql -c 32 -j 32 -T 20 -d postgres
[转帖]PostgreSQL 压测工具pgbench的更多相关文章
- super-smack压测工具
简介 super-smack是一款开源压测工具,支持MySQL.PostgreSQL.Oracle.本篇主要介绍一下使用super-smack压测MySQL体会. 1.SQL定义 2.数据字典定义 3 ...
- Http压测工具wrk使用指南
用过了很多压测工具,却一直没找到中意的那款.最近试了wrk感觉不错,写下这份使用指南给自己备忘用,如果能帮到你,那也很好. 安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持 ...
- web压测工具http_load原理分析
一.前言 http_load是一款测试web服务器性能的开源工具,从下面的网址可以下载到最新版本的http_load: http://www.acme.com/software/http_load/ ...
- [软件测试]网站压测工具Webbench源码分析
一.我与webbench二三事 Webbench是一个在linux下使用的非常简单的网站压测工具.它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能.Webbench ...
- Http压测工具wrk使用指南【转】
用过了很多压测工具,却一直没找到中意的那款.最近试了wrk感觉不错,写下这份使用指南给自己备忘用,如果能帮到你,那也很好. 安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持 ...
- python服务端多进程压测工具
本文描述一个python实现的多进程压测工具,这个压测工具的特点如下: 多进程 在大多数情况下,压测一般适用于IO密集型场景(如访问接口并等待返回),在这种场景下多线程多进程的区分并不明显(详情请参见 ...
- 内存压测工具Memtester
在做压力测试时,发现一个内存压测工具Memtester,可以随意设置内存占用大小,非常方便 下载地址:http://pyropus.ca/software/memtester/old-versions ...
- Http 压测工具 wrk 基本使用
Http 压测工具 wrk 基本使用 Intro wrk 是一款现代HTTP基准测试工具,能够在单个多核CPU上运行时产生显着负载.它将多线程设计与可扩展事件通知系统(如epoll和kqueue)结合 ...
- 压测工具使用(vegeta)
一.压测工具vegeta 1.介绍 Vegeta 是一个用 Go 语言编写的多功能的 HTTP 负载测试工具,它提供了命令行工具和一个开发库. 官方地址:https://github.com/tsen ...
- 003_ab http压测工具
一. ab -r -k -c 20000 -n 25000000 https://www.uuwatch.me/abtest #ab压测工具单机最大并发为20000,可以在多台机器上执行以增大并发 y ...
随机推荐
- WinForm如何将子控件插入FlowLayoutPanel开始位置
需求描述 动态将控件插入到FlowLayoutPanel控件的开始位置 实现方案 将控件添加到FlowLayoutPanel的Controls集合中,默认插到末尾 使用SetChildIndex方法更 ...
- Mybatis源码5 StatementHandler ,ParameterHandler
Mybatis5 StatementHandler ,ParameterHandler 一丶概述 前面我们总结了SqlSession--->CachingExecutor--->BaseE ...
- Llama2-Chinese项目:5-推理加速
随着大模型参数规模的不断增长,在有限的算力资源下,提升模型的推理速度逐渐变为一个重要的研究方向.常用的推理加速框架包含lmdeploy.FasterTransformer和vLLM等. 一.lmd ...
- 详解GaussDB(DWS)用户监控原理及应用
摘要:本文将聚焦于用户监控的原理及应用进行介绍. 本文分享自华为云社区<GaussDB(DWS)监控工具指南(二)用户级监控>,作者:幕后小黑爪 . 前言 资源监控是整个运维乃至整个产品生 ...
- 开源遇上华为云——DataX for HuaweiCloud OBS
摘要:欢迎越来越多的开发者加入,与华为云一起不断成长,繁荣开源生态. 本文分享自华为云社区<开源遇上华为云--DataX for HuaweiCloud OBS>,作者:华为云社区精选. ...
- 一文详述DMS资源池队列阻塞告警及原理
摘要: 本文主要对DMS资源池队列阻塞告警进行介绍,以及对其背后涉及的内核原理进行介绍. 本文分享自华为云社区<DMS资源池队列阻塞告警及原理介绍>,作者: codefulture. 一. ...
- 揭秘华为云GaussDB(for Influx):最佳实践之数据建模
摘要:本期将从GaussDB(for Influx)数据模型谈起,分享GaussDB(for Influx)数据建模的最佳方法,避免一些使用过程中的常见问题. 本文分享自华为云社区<华为云Gau ...
- SQL优化老出错,那是你没弄明白MySQL解释计划
摘要:数据库的解释计划阐明了sql的执行过程,展示了执行的细节,只要根据数据库告诉我们的问题按图索骥的分析就可以. 本文分享自华为云社区<轻松搞懂mysql的执行计划,再也不怕sql优化了> ...
- Mac 常用软件、快捷健、常用操作 和 Windows 对比
常用快捷健 Mac Windows 说明 活动监视器 任务管理器 制作替身 创建快捷方式 Command + I 右击属性 显示简介 Command + Option + I 开启信息检查器 + 鼠标 ...
- 万物皆可秒——淘宝秒杀Python脚本,扫货618,备战双11!
更多精彩内容,欢迎关注公众号:数量技术宅,也可添加技术宅个人微信号:sljsz01,与我交流. 总是抢不到想要的宝贝?试试Python脚本 对于淘宝.天猫,相信大家已经无比的熟悉,在每年的双十一.双十 ...