-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate.sh
executable file
·57 lines (54 loc) · 1.72 KB
/
update.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
#
# Test upsert as a replacement for update...range of possible values to upsert
# on is so large that insert will almost never occur.
#
# This benchmark appears to indicate that even with heavyweight page locks, the
# performance of these two cases is remarkably similar
#
# Only useful for benchmarking, and so not called by main.sh
if [[ $1 ]]; then
count=$1
else
count=10000000
fi
bold=`tput bold`
normal=`tput sgr0`
NC='\e[0m' # No Color
seconds=60
# number of tuples to update is actually $tuples * 10
tuples=1000000
pretuples=100000
echo "running $0 benchmark $count times"
echo "Test upsert as a replacement for update...no insert part, for comparison against raw update performance"
echo "${bold}UPSERT with no inserts, only updates, vs. equivalent updates${normal}"
while [ $count -gt 0 ]
do
echo "running $0 benchmark"
echo "trying $seconds second run ${bold}(new infrastructure, extended hwlocking)${normal}"
psql -c "drop table if exists foo;"
echo 'create table foo
(
merge serial primary key,
b int4,
c text
);' | psql
echo "${bold}pre-inserting tuples to update${normal}"
pgbench -f benchplaininsert.sql -j 4 -c 12 -t $pretuples -n -s $tuples > /dev/null
psql -c "checkpoint;"
pgbench -f benchupdate.sql -c 8 -T $seconds -n -s $tuples
echo "trying $seconds second run ${bold}(traditional updates, equivalent to master)${normal}"
psql -c "drop table if exists foo;"
echo 'create table foo
(
merge serial primary key,
b int4,
c text
);' | psql
echo "${bold}pre-inserting tuples to update${normal}"
pgbench -f benchplaininsert.sql -c 10 -t $pretuples -n -s $tuples > /dev/null
psql -c "checkpoint;"
pgbench -f benchplainupdate.sql -c 8 -T $seconds -n -s $tuples
count=$(( $count - 1 ))
echo -e "\n\n"
done