repro.txt

text/plain

Filename: repro.txt
Type: text/plain
Part: 0
Message: connection establishment versus parallel workers
setup:

psql -h "$host" -U "$user" postgres <<EOF
create database mydb;
\c mydb
create table mytable (a int);
insert into mytable (a) select * from generate_series(1, 500000);
EOF

--

start many parallel workers (may need to change -c and -j):

pgbench -h "$host" -U "$user" mydb -c 30 -j 2 -T 300 -f <(echo '
begin;
select count(*) from mytable;
end;')

--

while pgbench is running, check connection establishment times:

while :; do
  time pg_isready -h "$host" -U "$user" -d postgres
  sleep 1
done