IT 관련/PostgreSQL

[PostgreSQL] pgbench 테스트 하는법

상어 우두머리 2025. 9. 15. 10:15
728x90

초기화 작업

[postgres@failoverprimary scripts]$ pgbench -i postgres
dropping old tables...
NOTICE:  table "pgbench_accounts" does not exist, skipping
NOTICE:  table "pgbench_branches" does not exist, skipping
NOTICE:  table "pgbench_history" does not exist, skipping
NOTICE:  table "pgbench_tellers" does not exist, skipping
creating tables...
generating data (client-side)...
100000 of 100000 tuples (100%) done (elapsed 0.13 s, remaining 0.00 s)
vacuuming...
creating primary keys...
done in 0.45 s (drop tables 0.01 s, create tables 0.08 s, client-side generate 0.23 s, vacuum 0.05 s, primary keys 0.08 s).

 

초기화 수행 시 생성되는 테이블

[postgres@failoverprimary scripts]$ psql
psql (16.10)
Type "help" for help.

postgres=# \dt
              List of relations
 Schema |       Name       | Type  |  Owner
--------+------------------+-------+----------
 public | pgbench_accounts | table | postgres
 public | pgbench_branches | table | postgres
 public | pgbench_history  | table | postgres
 public | pgbench_tellers  | table | postgres
(4 rows)

 

테스트 진행

-c number of concurrent database clients

-j number of thread

-t 몇번 돌릴건지

[postgres@failoverprimary scripts]$ pgbench -h localhost -p 5432 -U postgres -c 4 -j 4 -t 10
pgbench (16.10)
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 4
maximum number of tries: 1
number of transactions per client: 10
number of transactions actually processed: 40/40
number of failed transactions: 0 (0.000%)
latency average = 4.836 ms
initial connection time = 55.211 ms
tps = 827.129859 (without initial connection time)


[postgres@failoverprimary scripts]$ pgbench -h localhost -p 5432 -U postgres -c 10 -j 8 -t 100
pgbench (16.10)
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 8
maximum number of tries: 1
number of transactions per client: 100
number of transactions actually processed: 1000/1000
number of failed transactions: 0 (0.000%)
latency average = 12.821 ms
initial connection time = 119.556 ms
tps = 779.983137 (without initial connection time)

 

728x90