創建測試表, 并填充數據 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左右.
|