#!/bin/bash nloops=30000 rows=1000 dbname=postgres port=5432 seconds=30 psql -c "drop table if exists hjtbl;" -p $port $dbname psql -c "create table hjtbl (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null);" -p $port $dbname psql -c "insert into hjtbl select a,a,a,a,a,a from generate_series(1,$rows) a;" -p $port $dbname psql -c "vacuum freeze analyze hjtbl;" -p $port $dbname psql -c "alter system set jit_above_cost = 0;" -p $port $dbname psql -c "alter system set jit_optimize_above_cost = 1000000000;" -p $port $dbname psql -c "alter system set jit_inline_above_cost = 1000000000;" -p $port $dbname psql -c "select pg_reload_conf();" -p $port $dbname for alt_sys in "alter system set jit = 0;" "alter system set jit = 1;" "alter system set jit_optimize_above_cost = 0;" "alter system set jit_inline_above_cost = 0;" do echo "$alt_sys" psql -c "$alt_sys" -p $port $dbname > /dev/null psql -c "select pg_Reload_conf();" -p $port $dbname > /dev/null q=1 for sql in "select count(*) c from (select a,b,c,d,e,f from hjtbl cross join generate_Series(1,$nloops) offset 0) h1 inner join hjtbl using(a);" "select count(*) c from (select a,b,c,d,e,f from hjtbl cross join generate_Series(1,$nloops) offset 0) h1 inner join hjtbl using(a,b);" "select count(*) c from (select a,b,c,d,e,f from hjtbl cross join generate_Series(1,$nloops) offset 0) h1 inner join hjtbl using(a,b,c);" "select count(*) c from (select a,b,c,d,e,f from hjtbl cross join generate_Series(1,$nloops) offset 0) h1 inner join hjtbl using(a,b,c,d);" "select count(*) c from (select a,b,c,d,e,f from hjtbl cross join generate_Series(1,$nloops) offset 0) h1 inner join hjtbl using(a,b,c,d,e);" "select count(*) c from (select a,b,c,d,e,f from hjtbl cross join generate_Series(1,$nloops) offset 0) h1 inner join hjtbl using(a,b,c,d,e,f);" do echo $sql > bench.sql echo -n "Q$q " pgbench -n -f bench.sql -p $port -M prepared -T $seconds $dbname | grep latency q=$((q+1)) done done