Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement stress Test script by pgbench

Shulou Source: shulou.com Published: 2022-06-02 06:02:16 09月21日 Update

This article mainly introduces how to implement pgbench stress test script, the article is very detailed, has a certain reference value, interested friends must read!

Create a test table and fill it with data 5000W pen records.

pgbench -i -F 100 -s 500 -h 127.0.0.1 -U user

Pressure test 300 seconds.

pgbench -c 128 -j 1024 -M prepared -n -s 500 -T 300 -f ./ rw.sql -h 127.0.0.1 -p 5432 -U user

cat rw.sql

\set nbranches :scale

\set ntellers 10 * :scale

\set naccounts 100000 * :scale

\set aid random( 1 ,:naccounts )

\set bid random(1 ,:nbranches )

\set tid random( 1, :ntellers )

\set delta random(-5000, 5000 )

BEGIN;

UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;

SELECT abalance FROM pgbench_accounts WHERE aid = :aid;

UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;

UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;

INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CLOCK_TIMESTAMP());

END;

Results of multiple tests:

Tps is around 19000.

After the database cold start, direct pressure test results:

tps : around 16000.

The above is "pgbench how to implement stress test script" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Tests stress scripts content data articles results value interests guys buddies databases more knowledge industry information information channels channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Xiaomi MySQL MariaDB Shulou Tech Info