pgbench并发查询测试

最近更新时间: 2025-02-18 16:02:00

  • 复制
    复制成功
[tbase@VM_0_37_centos pgbench]$ cat select_t_trgm.sql
\set id random(1, 1000000)
select * from t_trgm where no_trgm ilike '%'||substring(md5(:id) from 3 for 6)||'%';
[tbase@VM_0_37_centos pgbench]$ pgbench -h 127.0.0.1 -p 11008 -d postgres -U tbase -c 4 -j 1 -n -M prepared -T 60 -r -f select_t_trgm.sql > select_t_trgm.txt 2>&1
[tbase@VM_0_37_centos pgbench]$ tail -20 select_t_trgm.txt
client 3 receiving
client 2 receiving
client 1 receiving
client 3 receiving
client 0 receiving
pghost: 127.0.0.1 pgport: 11008 nclients: 4 duration: 60 dbName: postgres
transaction type: select_t_trgm.sql
scaling factor: 1
query mode: prepared
number of clients: 4
number of threads: 1
duration: 60 s
number of transactions actually processed: 212
latency average = 1147.939 ms
tps = 3.484507 (including connections establishing)
tps = 3.484812 (excluding connections establishing)
script statistics:
 - statement latencies in milliseconds:
         0.016  \set id random(1, 1000000)
      1144.441  select * from t_trgm where no_trgm ilike '%'||substring(md5(:id) from 3 for 6)||'%';
[tbase@VM_0_37_centos pgbench]$ cat select_t_trgm.sql
\set id random(1, 1000000)
select * from t_trgm where no_trgm ilike '%'||md5(:id)||'%';
[tbase@VM_0_37_centos pgbench]$ pgbench -h 127.0.0.1 -p 11008 -d postgres -U tbase -c 4 -j 1 -n -M prepared -T 60 -r -f select_t_trgm.sql > select_t_trgm.txt 2>&1
[tbase@VM_0_37_centos pgbench]$ tail -20 select_t_trgm.txt
client 3 receiving
client 1 receiving
client 0 receiving
client 2 receiving
client 3 receiving
pghost: 127.0.0.1 pgport: 11008 nclients: 4 duration: 60 dbName: postgres
transaction type: select_t_trgm.sql
scaling factor: 1
query mode: prepared
number of clients: 4
number of threads: 1
duration: 60 s
number of transactions actually processed: 175
latency average = 1384.472 ms
tps = 2.889189 (including connections establishing)
tps = 2.889430 (excluding connections establishing)
script statistics:
 - statement latencies in milliseconds:
         0.015  \set id random(1, 1000000)
      1379.714  select * from t_trgm where no_trgm ilike '%'||md5(:id)||'%';