创建测试表, 并填充数据 5000W 笔记录. pgbench -i -F 100 -s 500 -h 127.0.0.1 -U user
压力测试 300秒. 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;
多次测试的结果:
tps 在19000 左右.
数据库冷启动后,直接压测的结果:
tps : 16000左右.
|