-
Notifications
You must be signed in to change notification settings - Fork 3
/
smalltwo.sh
executable file
·36 lines (35 loc) · 1004 Bytes
/
smalltwo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
#
# The point of this benchmark is in large part to get a sense of the
# performance overhead of unnecessarily value locking a serial PK, where
# presumably the sequential serial values represent a worse case for value
# locking. In the btree locking approach to value locking (A.K.A. Approach
# #1), we lock primary key last and release it first, partly in anticipation of
# this problem.
#
# This variant of two benchmark tries to stress contention harder with a
# smaller scale factor (though ordinary lock contention comes to dominate).
if [[ $1 ]]; then
count=$1
else
count=10000000
fi
echo "running $0 benchmark $count times"
while [ $count -gt 0 ]
do
rand=`shuf -i 10-20 -n 1`
echo "trying $0 $rand second run"
psql -c "drop table if exists foo;"
echo 'create table foo
(
a serial primary key,
merge int4 unique,
payload text
);' | psql
pgbench -f benchtwo.sql -j 4 -c 8 -T $rand -n -s 15
./foocount.sh
if [[ $? != 0 ]]; then
exit 1
fi
count=$(( $count - 1 ))
done