postgresql自带提供了一款轻量级的压力测试工具:pgbench, 可自行编写脚本,按自己的需求对数据库进行性能压力测试。
参数介绍:
pgbench --help
pgbench is a benchmarking tool for PostgreSQL.
Usage:
pgbench [OPTIONS]... [DBNAME]
Initialization options:
-i invokes initialization mode 初始化模式
-F NUM fill factor fillfactor
-s NUM scaling factor 销售端个数
Benchmarking options:
-c NUM number of concurrent database clients (default: 1) 模拟客户端个数
-C establish new connection for each transaction 设定为每一个事务建一个新连接
-D VARNAME=VALUE 传递测试脚本中变量值
define variable for use by custom script
-f FILENAME read transaction script from FILENAME 测试脚本位置
-j NUM number of threads (default: 1) 启动线程数
-l write transaction times to log file 丁香输出日志文件
-M {simple|extended|prepared}
protocol for submitting queries to server (default: simple)
-n do not run VACUUM before