暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

使用pgbench对磐维数据库进行压测

原创 feilunshuai 2025-09-11
86

一、初始化数据

pgbench -i -s 10 tpccdb 

-i 表示初始化数据
-s 表示scale大小,1个scale大概10w条数据


二、根据需要是否创建索引

create index on pgbench_accounts (bid);
create index on pgbench_accounts (abalance);


三、执行简单查询压测

[omm@db fei]$ pgbench -S -M simple -c 32 -j 32 -T 60 tpccdb 
starting vacuum...end.
transaction type: SELECT only
scaling factor: 10
query mode: simple
number of clients: 32
number of threads: 32
duration: 60 s
number of transactions actually processed: 13367009
latency average: 0.144 ms
tps = 222782.020398 (including connections establishing)
tps = 222882.990954 (excluding connections establishing)


四、执行自定义sql压测

[omm@db fei]$ cat 1.sql  
select * from pgbench_accounts where aid=100 ;

[omm@db fei]$ pgbench  -M extended -f 1.sql  -c 32 -j 32 -T 60 tpccdb 
starting vacuum...end.
transaction type: Custom query
scaling factor: 1
query mode: extended
number of clients: 32
number of threads: 32
duration: 60 s
number of transactions actually processed: 10600199
latency average: 0.181 ms
tps = 176668.134207 (including connections establishing)
tps = 176750.426042 (excluding connections establishing)



五、清理数据

drop table if exists pgbench_accounts, pgbench_branches, pgbench_tellers, pgbench_history cascade;



最后修改时间:2025-09-11 14:42:38
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论