os: centos 7.4
db: postgresql 10.10
# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
#
# su - postgres
Last login: Sat Oct 26 22:55:25 CST 2019 on pts/0
$
$ psql -c "select version();"
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 10.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)
# su - postgres
$ psql
postgres=#\c pgbenchdb
pgbenchdb=# create table tmp_t0(
id varchar(32) not null,
message_id varchar(32),
persion_id varchar(32) not null,
del_flag int4,
create_time timestamp
)
;
pgbenchdb=# create index idx_tmp_t0_x1 on tmp_t0(id);
create index idx_tmp_t0_x2 on tmp_t0(persion_id);
# su - postgres
$ vim /var/lib/pgsql/scripts/nonpar_insert.sql
\set v_id random(1, 10000000)
\set v_message_id random(1, 10000000)
\set v_persion_id random(1, 100000)
\set v_del_flag random(1, 2)
BEGIN;
INSERT INTO tmp_t0 (id, message_id, persion_id, del_flag, create_time) VALUES (:v_id, :v_message_id, :v_persion_id, :v_del_flag, CURRENT_TIMESTAMP);
END;
# su - postgres
$ /usr/pgsql-10/bin/pgbench -r -j 2 -c 4 -T 60 -P 1 -f /var/lib/pgsql/scripts/nonpar_insert.sql pgbenchdb
starting vacuum...end.
progress: 1.0 s, 252.0 tps, lat 15.417 ms stddev 62.785
progress: 2.5 s, 447.0 tps, lat 7.467 ms stddev 19.430
progress: 3.0 s, 561.5 tps, lat 10.660 ms stddev 41.767
transaction type: /var/lib/pgsql/scripts/nonpar_insert.sql
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 2
duration: 60 s
number of transactions actually processed: 27333
latency average = 8.778 ms
latency stddev = 27.445 ms
tps = 455.469205 (including connections establishing)
tps = 455.559694 (excluding connections establishing)
script statistics:
- statement latencies in milliseconds:
0.008 \set v_id random(1, 10000000)
0.003 \set v_message_id random(1, 10000000)
0.002 \set v_persion_id random(1, 100000)
0.002 \set v_del_flag random(1, 2)
0.988 BEGIN;
1.606 INSERT INTO tmp_t0 (id, message_id, persion_id, del_flag, create_time) VALUES (:v_id, :v_message_id, :v_persion_id, :v_del_flag, CURRENT_TIMESTAMP);
6.176 END;
# su - postgres
$ vim /var/lib/pgsql/scripts/nonpar_select.sql
\set v_persion_id random(1, 100000)
\set v_del_flag random(1, 2)
BEGIN;
select * from tmp_t0 where persion_id= cast(:v_persion_id as varchar) and del_flag = :v_del_flag ;
END;
# su - postgres
$ /usr/pgsql-10/bin/pgbench -r -j 2 -c 4 -T 60 -P 1 -f /var/lib/pgsql/scripts/nonpar_select.sql pgbenchdb
starting vacuum...end.
progress: 1.0 s, 991.8 tps, lat 3.924 ms stddev 30.360
progress: 2.0 s, 1074.1 tps, lat 3.725 ms stddev 29.259
progress: 3.0 s, 1910.2 tps, lat 2.096 ms stddev 11.461
transaction type: /var/lib/pgsql/scripts/nonpar_select.sql
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 2
duration: 60 s
number of transactions actually processed: 97688
latency average = 2.456 ms
latency stddev = 10.565 ms
tps = 1628.044136 (including connections establishing)
tps = 1628.392086 (excluding connections establishing)
script statistics:
- statement latencies in milliseconds:
0.008 \set v_persion_id random(1, 100000)
0.002 \set v_del_flag random(1, 2)
0.476 BEGIN;
1.451 select * from tmp_t0 where persion_id= cast(:v_persion_id as varchar) and del_flag = :v_del_flag;
0.524 END;
# su - postgres
$ vim /var/lib/pgsql/scripts/nonpar_update.sql
\set v_persion_id random(1, 100000)
\set v_del_flag random(1, 2)
BEGIN;
update tmp_t0 set create_time=CURRENT_TIMESTAMP,del_flag=:v_del_flag where persion_id= cast(:v_persion_id as varchar) and del_flag = :v_del_flag ;
END;
# su - postgres
$ /usr/pgsql-10/bin/pgbench -r -j 2 -c 4 -T 60 -P 1 -f /var/lib/pgsql/scripts/nonpar_update.sql pgbenchdb
starting vacuum...end.
progress: 1.0 s, 2077.5 tps, lat 1.911 ms stddev 1.582
progress: 2.0 s, 2240.3 tps, lat 1.787 ms stddev 1.531
progress: 3.0 s, 1848.6 tps, lat 2.163 ms stddev 16.490
transaction type: /var/lib/pgsql/scripts/nonpar_update.sql
scaling factor: 1
query mode: simple
number of clients: 4
number of threads: 2
duration: 60 s
number of transactions actually processed: 122990
latency average = 1.951 ms
latency stddev = 13.601 ms
tps = 2049.744565 (including connections establishing)
tps = 2049.838284 (excluding connections establishing)
script statistics:
- statement latencies in milliseconds:
0.002 \set v_persion_id random(1, 100000)
0.000 \set v_del_flag random(1, 2)
0.214 BEGIN;
0.515 update tmp_t0 set create_time=CURRENT_TIMESTAMP,del_flag=:v_del_flag where persion_id= cast(:v_persion_id as varchar) and del_flag = :v_del_flag ;
1.221 END;