創(chuàng)建測(cè)試表, 并填充數(shù)據(jù) 5000W 筆記錄. pgbench -i -F 100 -s 500 -h 127.0.0.1 -U user
壓力測(cè)試 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;
多次測(cè)試的結(jié)果:
tps 在19000 左右.
數(shù)據(jù)庫冷啟動(dòng)后,直接壓測(cè)的結(jié)果:
tps : 16000左右.
|