pgbench是postgresql进行压测的官方工具,熟悉这一工具的使用,对于后续数据库侧配置参数修改带来的影响,提供了客观的数据参考。
初始化测试库
create database mydb;
创建表
pgbench -Upostgres -i mydb;
测试
pgbench -Upostgres -c 2 -j 2 -t 10000 mydb;
注释:
- -c 建立链接数
- -j 启动的线程数,在pgbench中启动多个线程
- -t 进行多少的transaction
- -T 测试进行多少时间, -T和-t是互斥选项,只能二选一
- -P 多少秒打印一次信息
只进行select测试
pgbench -Upostgres -c2 -j2 -T 120 -P5 -S -n
注释
- -S 只进行query测试
- -n 跳过初始的vacuum