#!/bin/bash alias /usr/local/pgsql/bin/psql="/usr/local/pgsql/bin//usr/local/pgsql/bin/psql" alias /usr/local/pgsql/bin/pgbench="/usr/local/pgsql/bin//usr/local/pgsql/bin/pgbench" /usr/local/pgsql/bin/psql -c "create table if not exists abc (a int, b int, c int);" postgres for rows in 1000000 10000000 do for mod in 1 10 100 1000 10000 100000 1000000 do for selectrows in "select x%$mod,x%$mod,x from generate_Series(1,$rows) x;" "select x / ($rows / $mod),x / ($rows / $mod) ,x from generate_Series(1,$rows) x;" "select x % $mod * random(),x % $mod * random(),x from generate_Series(1,$rows) x;" do /usr/local/pgsql/bin/psql -c "truncate table abc;" postgres > /dev/null /usr/local/pgsql/bin/psql -c "insert into abc $selectrows" postgres > /dev/null /usr/local/pgsql/bin/psql -c "vacuum freeze abc;" postgres > /dev/null /usr/local/pgsql/bin/psql -c "select pg_prewarm('abc');" postgres > /dev/null echo "select a,b,row_number() over (order by a,b) from abc order by a,b,c" > bench.sql /usr/local/pgsql/bin/psql -c "alter system set enable_sort_pushdown = off;" postgres > /dev/null /usr/local/pgsql/bin/psql -c "select pg_reload_conf();" postgres > /dev/null echo -n "$rows $mod Master: " /usr/local/pgsql/bin/pgbench -n -f bench.sql -T 10 -M prepared postgres | grep latency /usr/local/pgsql/bin/psql -c "alter system set enable_sort_pushdown = on;" postgres > /dev/null /usr/local/pgsql/bin/psql -c "select pg_reload_conf();" postgres > /dev/null echo -n "$rows $mod Patched: " /usr/local/pgsql/bin/pgbench -n -f bench.sql -T 10 -M prepared postgres | grep latency done done done