事务内容postgresql pgbench
在寫這篇文章之前,xxx已經寫過了幾篇關于改事務內容主題的文章,想要了解的朋友可以去翻一下之前的文章
????pgbench is a benchmarking tool for PostgreSQL ,pgbench是postgresql自帶的一個性能基準測試工具。
????可以通過pgbench --help看一下參數的相關信息
????Usage:
? pgbench [OPTIONS]... [DBNAME]
????Initialization options:
? -i?????????? invokes initialization mode
? -F NUM?????? fill factor
? -s NUM?????? scaling factor
????Benchmarking options:
? -c NUM?????? number of concurrent database clients (default: 1)
? -C?????????? establish new connection for each transaction
? -D VARNAME=VALUE
?????????????? define variable for use by custom script
? -f FILENAME? read transaction script from FILENAME
? -j NUM?????? number of threads (default: 1)
? -l?????????? write transaction times to log file
? -M {simple|extended|prepared}
?????????????? protocol for submitting queries to server (default: simple)
? -n?????????? do not run VACUUM before tests
? -N?????????? do not update tables "pgbench_tellers" and "pgbench_branches"
? -r?????????? report average latency per command
? -s NUM?????? report this scale factor in output
? -S?????????? perform SELECT-only transactions
? -t NUM?????? number of transactions each client runs (default: 10)
? -T NUM?????? duration of benchmark test in seconds
? -v?????????? vacuum all four standard tables before tests
????Common options:
? -d?????????? print debugging output
? -h HOSTNAME? database server host or socket directory
? -p PORT????? database server port number
? -U USERNAME? connect as specified database user
? --help?????? show this help, then exit
? --version??? output version information, then exit
????初始化:scale為10,pgbench_accounts記錄有100W,
????pgbench -i -s 10 pgbench -h 127.0.0.1 -p 1931 -U testuser
????這里初始化會創立4張表,如下
?????Schema |?????? Name?????? | Type? |? Owner?? |? Size? | Description?
--------+------------------+-------+----------+--------+-------------
?public | pgbench_accounts | table | testuser | 130 MB |?
?public | pgbench_branches | table | testuser | 168 kB |?
?public | pgbench_history? | table | testuser | 960 kB |?
?public | pgbench_tellers? | table | testuser | 456 kB |
????測試:100個client并發,每一個有100個事務
????pgbench? -c 100 -t 100 pgbench
starting vacuum...end.
transaction type: TPC-B (sort of)
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 1
number of transactions per client: 100
number of transactions actually processed: 10000/10000
tps = 114.339158 (including connections establishing)? --包括網絡開銷的事務數
tps = 114.643324 (excluding connections establishing)? --不包括網絡開銷的事務數
我拽著春姑娘的衣裙,春姑娘把我帶到了綠色的世界里。
????pgbench? -c 100 -t 100 -j 100 pgbench
starting vacuum...end.
transaction type: TPC-B (sort of)
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 100
number of transactions per client: 100
number of transactions actually processed: 10000/10000
tps = 134.473603 (including connections establishing)
tps = 134.616838 (excluding connections establishing)
????這里注意-c必須是-j的倍數,也就是client是threads的倍數。
????pgbench? -c 100? -j 100 -T 10 pgbench
starting vacuum...end.
transaction type: TPC-B (sort of)
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 100
duration: 10 s
number of transactions actually processed: 2144
tps = 209.617862 (including connections establishing)
tps = 211.282453 (excluding connections establishing)
????注意:-t和-T不能同時使用,
????腳本的內容:
????\set nbranches :scale
\set ntellers 10 * :scale
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\setrandom delta -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, CURRENT_TIMESTAMP);
END;
????舉例測試一下呆板insert的速度有多快
????insertsize.sql內容:create table data(filler text);
????insert-size.sql內容:insert into data (filler) values (repeat('X',:scale));
????$psql -d pgbench -f insertsize.sql?
????$pgbench -s 100 -c 10 -t 10000 pgbench -f insert-size.sql?
starting vacuum...end.
transaction type: Custom query
scaling factor: 100
query mode: simple
number of clients: 10
number of threads: 1
number of transactions per client: 10000
number of transactions actually processed: 100000/100000
tps = 608.144907 (including connections establishing)
tps = 608.234303 (excluding connections establishing)
文章結束給大家分享下程序員的一些笑話語錄: 手機終究會變成PC,所以ip會比wm更加暢銷,但是有一天手機強大到一定程度了就會發現只有wm的支持才能完美享受。就好比樹和草,草長得再高也是草,時間到了條件成熟了樹就會竄天高了。www.ishuo.cn
轉載于:https://www.cnblogs.com/jiangu66/archive/2013/05/14/3078668.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的事务内容postgresql pgbench的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 全面剖析VeriSign代码签名证书
- 下一篇: 文档null一段 虚拟机操作